Convert Exit to world coordinates.
This commit is contained in:
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
heli.Reservation = res.Reserve(dest, self, heli);
|
||||
|
||||
var exit = dest.Info.Traits.WithInterface<ExitInfo>().FirstOrDefault();
|
||||
var offset = (exit != null) ? exit.SpawnOffsetVector : WVec.Zero;
|
||||
var offset = (exit != null) ? exit.SpawnOffset : WVec.Zero;
|
||||
|
||||
return Util.SequenceActivities(
|
||||
new HeliFly(dest.CenterPosition + offset),
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace OpenRA.Mods.RA.Air
|
||||
Reservation = res.Reserve(order.TargetActor, self, this);
|
||||
|
||||
var exit = order.TargetActor.Info.Traits.WithInterface<ExitInfo>().FirstOrDefault();
|
||||
var offset = (exit != null) ? exit.SpawnOffsetVector : WVec.Zero;
|
||||
var offset = (exit != null) ? exit.SpawnOffset : WVec.Zero;
|
||||
|
||||
self.SetTargetLine(Target.FromActor(order.TargetActor), Color.Green);
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace OpenRA.Mods.RA.Missions
|
||||
cargo.Load(chinook, world.CreateActor(false, ChinookCargo.Random(world.SharedRandom), allies, null, null));
|
||||
|
||||
var exit = lz.Info.Traits.WithInterface<ExitInfo>().FirstOrDefault();
|
||||
var offset = (exit != null) ? exit.SpawnOffsetVector : WVec.Zero;
|
||||
var offset = (exit != null) ? exit.SpawnOffset : WVec.Zero;
|
||||
|
||||
chinook.QueueActivity(new HeliFly(lz.CenterPosition + offset)); // no reservation of hpad but it's not needed
|
||||
chinook.QueueActivity(new Turn(0));
|
||||
|
||||
@@ -28,13 +28,12 @@ namespace OpenRA.Mods.RA
|
||||
[Desc("Where the unit should leave the building. Multiples are allowed if IDs are added: Exit@2, ...")]
|
||||
public class ExitInfo : TraitInfo<Exit>
|
||||
{
|
||||
public readonly int2 SpawnOffset = int2.Zero; // in px relative to CenterLocation
|
||||
public readonly int2 ExitCell = int2.Zero; // in cells relative to TopLeft
|
||||
public readonly int Facing = -1;
|
||||
[Desc("Offset at which that the exiting actor is spawned")]
|
||||
public readonly WVec SpawnOffset = WVec.Zero;
|
||||
|
||||
// TODO: Push this conversion into the yaml
|
||||
public WVec SpawnOffsetVector { get { return new WVec(SpawnOffset.X, SpawnOffset.Y, 0) * 1024 / Game.CellSize; } }
|
||||
public CVec ExitCellVector { get { return (CVec)ExitCell; } }
|
||||
[Desc("Cell offset where the exiting actor enters the ActorMap")]
|
||||
public readonly CVec ExitCell = CVec.Zero;
|
||||
public readonly int Facing = -1;
|
||||
}
|
||||
|
||||
public class Exit { }
|
||||
@@ -49,8 +48,8 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo)
|
||||
{
|
||||
var exit = self.Location + exitinfo.ExitCellVector;
|
||||
var spawn = self.CenterPosition + exitinfo.SpawnOffsetVector;
|
||||
var exit = self.Location + exitinfo.ExitCell;
|
||||
var spawn = self.CenterPosition + exitinfo.SpawnOffset;
|
||||
var to = exit.CenterPosition;
|
||||
|
||||
var fi = producee.Traits.Get<IFacingInfo>();
|
||||
@@ -126,7 +125,7 @@ namespace OpenRA.Mods.RA
|
||||
var mobileInfo = producee.Traits.GetOrDefault<MobileInfo>();
|
||||
|
||||
return mobileInfo == null ||
|
||||
mobileInfo.CanEnterCell(self.World, self, self.Location + s.ExitCellVector, self, true, true);
|
||||
mobileInfo.CanEnterCell(self.World, self, self.Location + s.ExitCell, self, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user