From d6931f1d059ca56da5aede233438944b6a2d59c8 Mon Sep 17 00:00:00 2001 From: Taryn Hill Date: Mon, 21 Jul 2014 18:00:11 -0500 Subject: [PATCH] Added flag to Mobile/AircraftInfo: MoveIntoShroud. Does not change the audio feedback given. --- OpenRA.Mods.RA/Air/Aircraft.cs | 20 ++++++++++++++++++-- OpenRA.Mods.RA/Air/Helicopter.cs | 11 ++++++++--- OpenRA.Mods.RA/Air/Plane.cs | 13 +++++++++---- OpenRA.Mods.RA/Move/Mobile.cs | 29 +++++++++++++++++++++++------ 4 files changed, 58 insertions(+), 15 deletions(-) mode change 100755 => 100644 OpenRA.Mods.RA/Air/Helicopter.cs mode change 100755 => 100644 OpenRA.Mods.RA/Air/Plane.cs diff --git a/OpenRA.Mods.RA/Air/Aircraft.cs b/OpenRA.Mods.RA/Air/Aircraft.cs index 6b5872ce09..ac8273845a 100644 --- a/OpenRA.Mods.RA/Air/Aircraft.cs +++ b/OpenRA.Mods.RA/Air/Aircraft.cs @@ -37,6 +37,9 @@ namespace OpenRA.Mods.RA.Air public readonly int Speed = 1; 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 int GetInitialFacing() { return InitialFacing; } } @@ -248,7 +251,7 @@ namespace OpenRA.Mods.RA.Air yield return new EnterAlliedActorTargeter("Enter", 5, 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 int OrderPriority { get { return 4; } } + readonly AircraftInfo info; + + public AircraftMoveOrderTargeter(AircraftInfo info) { this.info = info; } + public bool CanTarget(Actor self, Target target, List othersAtTarget, TargetModifiers modifiers, ref string cursor) { if (target.Type != TargetType.Terrain) 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); - cursor = self.World.Map.Contains(self.World.Map.CellContaining(target.CenterPosition)) ? "move" : "move-blocked"; + + if (!explored && !info.MoveIntoShroud) + cursor = "move-blocked"; + return true; } diff --git a/OpenRA.Mods.RA/Air/Helicopter.cs b/OpenRA.Mods.RA/Air/Helicopter.cs old mode 100755 new mode 100644 index 8ee4f10f93..6449f1440d --- a/OpenRA.Mods.RA/Air/Helicopter.cs +++ b/OpenRA.Mods.RA/Air/Helicopter.cs @@ -56,11 +56,16 @@ namespace OpenRA.Mods.RA.Air if (order.OrderString == "Move") { 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.QueueActivity(new HeliFly(self, t)); + self.QueueActivity(new HeliFly(self, target)); if (Info.LandWhenIdle) { diff --git a/OpenRA.Mods.RA/Air/Plane.cs b/OpenRA.Mods.RA/Air/Plane.cs old mode 100755 new mode 100644 index 52a607ec1c..9e301462c0 --- a/OpenRA.Mods.RA/Air/Plane.cs +++ b/OpenRA.Mods.RA/Air/Plane.cs @@ -71,13 +71,18 @@ namespace OpenRA.Mods.RA.Air { 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(); - var cell = self.World.Map.Clamp(order.TargetLocation); - var t = Target.FromCell(self.World, cell); - self.SetTargetLine(t, Color.Green); + var target = Target.FromCell(self.World, cell); + self.SetTargetLine(target, Color.Green); self.CancelActivity(); - self.QueueActivity(new Fly(self, t)); + self.QueueActivity(new Fly(self, target)); self.QueueActivity(new FlyCircle()); } else if (order.OrderString == "Enter") diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index 55c2307a96..9050e7fe6f 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -24,18 +24,29 @@ namespace OpenRA.Mods.RA.Move [FieldLoader.LoadUsing("LoadSpeeds")] [Desc("Set Water: 0 for ground units and lower the value on rough terrain.")] public readonly Dictionary TerrainSpeeds; + [Desc("e.g. crate, wall, infantry")] - public readonly string[] Crushes; + public readonly string[] Crushes = { }; + public readonly int WaitAverage = 5; + public readonly int WaitSpread = 2; + public readonly int InitialFacing = 128; + [Desc("Rate of Turning")] public readonly int ROT = 255; + public readonly int Speed = 1; + public readonly bool OnRails = false; + [Desc("Allow multiple (infantry) units in one cell.")] 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); } static object LoadSpeeds(MiniYaml y) @@ -373,8 +384,13 @@ namespace OpenRA.Mods.RA.Move public void ResolveOrder(Actor self, Order order) { if (order.OrderString == "Move") + { + if (!Info.MoveIntoShroud && !self.Owner.Shroud.IsExplored(order.TargetLocation)) + return; + PerformMove(self, self.World.Map.Clamp(order.TargetLocation), order.Queued && !self.IsIdle); + } if (order.OrderString == "Stop") self.CancelActivity(); @@ -559,13 +575,14 @@ namespace OpenRA.Mods.RA.Move var location = self.World.Map.CellContaining(target.CenterPosition); IsQueued = modifiers.HasModifier(TargetModifiers.ForceQueue); - cursor = "move"; - if (self.Owner.Shroud.IsExplored(location)) - cursor = self.World.Map.GetTerrainInfo(location).CustomCursor ?? cursor; + var explored = self.Owner.Shroud.IsExplored(location); + 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) && - unitType.MovementCostForCell(self.World, location) == int.MaxValue)) + if ((!explored && !unitType.MoveIntoShroud) || + (explored && unitType.MovementCostForCell(self.World, location) == int.MaxValue)) cursor = "move-blocked"; return true;