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