Use MoveIntoWorld for production.

This commit is contained in:
Paul Chote
2014-03-19 13:11:30 +13:00
parent ac5a4589ea
commit 8b3b894fc5
2 changed files with 7 additions and 17 deletions

View File

@@ -34,6 +34,7 @@ namespace OpenRA.Mods.RA
[Desc("Cell offset where the exiting actor enters the ActorMap")] [Desc("Cell offset where the exiting actor enters the ActorMap")]
public readonly CVec ExitCell = CVec.Zero; public readonly CVec ExitCell = CVec.Zero;
public readonly int Facing = -1; public readonly int Facing = -1;
public readonly bool MoveIntoWorld = true;
} }
public class Exit { } public class Exit { }
@@ -58,28 +59,15 @@ namespace OpenRA.Mods.RA
var newUnit = self.World.CreateActor(producee.Name, new TypeDictionary var newUnit = self.World.CreateActor(producee.Name, new TypeDictionary
{ {
new OwnerInit(self.Owner), new OwnerInit(self.Owner),
new LocationInit(exit), new CenterPositionInit(spawn),
new FacingInit(initialFacing) new FacingInit(initialFacing)
}); });
// TODO: Move this into an *Init var move = newUnit.Trait<IMove>();
// TODO: We should be adjusting the actual position for aircraft, not just visuals. if (exitinfo.MoveIntoWorld)
var teleportable = newUnit.Trait<IPositionable>(); newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit));
teleportable.SetVisualPosition(newUnit, spawn);
// TODO: Generalize this for non-mobile (e.g. aircraft) too
// Remember to update the Enter activity too
var mobile = newUnit.TraitOrDefault<Mobile>();
if (mobile != null)
{
// Animate the spawn -> exit transition
var speed = mobile.MovementSpeedForCell(newUnit, exit);
var length = speed > 0 ? (to - spawn).Length / speed : 0;
newUnit.QueueActivity(new Drag(spawn, to, length));
}
var target = MoveToRallyPoint(self, newUnit, exit); var target = MoveToRallyPoint(self, newUnit, exit);
newUnit.SetTargetLine(Target.FromCell(target), Color.Green, false); newUnit.SetTargetLine(Target.FromCell(target), Color.Green, false);
foreach (var t in self.TraitsImplementing<INotifyProduction>()) foreach (var t in self.TraitsImplementing<INotifyProduction>())
t.UnitProduced(self, newUnit, exit); t.UnitProduced(self, newUnit, exit);

View File

@@ -1025,6 +1025,7 @@ HPAD:
Exit@1: Exit@1:
SpawnOffset: 0,-256,0 SpawnOffset: 0,-256,0
ExitCell: 0,0 ExitCell: 0,0
MoveIntoWorld: false
Production: Production:
Produces: Helicopter Produces: Helicopter
Reservable: Reservable:
@@ -1059,6 +1060,7 @@ AFLD:
SpawnOffset: 0,170,0 SpawnOffset: 0,170,0
ExitCell: 1,1 ExitCell: 1,1
Facing: 192 Facing: 192
MoveIntoWorld: false
Production: Production:
Produces: Plane Produces: Plane
Reservable: Reservable: