#250 resources should have a list of allowed terrain types
This commit is contained in:
@@ -58,14 +58,17 @@ namespace OpenRA.Traits
|
||||
for (int x = map.Bounds.Left; x < map.Bounds.Right; x++)
|
||||
for (int y = map.Bounds.Top; y < map.Bounds.Bottom; y++)
|
||||
{
|
||||
// Todo: Valid terrain should be specified in the resource
|
||||
if (!AllowResourceAt(new int2(x,y)))
|
||||
var type = resourceTypes.FirstOrDefault(
|
||||
r => r.info.ResourceType == w.Map.MapResources[x, y].type);
|
||||
|
||||
if (type == null)
|
||||
continue;
|
||||
|
||||
content[x, y].type = resourceTypes.FirstOrDefault(
|
||||
r => r.info.ResourceType == w.Map.MapResources[x, y].type);
|
||||
if (content[x, y].type != null)
|
||||
content[x, y].image = ChooseContent(content[x, y].type);
|
||||
if (!AllowResourceAt(type, new int2(x,y)))
|
||||
continue;
|
||||
|
||||
content[x, y].type = type;
|
||||
content[x, y].image = ChooseContent(type);
|
||||
}
|
||||
|
||||
for (int x = map.Bounds.Left; x < map.Bounds.Right; x++)
|
||||
@@ -77,11 +80,11 @@ namespace OpenRA.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public bool AllowResourceAt( int2 a )
|
||||
public bool AllowResourceAt(ResourceType rt, int2 a)
|
||||
{
|
||||
if (!world.Map.IsInMap(a.X, a.Y)) return false;
|
||||
if( !world.GetTerrainInfo( a ).Buildable ) return false;
|
||||
if( world.WorldActor.Trait<UnitInfluence>().AnyUnitsAt( a ) ) return false;
|
||||
if (!rt.info.AllowedTerrainTypes.Contains(world.GetTerrainInfo(a).Type)) return false;
|
||||
if (!rt.info.AllowUnderActors && world.WorldActor.Trait<UnitInfluence>().AnyUnitsAt(a)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace OpenRA.Traits
|
||||
public readonly string Name = null;
|
||||
public readonly string TerrainType = "Ore";
|
||||
|
||||
public readonly string[] AllowedTerrainTypes = { };
|
||||
public readonly bool AllowUnderActors = false;
|
||||
|
||||
public Sprite[][] Sprites;
|
||||
public int PaletteIndex;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA
|
||||
// Todo: Valid terrain should be specified in the resource
|
||||
if (cell != null && self.World.Map.IsInMap(cell.Value) &&
|
||||
(resLayer.GetResource(cell.Value) == resourceType
|
||||
|| (resLayer.GetResource(cell.Value) == null && resLayer.AllowResourceAt(cell.Value))))
|
||||
|| (resLayer.GetResource(cell.Value) == null && resLayer.AllowResourceAt(resourceType, cell.Value))))
|
||||
resLayer.AddResource(resourceType, cell.Value.X, cell.Value.Y, 1);
|
||||
|
||||
ticks = info.Interval;
|
||||
|
||||
@@ -111,6 +111,8 @@ World:
|
||||
ValuePerUnit: 30
|
||||
Name: Tiberium
|
||||
PipColor: Green
|
||||
AllowedTerrainTypes: Clear,Road
|
||||
AllowUnderActors: false
|
||||
ResourceType@blue-tib:
|
||||
ResourceType: 2
|
||||
Palette: terrain
|
||||
@@ -120,6 +122,8 @@ World:
|
||||
Name: Blue Tiberium
|
||||
# todo: add a blue pip.
|
||||
PipColor: Red
|
||||
AllowedTerrainTypes: Clear,Road
|
||||
AllowUnderActors: false
|
||||
SmudgeLayer@SCORCH:
|
||||
Type:Scorch
|
||||
Types:sc1,sc2,sc3,sc4,sc5,sc6
|
||||
|
||||
@@ -160,6 +160,8 @@ World:
|
||||
ValuePerUnit: 25
|
||||
Name: Ore
|
||||
PipColor: Yellow
|
||||
AllowedTerrainTypes: Clear,Road
|
||||
AllowUnderActors: false
|
||||
ResourceType@gem:
|
||||
ResourceType: 2
|
||||
Palette: terrain
|
||||
@@ -167,6 +169,8 @@ World:
|
||||
ValuePerUnit: 50
|
||||
Name: Gems
|
||||
PipColor: Red
|
||||
AllowedTerrainTypes: Clear,Road
|
||||
AllowUnderActors: false
|
||||
SmudgeLayer@SCORCH:
|
||||
Type:Scorch
|
||||
Types:sc1,sc2,sc3,sc4,sc5,sc6
|
||||
|
||||
Reference in New Issue
Block a user