Added flag to Mobile/AircraftInfo: MoveIntoShroud.

Does not change the audio feedback given.
This commit is contained in:
Taryn Hill
2014-07-21 18:00:11 -05:00
parent f84b1c145e
commit d6931f1d05
4 changed files with 58 additions and 15 deletions

View File

@@ -37,6 +37,9 @@ namespace OpenRA.Mods.RA.Air
public readonly int Speed = 1; public readonly int Speed = 1;
public readonly string[] LandableTerrainTypes = { }; public readonly string[] LandableTerrainTypes = { };
[Desc("Can the actor be ordered to move in to shroud?")]
public readonly bool MoveIntoShroud = true;
public virtual object Create(ActorInitializer init) { return new Aircraft(init, this); } public virtual object Create(ActorInitializer init) { return new Aircraft(init, this); }
public int GetInitialFacing() { return InitialFacing; } public int GetInitialFacing() { return InitialFacing; }
} }
@@ -248,7 +251,7 @@ namespace OpenRA.Mods.RA.Air
yield return new EnterAlliedActorTargeter<Building>("Enter", 5, yield return new EnterAlliedActorTargeter<Building>("Enter", 5,
target => AircraftCanEnter(target), target => !Reservable.IsReserved(target)); target => AircraftCanEnter(target), target => !Reservable.IsReserved(target));
yield return new AircraftMoveOrderTargeter(); yield return new AircraftMoveOrderTargeter(info);
} }
} }
@@ -297,13 +300,26 @@ namespace OpenRA.Mods.RA.Air
public string OrderID { get { return "Move"; } } public string OrderID { get { return "Move"; } }
public int OrderPriority { get { return 4; } } public int OrderPriority { get { return 4; } }
readonly AircraftInfo info;
public AircraftMoveOrderTargeter(AircraftInfo info) { this.info = info; }
public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor) public bool CanTarget(Actor self, Target target, List<Actor> othersAtTarget, TargetModifiers modifiers, ref string cursor)
{ {
if (target.Type != TargetType.Terrain) if (target.Type != TargetType.Terrain)
return false; return false;
var location = self.World.Map.CellContaining(target.CenterPosition);
var explored = self.Owner.Shroud.IsExplored(location);
cursor = self.World.Map.Contains(location) ?
(self.World.Map.GetTerrainInfo(location).CustomCursor ?? "move") :
"move-blocked";
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
cursor = self.World.Map.Contains(self.World.Map.CellContaining(target.CenterPosition)) ? "move" : "move-blocked";
if (!explored && !info.MoveIntoShroud)
cursor = "move-blocked";
return true; return true;
} }

11
OpenRA.Mods.RA/Air/Helicopter.cs Executable file → Normal file
View File

@@ -56,11 +56,16 @@ namespace OpenRA.Mods.RA.Air
if (order.OrderString == "Move") if (order.OrderString == "Move")
{ {
var cell = self.World.Map.Clamp(order.TargetLocation); var cell = self.World.Map.Clamp(order.TargetLocation);
var t = Target.FromCell(self.World, cell); var explored = self.Owner.Shroud.IsExplored(cell);
self.SetTargetLine(t, Color.Green); if (!explored && !Info.MoveIntoShroud)
return;
var target = Target.FromCell(self.World, cell);
self.SetTargetLine(target, Color.Green);
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new HeliFly(self, t)); self.QueueActivity(new HeliFly(self, target));
if (Info.LandWhenIdle) if (Info.LandWhenIdle)
{ {

13
OpenRA.Mods.RA/Air/Plane.cs Executable file → Normal file
View File

@@ -71,13 +71,18 @@ namespace OpenRA.Mods.RA.Air
{ {
if (order.OrderString == "Move") if (order.OrderString == "Move")
{ {
var cell = self.World.Map.Clamp(order.TargetLocation);
var explored = self.Owner.Shroud.IsExplored(cell);
if (!explored && !Info.MoveIntoShroud)
return;
UnReserve(); UnReserve();
var cell = self.World.Map.Clamp(order.TargetLocation); var target = Target.FromCell(self.World, cell);
var t = Target.FromCell(self.World, cell); self.SetTargetLine(target, Color.Green);
self.SetTargetLine(t, Color.Green);
self.CancelActivity(); self.CancelActivity();
self.QueueActivity(new Fly(self, t)); self.QueueActivity(new Fly(self, target));
self.QueueActivity(new FlyCircle()); self.QueueActivity(new FlyCircle());
} }
else if (order.OrderString == "Enter") else if (order.OrderString == "Enter")

View File

@@ -24,18 +24,29 @@ namespace OpenRA.Mods.RA.Move
[FieldLoader.LoadUsing("LoadSpeeds")] [FieldLoader.LoadUsing("LoadSpeeds")]
[Desc("Set Water: 0 for ground units and lower the value on rough terrain.")] [Desc("Set Water: 0 for ground units and lower the value on rough terrain.")]
public readonly Dictionary<string, TerrainInfo> TerrainSpeeds; public readonly Dictionary<string, TerrainInfo> TerrainSpeeds;
[Desc("e.g. crate, wall, infantry")] [Desc("e.g. crate, wall, infantry")]
public readonly string[] Crushes; public readonly string[] Crushes = { };
public readonly int WaitAverage = 5; public readonly int WaitAverage = 5;
public readonly int WaitSpread = 2; public readonly int WaitSpread = 2;
public readonly int InitialFacing = 128; public readonly int InitialFacing = 128;
[Desc("Rate of Turning")] [Desc("Rate of Turning")]
public readonly int ROT = 255; public readonly int ROT = 255;
public readonly int Speed = 1; public readonly int Speed = 1;
public readonly bool OnRails = false; public readonly bool OnRails = false;
[Desc("Allow multiple (infantry) units in one cell.")] [Desc("Allow multiple (infantry) units in one cell.")]
public readonly bool SharesCell = false; public readonly bool SharesCell = false;
[Desc("Can the actor be ordered to move in to shroud?")]
public readonly bool MoveIntoShroud = true;
public virtual object Create(ActorInitializer init) { return new Mobile(init, this); } public virtual object Create(ActorInitializer init) { return new Mobile(init, this); }
static object LoadSpeeds(MiniYaml y) static object LoadSpeeds(MiniYaml y)
@@ -373,8 +384,13 @@ namespace OpenRA.Mods.RA.Move
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "Move") if (order.OrderString == "Move")
{
if (!Info.MoveIntoShroud && !self.Owner.Shroud.IsExplored(order.TargetLocation))
return;
PerformMove(self, self.World.Map.Clamp(order.TargetLocation), PerformMove(self, self.World.Map.Clamp(order.TargetLocation),
order.Queued && !self.IsIdle); order.Queued && !self.IsIdle);
}
if (order.OrderString == "Stop") if (order.OrderString == "Stop")
self.CancelActivity(); self.CancelActivity();
@@ -559,13 +575,14 @@ namespace OpenRA.Mods.RA.Move
var location = self.World.Map.CellContaining(target.CenterPosition); var location = self.World.Map.CellContaining(target.CenterPosition);
IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue);
cursor = "move";
if (self.Owner.Shroud.IsExplored(location)) var explored = self.Owner.Shroud.IsExplored(location);
cursor = self.World.Map.GetTerrainInfo(location).CustomCursor ?? cursor; cursor = self.World.Map.Contains(location) ?
(self.World.Map.GetTerrainInfo(location).CustomCursor ?? "move") :
"move-blocked";
if (!self.World.Map.Contains(location) || (self.Owner.Shroud.IsExplored(location) && if ((!explored && !unitType.MoveIntoShroud) ||
unitType.MovementCostForCell(self.World, location) == int.MaxValue)) (explored && unitType.MovementCostForCell(self.World, location) == int.MaxValue))
cursor = "move-blocked"; cursor = "move-blocked";
return true; return true;