Convert Exit to world coordinates.

This commit is contained in:
Paul Chote
2013-12-25 19:02:34 +13:00
parent f116c516ce
commit c7914ec68f
4 changed files with 11 additions and 12 deletions

View File

@@ -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),

View File

@@ -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);

View File

@@ -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));

View File

@@ -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);
}
}
}