From 728162e68895d1c935ee2de65a26398d9ad76791 Mon Sep 17 00:00:00 2001 From: Forcecore Date: Fri, 16 Jun 2017 20:27:49 -0500 Subject: [PATCH] GCOnDeploy's ValidTerrain() takes location parameter Fixes ##13394. Possible use: AI's future deploy planning when the actor isn't actually there yet. Also used in my mod for Slave Miner's deploy planning --- .../Conditions/GrantConditionOnDeploy.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs index e322ac9775..a95b3898d2 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnDeploy.cs @@ -157,36 +157,36 @@ namespace OpenRA.Mods.Common.Traits bool IsCursorBlocked() { - return ((deployState == DeployState.Deployed) && !info.CanUndeploy) || (!IsOnValidTerrain() && (deployState != DeployState.Deployed)); + return ((deployState == DeployState.Deployed) && !info.CanUndeploy) || (!IsValidTerrain(self.Location) && (deployState != DeployState.Deployed)); } - bool IsOnValidTerrain() + public bool IsValidTerrain(CPos location) { - return IsOnValidTerrainType() && IsOnValidRampType(); + return IsValidTerrainType(location) && IsValidRampType(location); } - bool IsOnValidTerrainType() + bool IsValidTerrainType(CPos location) { - if (!self.World.Map.Contains(self.Location)) + if (!self.World.Map.Contains(location)) return false; if (!checkTerrainType) return true; - var terrainType = self.World.Map.GetTerrainInfo(self.Location).Type; + var terrainType = self.World.Map.GetTerrainInfo(location).Type; return info.AllowedTerrainTypes.Contains(terrainType); } - bool IsOnValidRampType() + bool IsValidRampType(CPos location) { if (info.CanDeployOnRamps) return true; var ramp = 0; - if (self.World.Map.Contains(self.Location)) + if (self.World.Map.Contains(location)) { - var tile = self.World.Map.Tiles[self.Location]; + var tile = self.World.Map.Tiles[location]; var ti = self.World.Map.Rules.TileSet.GetTileInfo(tile); if (ti != null) ramp = ti.RampType; @@ -213,7 +213,7 @@ namespace OpenRA.Mods.Common.Traits if (!init && deployState != DeployState.Undeployed) return; - if (!IsOnValidTerrain()) + if (!IsValidTerrain(self.Location)) return; if (!string.IsNullOrEmpty(info.DeploySound))