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
This commit is contained in:
Forcecore
2017-06-16 20:27:49 -05:00
committed by Oliver Brakmann
parent f98e7656da
commit 728162e688

View File

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