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))