Fix units from transports appearing at load point.

This commit is contained in:
tovl
2019-08-12 00:46:54 +02:00
committed by abcdefg30
parent 70459b311e
commit 2d394f33b8
22 changed files with 186 additions and 86 deletions

View File

@@ -191,7 +191,7 @@ namespace OpenRA.Mods.Cnc.Traits
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; } WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange, public Activity MoveFollow(Actor self, Target target, WDist minRange, WDist maxRange,
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; } WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) { return null; } public Activity MoveIntoWorld(Actor self, int delay = 0) { return null; }
public Activity MoveToTarget(Actor self, Target target, public Activity MoveToTarget(Actor self, Target target,
WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; } WPos? initialTargetPosition = null, Color? targetLineColor = null) { return null; }
public Activity MoveIntoTarget(Actor self, Target target) { return null; } public Activity MoveIntoTarget(Actor self, Target target) { return null; }

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities
public abstract class Enter : Activity public abstract class Enter : Activity
{ {
enum EnterState { Approaching, Entering, Exiting } enum EnterState { Approaching, Entering, Exiting, Finished }
readonly IMove move; readonly IMove move;
readonly Color? targetLineColor; readonly Color? targetLineColor;
@@ -133,15 +133,18 @@ namespace OpenRA.Mods.Common.Activities
OnEnterComplete(self, target.Actor); OnEnterComplete(self, target.Actor);
lastState = EnterState.Exiting; lastState = EnterState.Exiting;
QueueChild(move.MoveIntoWorld(self, self.Location));
return false; return false;
} }
case EnterState.Exiting: case EnterState.Exiting:
return true; {
QueueChild(move.MoveIntoWorld(self));
lastState = EnterState.Finished;
return false;
}
} }
return false; return true;
} }
public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self) public override IEnumerable<TargetLineNode> TargetLineNodes(Actor self)

View File

@@ -19,14 +19,12 @@ namespace OpenRA.Mods.Common.Activities
{ {
readonly IPositionable pos; readonly IPositionable pos;
readonly WVec fallVector; readonly WVec fallVector;
readonly Actor ignore;
int groundLevel; int groundLevel;
public Parachute(Actor self, Actor ignoreActor = null) public Parachute(Actor self)
{ {
pos = self.TraitOrDefault<IPositionable>(); pos = self.TraitOrDefault<IPositionable>();
ignore = ignoreActor;
fallVector = new WVec(0, 0, self.Info.TraitInfo<ParachutableInfo>().FallRate); fallVector = new WVec(0, 0, self.Info.TraitInfo<ParachutableInfo>().FallRate);
IsInterruptible = false; IsInterruptible = false;
@@ -56,7 +54,7 @@ namespace OpenRA.Mods.Common.Activities
pos.SetPosition(self, centerPosition + new WVec(0, 0, groundLevel - centerPosition.Z)); pos.SetPosition(self, centerPosition + new WVec(0, 0, groundLevel - centerPosition.Z));
foreach (var np in self.TraitsImplementing<INotifyParachute>()) foreach (var np in self.TraitsImplementing<INotifyParachute>())
np.OnLanded(self, ignore); np.OnLanded(self);
} }
} }
} }

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Activities namespace OpenRA.Mods.Common.Activities
{ {
class EnterTransport : Enter class RideTransport : Enter
{ {
readonly Passenger passenger; readonly Passenger passenger;
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
Cargo enterCargo; Cargo enterCargo;
Aircraft enterAircraft; Aircraft enterAircraft;
public EnterTransport(Actor self, Target target) public RideTransport(Actor self, Target target)
: base(self, target, Color.Green) : base(self, target, Color.Green)
{ {
passenger = self.Trait<Passenger>(); passenger = self.Trait<Passenger>();
@@ -63,10 +63,6 @@ namespace OpenRA.Mods.Common.Activities
enterCargo.Load(enterActor, self); enterCargo.Load(enterActor, self);
w.Remove(self); w.Remove(self);
// Preemptively cancel any activities to avoid an edge-case where successively queued
// EnterTransports corrupt the actor state. Activities are cancelled again on unload
self.CancelActivity();
}); });
} }

View File

@@ -121,9 +121,10 @@ namespace OpenRA.Mods.Common.Activities
var move = actor.Trait<IMove>(); var move = actor.Trait<IMove>();
var pos = actor.Trait<IPositionable>(); var pos = actor.Trait<IPositionable>();
actor.CancelActivity(); pos.SetPosition(self, exitSubCell.Value.First, exitSubCell.Value.Second);
pos.SetVisualPosition(actor, spawn); pos.SetVisualPosition(actor, spawn);
actor.QueueActivity(move.MoveIntoWorld(actor, exitSubCell.Value.First, exitSubCell.Value.Second));
actor.CancelActivity();
w.Add(actor); w.Add(actor);
}); });
} }

View File

@@ -24,6 +24,16 @@ namespace OpenRA.Mods.Common
public int Value(World world) { return value; } public int Value(World world) { return value; }
} }
public class MoveIntoWorldDelayInit : IActorInit<int>
{
[FieldFromYamlKey]
readonly int value = 0;
public MoveIntoWorldDelayInit() { }
public MoveIntoWorldDelayInit(int init) { value = init; }
public int Value(World world) { return value; }
}
public class DynamicFacingInit : IActorInit<Func<int>> public class DynamicFacingInit : IActorInit<Func<int>>
{ {
readonly Func<int> func; readonly Func<int> func;

View File

@@ -46,7 +46,10 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Moves from outside the world into the cell grid.")] [Desc("Moves from outside the world into the cell grid.")]
public void MoveIntoWorld(CPos cell) public void MoveIntoWorld(CPos cell)
{ {
Self.QueueActivity(mobile.MoveIntoWorld(Self, cell, mobile.ToSubCell)); var pos = Self.CenterPosition;
mobile.SetPosition(Self, cell);
mobile.SetVisualPosition(Self, pos);
Self.QueueActivity(mobile.MoveIntoWorld(Self));
} }
[ScriptActorPropertyActivity] [ScriptActorPropertyActivity]
@@ -60,7 +63,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Move to and enter the transport.")] [Desc("Move to and enter the transport.")]
public void EnterTransport(Actor transport) public void EnterTransport(Actor transport)
{ {
Self.QueueActivity(new EnterTransport(Self, Target.FromActor(transport))); Self.QueueActivity(new RideTransport(Self, Target.FromActor(transport)));
} }
[Desc("Whether the actor can move (false if immobilized).")] [Desc("Whether the actor can move (false if immobilized).")]

View File

@@ -219,6 +219,7 @@ namespace OpenRA.Mods.Common.Traits
public bool ForceLanding { get; private set; } public bool ForceLanding { get; private set; }
IEnumerable<CPos> landingCells = Enumerable.Empty<CPos>(); IEnumerable<CPos> landingCells = Enumerable.Empty<CPos>();
bool requireForceMove; bool requireForceMove;
int moveIntoWorldDelay;
public static WPos GroundPosition(Actor self) public static WPos GroundPosition(Actor self)
{ {
@@ -229,7 +230,6 @@ namespace OpenRA.Mods.Common.Traits
bool airborne; bool airborne;
bool cruising; bool cruising;
bool firstTick = true;
int airborneToken = ConditionManager.InvalidConditionToken; int airborneToken = ConditionManager.InvalidConditionToken;
int cruisingToken = ConditionManager.InvalidConditionToken; int cruisingToken = ConditionManager.InvalidConditionToken;
@@ -250,6 +250,7 @@ namespace OpenRA.Mods.Common.Traits
SetPosition(self, init.Get<CenterPositionInit, WPos>()); SetPosition(self, init.Get<CenterPositionInit, WPos>());
Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : Info.InitialFacing; Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : Info.InitialFacing;
moveIntoWorldDelay = init.Contains<MoveIntoWorldDelayInit>() ? init.Get<MoveIntoWorldDelayInit, int>() : 0;
} }
public WDist LandAltitude public WDist LandAltitude
@@ -307,6 +308,8 @@ namespace OpenRA.Mods.Common.Traits
notifyMoving = self.TraitsImplementing<INotifyMoving>().ToArray(); notifyMoving = self.TraitsImplementing<INotifyMoving>().ToArray();
positionOffsets = self.TraitsImplementing<IAircraftCenterPositionOffset>().ToArray(); positionOffsets = self.TraitsImplementing<IAircraftCenterPositionOffset>().ToArray();
overrideAircraftLanding = self.TraitOrDefault<IOverrideAircraftLanding>(); overrideAircraftLanding = self.TraitOrDefault<IOverrideAircraftLanding>();
self.QueueActivity(MoveIntoWorld(self, moveIntoWorldDelay));
} }
void INotifyAddedToWorld.AddedToWorld(Actor self) void INotifyAddedToWorld.AddedToWorld(Actor self)
@@ -346,20 +349,6 @@ namespace OpenRA.Mods.Common.Traits
protected virtual void Tick(Actor self) protected virtual void Tick(Actor self)
{ {
if (firstTick)
{
firstTick = false;
var host = GetActorBelow();
if (host == null)
return;
MakeReservation(host);
if (Info.TakeOffOnCreation)
UnReserve(true);
}
// Add land activity if LandOnCondition resolves to true and the actor can land at the current location. // Add land activity if LandOnCondition resolves to true and the actor can land at the current location.
if (!ForceLanding && landNow.HasValue && landNow.Value && airborne && CanLand(self.Location) if (!ForceLanding && landNow.HasValue && landNow.Value && airborne && CanLand(self.Location)
&& !((self.CurrentActivity is Land) || self.CurrentActivity is Turn)) && !((self.CurrentActivity is Land) || self.CurrentActivity is Turn))
@@ -868,9 +857,46 @@ namespace OpenRA.Mods.Common.Traits
initialTargetPosition, targetLineColor); initialTargetPosition, targetLineColor);
} }
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) public Activity MoveIntoWorld(Actor self, int delay = 0)
{ {
return new Fly(self, Target.FromCell(self.World, cell, subCell)); return new MoveIntoWorldActivity(self, delay);
}
class MoveIntoWorldActivity : Activity
{
readonly Actor self;
readonly Aircraft aircraft;
readonly int delay;
public MoveIntoWorldActivity(Actor self, int delay = 0)
{
this.self = self;
aircraft = self.Trait<Aircraft>();
IsInterruptible = false;
this.delay = delay;
}
protected override void OnFirstRun(Actor self)
{
var host = aircraft.GetActorBelow();
if (host != null)
aircraft.MakeReservation(host);
if (delay > 0)
QueueChild(new Wait(delay));
}
public override bool Tick(Actor self)
{
if (!aircraft.Info.TakeOffOnCreation)
return true;
if (self.World.Map.DistanceAboveTerrain(aircraft.CenterPosition).Length <= aircraft.LandAltitude.Length)
QueueChild(new TakeOff(self));
aircraft.UnReserve();
return true;
}
} }
public Activity MoveToTarget(Actor self, Target target, public Activity MoveToTarget(Actor self, Target target,

View File

@@ -29,9 +29,6 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Type tags on this exit.")] [Desc("Type tags on this exit.")]
public readonly HashSet<string> ProductionTypes = new HashSet<string>(); public readonly HashSet<string> ProductionTypes = new HashSet<string>();
[Desc("AttackMove to a RallyPoint or stay where you are spawned.")]
public readonly bool MoveIntoWorld = true;
[Desc("Number of ticks to wait before moving into the world.")] [Desc("Number of ticks to wait before moving into the world.")]
public readonly int ExitDelay = 0; public readonly int ExitDelay = 0;

View File

@@ -11,6 +11,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Traits.Render; using OpenRA.Mods.Common.Traits.Render;
using OpenRA.Primitives; using OpenRA.Primitives;
using OpenRA.Traits; using OpenRA.Traits;
@@ -106,7 +107,7 @@ namespace OpenRA.Mods.Common.Traits
} }
void INotifyParachute.OnParachute(Actor self) { } void INotifyParachute.OnParachute(Actor self) { }
void INotifyParachute.OnLanded(Actor self, Actor ignore) void INotifyParachute.OnLanded(Actor self)
{ {
// Check whether the crate landed on anything // Check whether the crate landed on anything
var landedOn = self.World.ActorMap.GetActorsAt(self.Location) var landedOn = self.World.ActorMap.GetActorsAt(self.Location)
@@ -237,6 +238,9 @@ namespace OpenRA.Mods.Common.Traits
var cs = self.World.WorldActor.TraitOrDefault<CrateSpawner>(); var cs = self.World.WorldActor.TraitOrDefault<CrateSpawner>();
if (cs != null) if (cs != null)
cs.IncrementCrates(); cs.IncrementCrates();
if (self.World.Map.DistanceAboveTerrain(CenterPosition) > WDist.Zero && self.TraitOrDefault<Parachutable>() != null)
self.QueueActivity(new Parachute(self));
} }
void INotifyRemovedFromWorld.RemovedFromWorld(Actor self) void INotifyRemovedFromWorld.RemovedFromWorld(Actor self)

View File

@@ -82,11 +82,10 @@ namespace OpenRA.Mods.Common.Traits
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {
pilotPositionable.SetPosition(pilot, pilotCell, pilotSubCell); pilotPositionable.SetPosition(pilot, pilotCell, pilotSubCell);
w.Add(pilot);
var dropPosition = pilot.CenterPosition + new WVec(0, 0, self.CenterPosition.Z - pilot.CenterPosition.Z); var dropPosition = pilot.CenterPosition + new WVec(0, 0, self.CenterPosition.Z - pilot.CenterPosition.Z);
pilotPositionable.SetVisualPosition(pilot, dropPosition); pilotPositionable.SetVisualPosition(pilot, dropPosition);
pilot.QueueActivity(new Parachute(pilot));
w.Add(pilot);
}); });
Game.Sound.Play(SoundType.World, Info.ChuteSound, cp); Game.Sound.Play(SoundType.World, Info.ChuteSound, cp);

View File

@@ -144,6 +144,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
readonly Actor self; readonly Actor self;
readonly Lazy<IEnumerable<int>> speedModifiers; readonly Lazy<IEnumerable<int>> speedModifiers;
readonly int moveIntoWorldDelay;
#region IMove CurrentMovementTypes #region IMove CurrentMovementTypes
MovementType movementTypes; MovementType movementTypes;
@@ -239,6 +240,8 @@ namespace OpenRA.Mods.Common.Traits
// Use LocationInit if you want to insert the actor into the ActorMap! // Use LocationInit if you want to insert the actor into the ActorMap!
if (init.Contains<CenterPositionInit>()) if (init.Contains<CenterPositionInit>())
SetVisualPosition(self, init.Get<CenterPositionInit, WPos>()); SetVisualPosition(self, init.Get<CenterPositionInit, WPos>());
moveIntoWorldDelay = init.Contains<MoveIntoWorldDelayInit>() ? init.Get<MoveIntoWorldDelayInit, int>() : 0;
} }
protected override void Created(Actor self) protected override void Created(Actor self)
@@ -251,6 +254,7 @@ namespace OpenRA.Mods.Common.Traits
Locomotor = self.World.WorldActor.TraitsImplementing<Locomotor>() Locomotor = self.World.WorldActor.TraitsImplementing<Locomotor>()
.Single(l => l.Info.Name == Info.Locomotor); .Single(l => l.Info.Name == Info.Locomotor);
self.QueueActivity(MoveIntoWorld(self, moveIntoWorldDelay));
base.Created(self); base.Created(self);
} }
@@ -563,22 +567,59 @@ namespace OpenRA.Mods.Common.Traits
return WrapMove(new Follow(self, target, minRange, maxRange, initialTargetPosition, targetLineColor)); return WrapMove(new Follow(self, target, minRange, maxRange, initialTargetPosition, targetLineColor));
} }
public Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any) public Activity MoveIntoWorld(Actor self, int delay = 0)
{ {
var pos = self.CenterPosition; return new MoveIntoWorldActivity(self, delay);
}
if (subCell == SubCell.Any) class MoveIntoWorldActivity : Activity
subCell = Info.LocomotorInfo.SharesCell ? self.World.ActorMap.FreeSubCell(cell, subCell) : SubCell.FullCell; {
readonly Actor self;
readonly Mobile mobile;
// TODO: solve/reduce cell is full problem CPos cell;
if (subCell == SubCell.Invalid) SubCell subCell;
subCell = self.World.Map.Grid.DefaultSubCell; WPos pos;
int delay;
// Reserve the exit cell public MoveIntoWorldActivity(Actor self, int delay = 0)
SetPosition(self, cell, subCell); {
SetVisualPosition(self, pos); this.self = self;
mobile = self.Trait<Mobile>();
IsInterruptible = false;
this.delay = delay;
}
return WrapMove(VisualMove(self, pos, self.World.Map.CenterOfSubCell(cell, subCell), cell)); protected override void OnFirstRun(Actor self)
{
pos = self.CenterPosition;
if (self.World.Map.DistanceAboveTerrain(pos) > WDist.Zero && self.TraitOrDefault<Parachutable>() != null)
QueueChild(new Parachute(self));
}
public override bool Tick(Actor self)
{
pos = self.CenterPosition;
cell = mobile.ToCell;
subCell = mobile.ToSubCell;
if (subCell == SubCell.Any)
subCell = mobile.Info.LocomotorInfo.SharesCell ? self.World.ActorMap.FreeSubCell(cell, subCell) : SubCell.FullCell;
// TODO: solve/reduce cell is full problem
if (subCell == SubCell.Invalid)
subCell = self.World.Map.Grid.DefaultSubCell;
// Reserve the exit cell
mobile.SetPosition(self, cell, subCell);
mobile.SetVisualPosition(self, pos);
if (delay > 0)
QueueChild(new Wait(delay));
QueueChild(mobile.VisualMove(self, pos, self.World.Map.CenterOfSubCell(cell, subCell)));
return true;
}
} }
public Activity MoveToTarget(Actor self, Target target, public Activity MoveToTarget(Actor self, Target target,

View File

@@ -105,12 +105,10 @@ namespace OpenRA.Mods.Common.Traits
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {
dropPositionable.SetPosition(dropActor, dropCell, dropSubCell); dropPositionable.SetPosition(dropActor, dropCell, dropSubCell);
w.Add(dropActor);
var dropPosition = dropActor.CenterPosition + new WVec(0, 0, self.CenterPosition.Z - dropActor.CenterPosition.Z); var dropPosition = dropActor.CenterPosition + new WVec(0, 0, self.CenterPosition.Z - dropActor.CenterPosition.Z);
dropPositionable.SetVisualPosition(dropActor, dropPosition); dropPositionable.SetVisualPosition(dropActor, dropPosition);
w.Add(dropActor);
dropActor.QueueActivity(new Parachute(dropActor));
}); });
Game.Sound.Play(SoundType.World, info.ChuteSound, self.CenterPosition); Game.Sound.Play(SoundType.World, info.ChuteSound, self.CenterPosition);

View File

@@ -62,6 +62,8 @@ namespace OpenRA.Mods.Common.Traits
readonly ParachutableInfo info; readonly ParachutableInfo info;
readonly IPositionable positionable; readonly IPositionable positionable;
public Actor IgnoreActor;
ConditionManager conditionManager; ConditionManager conditionManager;
int parachutingToken = ConditionManager.InvalidConditionToken; int parachutingToken = ConditionManager.InvalidConditionToken;
@@ -86,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
parachutingToken = conditionManager.GrantCondition(self, info.ParachutingCondition); parachutingToken = conditionManager.GrantCondition(self, info.ParachutingCondition);
} }
void INotifyParachute.OnLanded(Actor self, Actor ignore) void INotifyParachute.OnLanded(Actor self)
{ {
IsInAir = false; IsInAir = false;
@@ -100,7 +102,7 @@ namespace OpenRA.Mods.Common.Traits
if (positionable.CanEnterCell(cell, self)) if (positionable.CanEnterCell(cell, self))
return; return;
if (ignore != null && self.World.ActorMap.GetActorsAt(cell).Any(a => a != ignore)) if (IgnoreActor != null && self.World.ActorMap.GetActorsAt(cell).Any(a => a != IgnoreActor))
return; return;
var onWater = info.WaterTerrainTypes.Contains(self.World.Map.GetTerrainInfo(cell).Type); var onWater = info.WaterTerrainTypes.Contains(self.World.Map.GetTerrainInfo(cell).Type);

View File

@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Common.Traits
if (!order.Queued) if (!order.Queued)
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new EnterTransport(self, order.Target)); self.QueueActivity(new RideTransport(self, order.Target));
self.ShowTargetLines(); self.ShowTargetLines();
} }

View File

@@ -73,6 +73,8 @@ namespace OpenRA.Mods.Common.Traits
td.Add(new LocationInit(exit)); td.Add(new LocationInit(exit));
td.Add(new CenterPositionInit(spawn)); td.Add(new CenterPositionInit(spawn));
td.Add(new FacingInit(initialFacing)); td.Add(new FacingInit(initialFacing));
if (exitinfo != null)
td.Add(new MoveIntoWorldDelayInit(exitinfo.ExitDelay));
} }
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
@@ -81,16 +83,7 @@ namespace OpenRA.Mods.Common.Traits
var move = newUnit.TraitOrDefault<IMove>(); var move = newUnit.TraitOrDefault<IMove>();
if (exitinfo != null && move != null) if (exitinfo != null && move != null)
{ newUnit.QueueActivity(new AttackMoveActivity(newUnit, () => move.MoveTo(exitLocation, 1, targetLineColor: Color.OrangeRed)));
if (exitinfo.MoveIntoWorld)
{
if (exitinfo.ExitDelay > 0)
newUnit.QueueActivity(new Wait(exitinfo.ExitDelay, false));
newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit));
newUnit.QueueActivity(new AttackMoveActivity(newUnit, () => move.MoveTo(exitLocation, 1, targetLineColor: Color.OrangeRed)));
}
}
if (!self.IsDead) if (!self.IsDead)
foreach (var t in self.TraitsImplementing<INotifyProduction>()) foreach (var t in self.TraitsImplementing<INotifyProduction>())

View File

@@ -127,25 +127,17 @@ namespace OpenRA.Mods.Common.Traits
td.Add(new LocationInit(exit)); td.Add(new LocationInit(exit));
td.Add(new CenterPositionInit(spawn)); td.Add(new CenterPositionInit(spawn));
td.Add(new FacingInit(initialFacing)); td.Add(new FacingInit(initialFacing));
td.Add(new MoveIntoWorldDelayInit(exitinfo.ExitDelay));
} }
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {
var newUnit = self.World.CreateActor(producee.Name, td); var newUnit = self.World.CreateActor(producee.Name, td);
newUnit.Trait<Parachutable>().IgnoreActor = self;
newUnit.QueueActivity(new Parachute(newUnit, self));
var move = newUnit.TraitOrDefault<IMove>(); var move = newUnit.TraitOrDefault<IMove>();
if (move != null) if (move != null)
{ newUnit.QueueActivity(new AttackMoveActivity(newUnit, () => move.MoveTo(exitLocation, 1, targetLineColor: Color.OrangeRed)));
if (exitinfo.MoveIntoWorld)
{
if (exitinfo.ExitDelay > 0)
newUnit.QueueActivity(new Wait(exitinfo.ExitDelay, false));
newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit));
newUnit.QueueActivity(new AttackMoveActivity(newUnit, () => move.MoveTo(exitLocation, 1, targetLineColor: Color.OrangeRed)));
}
}
if (!self.IsDead) if (!self.IsDead)
foreach (var t in self.TraitsImplementing<INotifyProduction>()) foreach (var t in self.TraitsImplementing<INotifyProduction>())

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits.Render
void INotifyParachute.OnParachute(Actor self) { } void INotifyParachute.OnParachute(Actor self) { }
void INotifyParachute.OnLanded(Actor self, Actor ignore) void INotifyParachute.OnLanded(Actor self)
{ {
PlaySequence(); PlaySequence();
} }

View File

@@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Traits
[RequireExplicitImplementation] [RequireExplicitImplementation]
public interface INotifyResourceAccepted { void OnResourceAccepted(Actor self, Actor refinery, int amount); } public interface INotifyResourceAccepted { void OnResourceAccepted(Actor self, Actor refinery, int amount); }
public interface INotifyParachute { void OnParachute(Actor self); void OnLanded(Actor self, Actor ignore); } public interface INotifyParachute { void OnParachute(Actor self); void OnLanded(Actor self); }
[RequireExplicitImplementation] [RequireExplicitImplementation]
public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner, BitSet<CaptureType> captureTypes); } public interface INotifyCapture { void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner, BitSet<CaptureType> captureTypes); }
@@ -435,7 +435,7 @@ namespace OpenRA.Mods.Common.Traits
WPos? initialTargetPosition = null, Color? targetLineColor = null); WPos? initialTargetPosition = null, Color? targetLineColor = null);
Activity MoveToTarget(Actor self, Target target, Activity MoveToTarget(Actor self, Target target,
WPos? initialTargetPosition = null, Color? targetLineColor = null); WPos? initialTargetPosition = null, Color? targetLineColor = null);
Activity MoveIntoWorld(Actor self, CPos cell, SubCell subCell = SubCell.Any); Activity MoveIntoWorld(Actor self, int delay = 0);
Activity MoveIntoTarget(Actor self, Target target); Activity MoveIntoTarget(Actor self, Target target);
Activity VisualMove(Actor self, WPos fromPos, WPos toPos); Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos); int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos);

View File

@@ -0,0 +1,38 @@
#region Copyright & License Information
/*
* Copyright 2007-2019 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
public class RemoveMoveIntoWorldFromExit : UpdateRule
{
public override string Name { get { return "Remove MoveIntoWorld from Exit."; } }
public override string Description
{
get
{
return "The MoveIntoWorld parameter has been removed from the Exit trait because it no\n" +
"longer serves a purpose (aircraft can now use the same exit procedure as other\n" +
"units).";
}
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var t in actorNode.ChildrenMatching("Exit"))
t.RemoveNodes("MoveIntoWorld");
yield break;
}
}
}

View File

@@ -133,6 +133,7 @@ namespace OpenRA.Mods.Common.UpdateRules
new AddCanSlide(), new AddCanSlide(),
new AddAircraftIdleBehavior(), new AddAircraftIdleBehavior(),
new RenameSearchRadius(), new RenameSearchRadius(),
new RemoveMoveIntoWorldFromExit(),
}) })
}; };

View File

@@ -1344,7 +1344,6 @@ HPAD:
RequiresCondition: !being-captured RequiresCondition: !being-captured
SpawnOffset: 0,-256,0 SpawnOffset: 0,-256,0
ExitCell: 0,0 ExitCell: 0,0
MoveIntoWorld: false
Facing: 224 Facing: 224
RallyPoint: RallyPoint:
Production: Production:
@@ -1435,7 +1434,6 @@ AFLD:
RequiresCondition: !being-captured RequiresCondition: !being-captured
ExitCell: 1,1 ExitCell: 1,1
Facing: 192 Facing: 192
MoveIntoWorld: false
RallyPoint: RallyPoint:
Production: Production:
Produces: Aircraft, Plane Produces: Aircraft, Plane