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