Generalize RallyPointInfo.Offset to support arbitrary length paths.
This commit is contained in:
@@ -187,7 +187,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
if (wasRepaired || isHostInvalid || (!stayOnResupplier && aircraft.Info.TakeOffOnResupply))
|
if (wasRepaired || isHostInvalid || (!stayOnResupplier && aircraft.Info.TakeOffOnResupply))
|
||||||
{
|
{
|
||||||
if (self.CurrentActivity.NextActivity == null && rp != null)
|
if (self.CurrentActivity.NextActivity == null && rp != null && rp.Path.Count > 0)
|
||||||
foreach (var cell in rp.Path)
|
foreach (var cell in rp.Path)
|
||||||
QueueChild(move.MoveTo(cell, 1, ignoreActor: repairableNear != null ? null : host.Actor, targetLineColor: Color.Green));
|
QueueChild(move.MoveTo(cell, 1, ignoreActor: repairableNear != null ? null : host.Actor, targetLineColor: Color.Green));
|
||||||
else
|
else
|
||||||
@@ -208,7 +208,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
// If there's a next activity and we're not RepairableNear, first leave host if the next activity is not a Move.
|
// If there's a next activity and we're not RepairableNear, first leave host if the next activity is not a Move.
|
||||||
if (self.CurrentActivity.NextActivity == null)
|
if (self.CurrentActivity.NextActivity == null)
|
||||||
{
|
{
|
||||||
if (rp != null)
|
if (rp != null && rp.Path.Count > 0)
|
||||||
foreach (var cell in rp.Path)
|
foreach (var cell in rp.Path)
|
||||||
QueueChild(move.MoveTo(cell, 1, repairableNear != null ? null : host.Actor, true));
|
QueueChild(move.MoveTo(cell, 1, repairableNear != null ? null : host.Actor, true));
|
||||||
else if (repairableNear == null)
|
else if (repairableNear == null)
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ namespace OpenRA.Mods.Common.Effects
|
|||||||
foreach (var c in cachedLocations)
|
foreach (var c in cachedLocations)
|
||||||
targetLineNodes.Add(world.Map.CenterOfCell(c));
|
targetLineNodes.Add(world.Map.CenterOfCell(c));
|
||||||
|
|
||||||
|
if (targetLineNodes.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
var exitPos = building.CenterPosition;
|
var exitPos = building.CenterPosition;
|
||||||
|
|
||||||
// Find closest exit
|
// Find closest exit
|
||||||
|
|||||||
@@ -79,8 +79,21 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
[Desc("Query or set a factory's rally point.")]
|
[Desc("Query or set a factory's rally point.")]
|
||||||
public CPos RallyPoint
|
public CPos RallyPoint
|
||||||
{
|
{
|
||||||
get { return rp.Path.Last(); }
|
get
|
||||||
set { rp.Path = new List<CPos> { value }; }
|
{
|
||||||
|
if (rp.Path.Count > 0)
|
||||||
|
return rp.Path.Last();
|
||||||
|
|
||||||
|
var exit = Self.FirstExitOrDefault();
|
||||||
|
if (exit != null)
|
||||||
|
return Self.Location + exit.Info.ExitCell;
|
||||||
|
|
||||||
|
return Self.Location;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
rp.Path = new List<CPos> { value };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -228,8 +228,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
foreach (var rp in world.ActorsWithTrait<RallyPoint>())
|
foreach (var rp in world.ActorsWithTrait<RallyPoint>())
|
||||||
{
|
{
|
||||||
if (rp.Actor.Owner == player &&
|
if (rp.Actor.Owner != player)
|
||||||
!IsRallyPointValid(rp.Trait.Path[0], rp.Actor.Info.TraitInfoOrDefault<BuildingInfo>()))
|
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)
|
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")]
|
[Desc("Custom palette is a player palette BaseName")]
|
||||||
public readonly bool IsPlayerPalette = true;
|
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); }
|
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)
|
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)
|
public RallyPoint(Actor self, RallyPointInfo info)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
initialFacing = delta.Yaw.Facing;
|
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 LocationInit(exit));
|
||||||
td.Add(new CenterPositionInit(spawn));
|
td.Add(new CenterPositionInit(spawn));
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var aircraftInfo = producee.TraitInfoOrDefault<AircraftInfo>();
|
var aircraftInfo = producee.TraitInfoOrDefault<AircraftInfo>();
|
||||||
var mobileInfo = producee.TraitInfoOrDefault<MobileInfo>();
|
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;
|
var location = spawnLocation;
|
||||||
if (!location.HasValue)
|
if (!location.HasValue)
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
var initialFacing = exitinfo.Facing < 0 ? (to - spawn).Yaw.Facing : exitinfo.Facing;
|
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 LocationInit(exit));
|
||||||
td.Add(new CenterPositionInit(spawn));
|
td.Add(new CenterPositionInit(spawn));
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||||
|
{
|
||||||
|
class RenameRallyPointPath : UpdateRule
|
||||||
|
{
|
||||||
|
public override string Name { get { return "Renamed RallyPoint Offset to Path"; } }
|
||||||
|
public override string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "The RallyPoint Offset property has been renamed to Path and now accepts multiple (or no) values.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||||
|
{
|
||||||
|
foreach (var rp in actorNode.ChildrenMatching("RallyPoint"))
|
||||||
|
rp.RenameChildrenMatching("Offset", "Path");
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -98,6 +98,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
new ReformatChromeProvider(),
|
new ReformatChromeProvider(),
|
||||||
new RenameSpins(),
|
new RenameSpins(),
|
||||||
new CreateScreenShakeWarhead(),
|
new CreateScreenShakeWarhead(),
|
||||||
|
new RenameRallyPointPath(),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ HAND:
|
|||||||
Range: 5c0
|
Range: 5c0
|
||||||
WithBuildingBib:
|
WithBuildingBib:
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 1,2
|
Path: 1,2
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: 512,1024,0
|
SpawnOffset: 512,1024,0
|
||||||
ExitCell: 1,2
|
ExitCell: 1,2
|
||||||
@@ -432,7 +432,7 @@ AFLD:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 7c0
|
Range: 7c0
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 4,2
|
Path: 4,2
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: -1024,0,0
|
SpawnOffset: -1024,0,0
|
||||||
ExitCell: 3,1
|
ExitCell: 3,1
|
||||||
@@ -497,7 +497,7 @@ WEAP:
|
|||||||
RequiresCondition: !build-incomplete
|
RequiresCondition: !build-incomplete
|
||||||
Sequence: build-top
|
Sequence: build-top
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 0,2
|
Path: 0,2
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: -512,-512,0
|
SpawnOffset: -512,-512,0
|
||||||
ExitCell: 0,1
|
ExitCell: 0,1
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ BIO:
|
|||||||
ProductionBar:
|
ProductionBar:
|
||||||
ProductionType: Biolab
|
ProductionType: Biolab
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: -1,-1
|
Path: -1,-1
|
||||||
SpawnActorOnDeath:
|
SpawnActorOnDeath:
|
||||||
Actor: BIO.Husk
|
Actor: BIO.Husk
|
||||||
ProvidesPrerequisite@buildingname:
|
ProvidesPrerequisite@buildingname:
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ barracks:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 3c768
|
Range: 3c768
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 1,2
|
Path: 1,2
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: 352,576,0
|
SpawnOffset: 352,576,0
|
||||||
ExitCell: 0,2
|
ExitCell: 0,2
|
||||||
@@ -418,7 +418,7 @@ light_factory:
|
|||||||
Queues: Vehicle
|
Queues: Vehicle
|
||||||
Sequence: production-welding
|
Sequence: production-welding
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 2,2
|
Path: 2,2
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: 544,-224,0
|
SpawnOffset: 544,-224,0
|
||||||
ExitCell: 2,1
|
ExitCell: 2,1
|
||||||
@@ -500,7 +500,7 @@ heavy_factory:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 4c768
|
Range: 4c768
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 0,3
|
Path: 0,3
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: 256,192,0
|
SpawnOffset: 256,192,0
|
||||||
ExitCell: 0,2
|
ExitCell: 0,2
|
||||||
@@ -652,7 +652,7 @@ starport:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 3c768
|
Range: 3c768
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 1,3
|
Path: 1,3
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: 0,-480,0
|
SpawnOffset: 0,-480,0
|
||||||
ExitCell: 2,2
|
ExitCell: 2,2
|
||||||
@@ -907,7 +907,7 @@ repair_pad:
|
|||||||
FinishRepairingNotification: UnitRepaired
|
FinishRepairingNotification: UnitRepaired
|
||||||
PlayerExperience: 15
|
PlayerExperience: 15
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 1,3
|
Path: 1,3
|
||||||
RenderSprites:
|
RenderSprites:
|
||||||
Image: repair_pad.ordos
|
Image: repair_pad.ordos
|
||||||
FactionImages:
|
FactionImages:
|
||||||
|
|||||||
@@ -1814,7 +1814,7 @@ KENN:
|
|||||||
WithBuildingBib:
|
WithBuildingBib:
|
||||||
HasMinibib: True
|
HasMinibib: True
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 0,2
|
Path: 0,2
|
||||||
Exit@0:
|
Exit@0:
|
||||||
RequiresCondition: !being-captured
|
RequiresCondition: !being-captured
|
||||||
SpawnOffset: -280,400,0
|
SpawnOffset: -280,400,0
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ GAPILE:
|
|||||||
Range: 5c0
|
Range: 5c0
|
||||||
MaxHeightDelta: 3
|
MaxHeightDelta: 3
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 2,3
|
Path: 2,3
|
||||||
Palette: mouse
|
Palette: mouse
|
||||||
IsPlayerPalette: false
|
IsPlayerPalette: false
|
||||||
LineWidth: 2
|
LineWidth: 2
|
||||||
@@ -196,7 +196,7 @@ GAWEAP:
|
|||||||
Armor:
|
Armor:
|
||||||
Type: Heavy
|
Type: Heavy
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 4,1
|
Path: 4,1
|
||||||
Palette: mouse
|
Palette: mouse
|
||||||
IsPlayerPalette: false
|
IsPlayerPalette: false
|
||||||
LineWidth: 2
|
LineWidth: 2
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ NAHAND:
|
|||||||
ExitCell: 0,2
|
ExitCell: 0,2
|
||||||
ExitsDebugOverlay:
|
ExitsDebugOverlay:
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 3,3
|
Path: 3,3
|
||||||
Palette: mouse
|
Palette: mouse
|
||||||
IsPlayerPalette: false
|
IsPlayerPalette: false
|
||||||
LineWidth: 2
|
LineWidth: 2
|
||||||
@@ -208,7 +208,7 @@ NAWEAP:
|
|||||||
Range: 4c0
|
Range: 4c0
|
||||||
MaxHeightDelta: 3
|
MaxHeightDelta: 3
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Offset: 4,1
|
Path: 4,1
|
||||||
Palette: mouse
|
Palette: mouse
|
||||||
IsPlayerPalette: false
|
IsPlayerPalette: false
|
||||||
LineWidth: 2
|
LineWidth: 2
|
||||||
|
|||||||
Reference in New Issue
Block a user