Generalize RallyPointInfo.Offset to support arbitrary length paths.
This commit is contained in:
@@ -228,8 +228,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
foreach (var rp in world.ActorsWithTrait<RallyPoint>())
|
||||
{
|
||||
if (rp.Actor.Owner == player &&
|
||||
!IsRallyPointValid(rp.Trait.Path[0], rp.Actor.Info.TraitInfoOrDefault<BuildingInfo>()))
|
||||
if (rp.Actor.Owner != player)
|
||||
continue;
|
||||
|
||||
if (rp.Trait.Path.Count == 0 || !IsRallyPointValid(rp.Trait.Path[0], rp.Actor.Info.TraitInfoOrDefault<BuildingInfo>()))
|
||||
{
|
||||
bot.QueueOrder(new Order("SetRallyPoint", rp.Actor, Target.FromCell(world, ChooseRallyLocationNear(rp.Actor)), false)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Custom palette is a player palette BaseName")]
|
||||
public readonly bool IsPlayerPalette = true;
|
||||
|
||||
public readonly CVec Offset = new CVec(1, 3);
|
||||
[Desc("A list of 0 or more offsets defining the initial rally point path.")]
|
||||
public readonly CVec[] Path = { new CVec(1, 3) };
|
||||
|
||||
public object Create(ActorInitializer init) { return new RallyPoint(init.Self, this); }
|
||||
}
|
||||
@@ -57,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void ResetPath(Actor self)
|
||||
{
|
||||
Path = new List<CPos> { self.Location + Info.Offset };
|
||||
Path = Info.Path.Select(p => self.Location + p).ToList();
|
||||
}
|
||||
|
||||
public RallyPoint(Actor self, RallyPointInfo info)
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
initialFacing = delta.Yaw.Facing;
|
||||
}
|
||||
|
||||
exitLocations = rp.Value != null ? rp.Value.Path : new List<CPos> { exit };
|
||||
exitLocations = rp.Value != null && rp.Value.Path.Count > 0 ? rp.Value.Path : new List<CPos> { exit };
|
||||
|
||||
td.Add(new LocationInit(exit));
|
||||
td.Add(new CenterPositionInit(spawn));
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var aircraftInfo = producee.TraitInfoOrDefault<AircraftInfo>();
|
||||
var mobileInfo = producee.TraitInfoOrDefault<MobileInfo>();
|
||||
|
||||
var destinations = rp != null ? rp.Path : new List<CPos> { self.Location };
|
||||
var destinations = rp != null && rp.Path.Count > 0 ? rp.Path : new List<CPos> { self.Location };
|
||||
|
||||
var location = spawnLocation;
|
||||
if (!location.HasValue)
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var initialFacing = exitinfo.Facing < 0 ? (to - spawn).Yaw.Facing : exitinfo.Facing;
|
||||
|
||||
exitLocations = rp.Value != null ? rp.Value.Path : new List<CPos> { exit };
|
||||
exitLocations = rp.Value != null && rp.Value.Path.Count > 0 ? rp.Value.Path : new List<CPos> { exit };
|
||||
|
||||
td.Add(new LocationInit(exit));
|
||||
td.Add(new CenterPositionInit(spawn));
|
||||
|
||||
Reference in New Issue
Block a user