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:
committed by
Oliver Brakmann
parent
f98e7656da
commit
728162e688
@@ -157,36 +157,36 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
bool IsCursorBlocked()
|
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;
|
return false;
|
||||||
|
|
||||||
if (!checkTerrainType)
|
if (!checkTerrainType)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var terrainType = self.World.Map.GetTerrainInfo(self.Location).Type;
|
var terrainType = self.World.Map.GetTerrainInfo(location).Type;
|
||||||
|
|
||||||
return info.AllowedTerrainTypes.Contains(terrainType);
|
return info.AllowedTerrainTypes.Contains(terrainType);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsOnValidRampType()
|
bool IsValidRampType(CPos location)
|
||||||
{
|
{
|
||||||
if (info.CanDeployOnRamps)
|
if (info.CanDeployOnRamps)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
var ramp = 0;
|
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);
|
var ti = self.World.Map.Rules.TileSet.GetTileInfo(tile);
|
||||||
if (ti != null)
|
if (ti != null)
|
||||||
ramp = ti.RampType;
|
ramp = ti.RampType;
|
||||||
@@ -213,7 +213,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!init && deployState != DeployState.Undeployed)
|
if (!init && deployState != DeployState.Undeployed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!IsOnValidTerrain())
|
if (!IsValidTerrain(self.Location))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(info.DeploySound))
|
if (!string.IsNullOrEmpty(info.DeploySound))
|
||||||
|
|||||||
Reference in New Issue
Block a user