Allow queued structure rallypoints.
This commit is contained in:
@@ -229,7 +229,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var rp in world.ActorsWithTrait<RallyPoint>())
|
||||
{
|
||||
if (rp.Actor.Owner == player &&
|
||||
!IsRallyPointValid(rp.Trait.Location, rp.Actor.Info.TraitInfoOrDefault<BuildingInfo>()))
|
||||
!IsRallyPointValid(rp.Trait.Path[0], rp.Actor.Info.TraitInfoOrDefault<BuildingInfo>()))
|
||||
{
|
||||
bot.QueueOrder(new Order("SetRallyPoint", rp.Actor, Target.FromCell(world, ChooseRallyLocationNear(rp.Actor)), false)
|
||||
{
|
||||
|
||||
@@ -48,23 +48,22 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
const string OrderID = "SetRallyPoint";
|
||||
|
||||
[Sync]
|
||||
public CPos Location;
|
||||
public List<CPos> Path;
|
||||
|
||||
public RallyPointInfo Info;
|
||||
public string PaletteName { get; private set; }
|
||||
|
||||
const uint ForceSet = 1;
|
||||
|
||||
public void ResetLocation(Actor self)
|
||||
public void ResetPath(Actor self)
|
||||
{
|
||||
Location = self.Location + Info.Offset;
|
||||
Path = new List<CPos> { self.Location + Info.Offset };
|
||||
}
|
||||
|
||||
public RallyPoint(Actor self, RallyPointInfo info)
|
||||
{
|
||||
Info = info;
|
||||
ResetLocation(self);
|
||||
ResetPath(self);
|
||||
PaletteName = info.IsPlayerPalette ? info.Palette + self.Owner.InternalName : info.Palette;
|
||||
}
|
||||
|
||||
@@ -84,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (Info.IsPlayerPalette)
|
||||
PaletteName = Info.Palette + newOwner.InternalName;
|
||||
|
||||
ResetLocation(self);
|
||||
ResetPath(self);
|
||||
}
|
||||
|
||||
public IEnumerable<IOrderTargeter> Orders
|
||||
@@ -96,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (order.OrderID == OrderID)
|
||||
{
|
||||
return new Order(order.OrderID, self, target, false)
|
||||
return new Order(order.OrderID, self, target, queued)
|
||||
{
|
||||
SuppressVisualFeedback = true,
|
||||
ExtraData = ((RallyPointOrderTargeter)order).ForceSet ? ForceSet : 0
|
||||
@@ -108,8 +107,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == OrderID)
|
||||
Location = self.World.Map.CellContaining(order.Target.CenterPosition);
|
||||
if (order.OrderString != OrderID)
|
||||
return;
|
||||
|
||||
if (!order.Queued)
|
||||
Path.Clear();
|
||||
|
||||
Path.Add(self.World.Map.CellContaining(order.Target.CenterPosition));
|
||||
}
|
||||
|
||||
public static bool IsForceSet(Order order)
|
||||
@@ -130,12 +134,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public int OrderPriority { get { return 0; } }
|
||||
public bool TargetOverridesSelection(Actor self, Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
|
||||
public bool ForceSet { get; private set; }
|
||||
public bool IsQueued { get; protected set; }
|
||||
|
||||
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)
|
||||
{
|
||||
if (target.Type != TargetType.Terrain)
|
||||
return false;
|
||||
|
||||
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
|
||||
|
||||
var location = self.World.Map.CellContaining(target.CenterPosition);
|
||||
if (self.World.Map.Contains(location))
|
||||
{
|
||||
@@ -154,8 +161,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsQueued { get { return false; } } // unused
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (reservedForAircraft.GetActorBelow() == self)
|
||||
{
|
||||
if (rallyPoint != null)
|
||||
reservedFor.QueueActivity(reservedForAircraft.MoveTo(rallyPoint.Location, null, targetLineColor: Color.Green));
|
||||
foreach (var cell in rallyPoint.Path)
|
||||
reservedFor.QueueActivity(reservedForAircraft.MoveTo(cell, 1, targetLineColor: Color.Green));
|
||||
else
|
||||
reservedFor.QueueActivity(new TakeOff(reservedFor));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
@@ -42,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public virtual void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string productionType, TypeDictionary inits)
|
||||
{
|
||||
var exit = CPos.Zero;
|
||||
var exitLocation = CPos.Zero;
|
||||
var exitLocations = new List<CPos>();
|
||||
|
||||
// Clone the initializer dictionary for the new actor
|
||||
var td = new TypeDictionary();
|
||||
@@ -68,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
initialFacing = delta.Yaw.Facing;
|
||||
}
|
||||
|
||||
exitLocation = rp.Value != null ? rp.Value.Location : exit;
|
||||
exitLocations = rp.Value != null ? rp.Value.Path : new List<CPos> { exit };
|
||||
|
||||
td.Add(new LocationInit(exit));
|
||||
td.Add(new CenterPositionInit(spawn));
|
||||
@@ -83,7 +84,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var move = newUnit.TraitOrDefault<IMove>();
|
||||
if (exitinfo != null && move != null)
|
||||
newUnit.QueueActivity(new AttackMoveActivity(newUnit, () => move.MoveTo(exitLocation, 1, targetLineColor: Color.OrangeRed)));
|
||||
foreach (var cell in exitLocations)
|
||||
newUnit.QueueActivity(new AttackMoveActivity(newUnit, () => move.MoveTo(cell, 1, evaluateNearestMovableCell: true, targetLineColor: Color.OrangeRed)));
|
||||
|
||||
if (!self.IsDead)
|
||||
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var aircraftInfo = producee.TraitInfoOrDefault<AircraftInfo>();
|
||||
var mobileInfo = producee.TraitInfoOrDefault<MobileInfo>();
|
||||
|
||||
var destination = rp != null ? rp.Location : self.Location;
|
||||
var destinations = rp != null ? rp.Path : new List<CPos> { self.Location };
|
||||
|
||||
var location = spawnLocation;
|
||||
if (!location.HasValue)
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var locomotorInfo = mobileInfo.LocomotorInfo;
|
||||
location = self.World.Map.ChooseClosestMatchingEdgeCell(self.Location,
|
||||
c => mobileInfo.CanEnterCell(self.World, null, c) && domainIndex.IsPassable(c, destination, locomotorInfo));
|
||||
c => mobileInfo.CanEnterCell(self.World, null, c) && domainIndex.IsPassable(c, destinations[0], locomotorInfo));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (aircraftInfo != null)
|
||||
pos += new WVec(0, 0, aircraftInfo.CruiseAltitude.Length);
|
||||
|
||||
var initialFacing = self.World.Map.FacingBetween(location.Value, destination, 0);
|
||||
var initialFacing = self.World.Map.FacingBetween(location.Value, destinations[0], 0);
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
@@ -91,11 +91,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var move = newUnit.TraitOrDefault<IMove>();
|
||||
if (move != null)
|
||||
newUnit.QueueActivity(move.MoveTo(destination, 2));
|
||||
foreach (var cell in destinations)
|
||||
newUnit.QueueActivity(move.MoveTo(cell, 2, evaluateNearestMovableCell: true));
|
||||
|
||||
if (!self.IsDead)
|
||||
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
||||
t.UnitProduced(self, newUnit, destination);
|
||||
t.UnitProduced(self, newUnit, destinations[0]);
|
||||
|
||||
var notifyOthers = self.World.ActorsWithTrait<INotifyOtherProduction>();
|
||||
foreach (var notify in notifyOthers)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Activities;
|
||||
using OpenRA.Mods.Common.Activities;
|
||||
using OpenRA.Primitives;
|
||||
@@ -102,7 +103,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public override void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string productionType, TypeDictionary inits)
|
||||
{
|
||||
var exit = CPos.Zero;
|
||||
var exitLocation = CPos.Zero;
|
||||
var exitLocations = new List<CPos>();
|
||||
|
||||
var info = (ProductionParadropInfo)Info;
|
||||
var actorType = info.ActorType;
|
||||
@@ -122,7 +123,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var initialFacing = exitinfo.Facing < 0 ? (to - spawn).Yaw.Facing : exitinfo.Facing;
|
||||
|
||||
exitLocation = rp.Value != null ? rp.Value.Location : exit;
|
||||
exitLocations = rp.Value != null ? rp.Value.Path : new List<CPos> { exit };
|
||||
|
||||
td.Add(new LocationInit(exit));
|
||||
td.Add(new CenterPositionInit(spawn));
|
||||
@@ -137,7 +138,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var move = newUnit.TraitOrDefault<IMove>();
|
||||
if (move != null)
|
||||
newUnit.QueueActivity(new AttackMoveActivity(newUnit, () => move.MoveTo(exitLocation, 1, targetLineColor: Color.OrangeRed)));
|
||||
foreach (var cell in exitLocations)
|
||||
newUnit.QueueActivity(new AttackMoveActivity(newUnit, () => move.MoveTo(cell, 1, evaluateNearestMovableCell: true, targetLineColor: Color.OrangeRed)));
|
||||
|
||||
if (!self.IsDead)
|
||||
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
||||
|
||||
Reference in New Issue
Block a user