#1108 changed BuildingInfo.WaterBound to a list of terraintypes. makes it possible to have buildings with custom terrain requirements
This commit is contained in:
@@ -19,7 +19,6 @@ namespace OpenRA.FileFormats
|
||||
public class TerrainTypeInfo
|
||||
{
|
||||
public string Type;
|
||||
public bool Buildable = true;
|
||||
public bool AcceptSmudge = true;
|
||||
public bool IsWater = false;
|
||||
public Color Color;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
public class BuildingInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Power = 0;
|
||||
public readonly bool WaterBound = false;
|
||||
public readonly string[] TerrainTypes = {};
|
||||
public readonly int Adjacent = 2;
|
||||
public readonly string Footprint = "x";
|
||||
public readonly int2 Dimensions = new int2(1, 1);
|
||||
|
||||
@@ -16,20 +16,17 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
{
|
||||
public static class BuildingUtils
|
||||
{
|
||||
public static bool IsCellBuildable(this World world, int2 a, bool waterBound)
|
||||
public static bool IsCellBuildable(this World world, int2 a, BuildingInfo bi)
|
||||
{
|
||||
return world.IsCellBuildable(a, waterBound, null);
|
||||
return world.IsCellBuildable(a, bi, null);
|
||||
}
|
||||
|
||||
public static bool IsCellBuildable(this World world, int2 a, bool waterBound, Actor toIgnore)
|
||||
public static bool IsCellBuildable(this World world, int2 a, BuildingInfo bi, Actor toIgnore)
|
||||
{
|
||||
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(a) != null) return false;
|
||||
if (world.ActorMap.GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
||||
|
||||
if (waterBound)
|
||||
return world.Map.IsInMap(a.X,a.Y) && world.GetTerrainInfo(a).IsWater;
|
||||
|
||||
return world.Map.IsInMap(a.X, a.Y) && world.GetTerrainInfo(a).Buildable;
|
||||
return world.Map.IsInMap(a) && bi.TerrainTypes.Contains(world.GetTerrainType(a));
|
||||
}
|
||||
|
||||
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, int2 topLeft, Actor toIgnore)
|
||||
@@ -37,7 +34,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
var res = world.WorldActor.Trait<ResourceLayer>();
|
||||
return FootprintUtils.Tiles(name, building, topLeft).All(
|
||||
t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null &&
|
||||
world.IsCellBuildable(t, building.WaterBound, toIgnore));
|
||||
world.IsCellBuildable(t, building, toIgnore));
|
||||
}
|
||||
|
||||
public static IEnumerable<int2> GetLineBuildCells(World world, int2 location, string name, BuildingInfo bi)
|
||||
@@ -45,7 +42,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
int range = Rules.Info[name].Traits.Get<LineBuildInfo>().Range;
|
||||
var topLeft = location; // 1x1 assumption!
|
||||
|
||||
if (world.IsCellBuildable(topLeft, bi.WaterBound))
|
||||
if (world.IsCellBuildable(topLeft, bi))
|
||||
yield return topLeft;
|
||||
|
||||
// Start at place location, search outwards
|
||||
@@ -60,7 +57,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
continue;
|
||||
|
||||
int2 cell = topLeft + i * vecs[d];
|
||||
if (world.IsCellBuildable(cell, bi.WaterBound))
|
||||
if (world.IsCellBuildable(cell, bi))
|
||||
continue; // Cell is empty; continue search
|
||||
|
||||
// Cell contains an actor. Is it the type we want?
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace OpenRA.Mods.RA
|
||||
public readonly string Name = "Unnamed Bot";
|
||||
public readonly int SquadSize = 8;
|
||||
public readonly int AssignRolesInterval = 20;
|
||||
public readonly string RallypointTestBuilding = "fact"; // temporary hack to maintain previous rallypoint behavior.
|
||||
|
||||
string IBotInfo.Name { get { return this.Name; } }
|
||||
|
||||
@@ -64,6 +65,7 @@ namespace OpenRA.Mods.RA
|
||||
int ticks;
|
||||
Player p;
|
||||
PowerManager playerPower;
|
||||
readonly BuildingInfo rallypointTestBuilding; // temporary hack
|
||||
|
||||
int2 baseCenter;
|
||||
XRandom random = new XRandom(); //we do not use the synced random number generator.
|
||||
@@ -76,6 +78,8 @@ namespace OpenRA.Mods.RA
|
||||
public HackyAI(HackyAIInfo Info)
|
||||
{
|
||||
this.Info = Info;
|
||||
// temporary hack.
|
||||
this.rallypointTestBuilding = Rules.Info[Info.RallypointTestBuilding].Traits.Get<BuildingInfo>();
|
||||
}
|
||||
|
||||
enum BuildState
|
||||
@@ -342,7 +346,9 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
bool IsRallyPointValid(int2 x)
|
||||
{
|
||||
return world.IsCellBuildable(x, false);
|
||||
// this is actually WRONG as soon as HackyAI is building units with a variety of
|
||||
// movement capabilities. (has always been wrong)
|
||||
return world.IsCellBuildable(x, rallypointTestBuilding);
|
||||
}
|
||||
|
||||
void SetRallyPointsForNewProductionBuildings(Actor self)
|
||||
@@ -366,7 +372,7 @@ namespace OpenRA.Mods.RA
|
||||
//won't work for shipyards...
|
||||
int2 ChooseRallyLocationNear(int2 startPos)
|
||||
{
|
||||
var possibleRallyPoints = world.FindTilesInCircle(startPos, 8).Where(x => world.IsCellBuildable(x, false)).ToArray();
|
||||
var possibleRallyPoints = world.FindTilesInCircle(startPos, 8).Where(IsRallyPointValid).ToArray();
|
||||
if (possibleRallyPoints.Length == 0)
|
||||
{
|
||||
Game.Debug("Bot Bug: No possible rallypoint near {0}", startPos);
|
||||
|
||||
@@ -22,13 +22,14 @@ namespace OpenRA.Mods.RA.Orders
|
||||
readonly Actor Producer;
|
||||
readonly string Building;
|
||||
readonly IEnumerable<Renderable> Preview;
|
||||
BuildingInfo BuildingInfo { get { return Rules.Info[ Building ].Traits.Get<BuildingInfo>(); } }
|
||||
readonly BuildingInfo BuildingInfo;
|
||||
Sprite buildOk, buildBlocked;
|
||||
|
||||
public PlaceBuildingOrderGenerator(Actor producer, string name)
|
||||
{
|
||||
Producer = producer;
|
||||
Building = name;
|
||||
BuildingInfo = Rules.Info[Building].Traits.Get<BuildingInfo>();
|
||||
|
||||
Preview = Rules.Info[Building].Traits.Get<RenderBuildingInfo>()
|
||||
.RenderPreview(Rules.Info[Building], producer.Owner);
|
||||
@@ -97,7 +98,7 @@ namespace OpenRA.Mods.RA.Orders
|
||||
var res = world.WorldActor.Trait<ResourceLayer>();
|
||||
var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft);
|
||||
foreach (var t in FootprintUtils.Tiles(Building, BuildingInfo, topLeft))
|
||||
cells.Add( t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo.WaterBound) && res.GetResource(t) == null );
|
||||
cells.Add( t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo) && res.GetResource(t) == null );
|
||||
}
|
||||
|
||||
foreach( var c in cells )
|
||||
|
||||
@@ -147,7 +147,6 @@ namespace OpenRA.TilesetBuilder
|
||||
var terraintype = new TerrainTypeInfo()
|
||||
{
|
||||
Type = "Clear",
|
||||
Buildable = true,
|
||||
AcceptSmudge = true,
|
||||
IsWater = false,
|
||||
Color = Color.White
|
||||
|
||||
@@ -207,6 +207,7 @@
|
||||
Footprint: x
|
||||
BuildSounds: constru2.aud, hvydoor1.aud
|
||||
SellSounds: cashturn.aud
|
||||
TerrainTypes: Clear,Road
|
||||
SoundOnDamageTransition:
|
||||
DamagedSound: xplos.aud
|
||||
DestroyedSound: xplobig4.aud
|
||||
@@ -295,6 +296,7 @@
|
||||
Footprint: x
|
||||
BuildSounds: hvydoor1.aud
|
||||
Adjacent: 7
|
||||
TerrainTypes: Clear,Road
|
||||
TargetableBuilding:
|
||||
TargetTypes: Ground
|
||||
Wall:
|
||||
|
||||
@@ -7,58 +7,47 @@ General:
|
||||
Terrain:
|
||||
TerrainType@Clear:
|
||||
Type: Clear
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 134, 95, 69
|
||||
TerrainType@Water:
|
||||
Type: Water
|
||||
IsWater: true
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 93, 165, 206
|
||||
TerrainType@Road:
|
||||
Type: Road
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 168, 123, 83
|
||||
TerrainType@Rock:
|
||||
Type: Rock
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 116, 90, 63
|
||||
TerrainType@Tree:
|
||||
Type: Tree
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 28, 32, 36
|
||||
TerrainType@River:
|
||||
Type: River
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 111, 132, 139
|
||||
TerrainType@Rough:
|
||||
Type: Rough
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Wall:
|
||||
Type: Wall
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 208, 192, 160
|
||||
TerrainType@Beach:
|
||||
Type: Beach
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 176, 156, 120
|
||||
TerrainType@Tiberium:
|
||||
Type: Tiberium
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 161, 226, 28
|
||||
TerrainType@BlueTiberium:
|
||||
Type: BlueTiberium
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 84, 252, 252
|
||||
|
||||
|
||||
@@ -7,58 +7,47 @@ General:
|
||||
Terrain:
|
||||
TerrainType@Clear:
|
||||
Type: Clear
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 40, 68, 40
|
||||
TerrainType@Water:
|
||||
Type: Water
|
||||
IsWater: true
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 92, 116, 164
|
||||
TerrainType@Road:
|
||||
Type: Road
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 88, 116, 116
|
||||
TerrainType@Rock:
|
||||
Type: Rock
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Tree:
|
||||
Type: Tree
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 28, 32, 36
|
||||
TerrainType@River:
|
||||
Type: River
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 92, 140, 180
|
||||
TerrainType@Rough:
|
||||
Type: Rough
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Wall:
|
||||
Type: Wall
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 208, 192, 160
|
||||
TerrainType@Beach:
|
||||
Type: Beach
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 176, 156, 120
|
||||
TerrainType@Tiberium:
|
||||
Type: Tiberium
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 161, 226, 28
|
||||
TerrainType@BlueTiberium:
|
||||
Type: BlueTiberium
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 84, 252, 252
|
||||
|
||||
|
||||
@@ -7,58 +7,47 @@ General:
|
||||
Terrain:
|
||||
TerrainType@Clear:
|
||||
Type: Clear
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 40, 68, 40
|
||||
TerrainType@Water:
|
||||
Type: Water
|
||||
IsWater: true
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 92, 116, 164
|
||||
TerrainType@Road:
|
||||
Type: Road
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 88, 116, 116
|
||||
TerrainType@Rock:
|
||||
Type: Rock
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Tree:
|
||||
Type: Tree
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 28, 32, 36
|
||||
TerrainType@River:
|
||||
Type: River
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 92, 140, 180
|
||||
TerrainType@Rough:
|
||||
Type: Rough
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Wall:
|
||||
Type: Wall
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 208, 192, 160
|
||||
TerrainType@Beach:
|
||||
Type: Beach
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 176, 156, 120
|
||||
TerrainType@Tiberium:
|
||||
Type: Tiberium
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 161, 226, 28
|
||||
TerrainType@BlueTiberium:
|
||||
Type: BlueTiberium
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 84, 252, 252
|
||||
|
||||
|
||||
@@ -174,6 +174,7 @@
|
||||
Building:
|
||||
Dimensions: 1,1
|
||||
Footprint: x
|
||||
TerrainTypes: Clear,Road
|
||||
GivesBuildableArea:
|
||||
Capturable:
|
||||
SoundOnDamageTransition:
|
||||
@@ -205,6 +206,7 @@
|
||||
Footprint: x
|
||||
BuildSounds: placbldg.aud
|
||||
Adjacent: 7
|
||||
TerrainTypes: Clear,Road
|
||||
SoundOnDamageTransition:
|
||||
DamagedSound: sandbag2.aud
|
||||
DestroyedSound: sandbag2.aud
|
||||
|
||||
@@ -85,7 +85,7 @@ SPEN:
|
||||
Footprint: xxx xxx xxx
|
||||
Dimensions: 3,3
|
||||
Adjacent: 8
|
||||
WaterBound: yes
|
||||
TerrainTypes: Water
|
||||
-GivesBuildableArea:
|
||||
Health:
|
||||
HP: 1000
|
||||
@@ -140,7 +140,7 @@ SYRD:
|
||||
Footprint: xxx xxx xxx
|
||||
Dimensions: 3,3
|
||||
Adjacent: 8
|
||||
WaterBound: yes
|
||||
TerrainTypes: Water
|
||||
-GivesBuildableArea:
|
||||
Health:
|
||||
HP: 1000
|
||||
@@ -1046,7 +1046,7 @@ SYRF:
|
||||
Footprint: xxx xxx xxx
|
||||
Dimensions: 3,3
|
||||
Adjacent: 8
|
||||
WaterBound: yes
|
||||
TerrainTypes: Water
|
||||
-GivesBuildableArea:
|
||||
Health:
|
||||
HP: 30
|
||||
@@ -1066,7 +1066,7 @@ SPEF:
|
||||
Footprint: xxx xxx xxx
|
||||
Dimensions: 3,3
|
||||
Adjacent: 8
|
||||
WaterBound: yes
|
||||
TerrainTypes: Water
|
||||
-GivesBuildableArea:
|
||||
Health:
|
||||
HP: 30
|
||||
|
||||
@@ -7,53 +7,43 @@ General:
|
||||
Terrain:
|
||||
TerrainType@Clear:
|
||||
Type: Clear
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 40, 68, 40
|
||||
TerrainType@Water:
|
||||
Type: Water
|
||||
IsWater: true
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 92, 116, 164
|
||||
TerrainType@Road:
|
||||
Type: Road
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 88, 116, 116
|
||||
TerrainType@Rock:
|
||||
Type: Rock
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Tree:
|
||||
Type: Tree
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 28, 32, 36
|
||||
TerrainType@River:
|
||||
Type: River
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 92, 140, 180
|
||||
TerrainType@Rough:
|
||||
Type: Rough
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Wall:
|
||||
Type: Wall
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 208, 192, 160
|
||||
TerrainType@Beach:
|
||||
Type: Beach
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 176, 156, 120
|
||||
TerrainType@Ore:
|
||||
Type: Ore
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 148, 128, 96
|
||||
|
||||
|
||||
@@ -7,53 +7,43 @@ General:
|
||||
Terrain:
|
||||
TerrainType@Clear:
|
||||
Type: Clear
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 196, 196, 196
|
||||
TerrainType@Water:
|
||||
Type: Water
|
||||
IsWater: true
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 92, 116, 164
|
||||
TerrainType@Road:
|
||||
Type: Road
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 88, 116, 116
|
||||
TerrainType@Rock:
|
||||
Type: Rock
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Tree:
|
||||
Type: Tree
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 28, 32, 36
|
||||
TerrainType@River:
|
||||
Type: River
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 92, 140, 180
|
||||
TerrainType@Rough:
|
||||
Type: Rough
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Wall:
|
||||
Type: Wall
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 208, 192, 160
|
||||
TerrainType@Beach:
|
||||
Type: Beach
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 176, 156, 120
|
||||
TerrainType@Ore:
|
||||
Type: Ore
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 148, 128, 96
|
||||
|
||||
|
||||
@@ -7,53 +7,43 @@ General:
|
||||
Terrain:
|
||||
TerrainType@Clear:
|
||||
Type: Clear
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 40, 68, 40
|
||||
TerrainType@Water:
|
||||
Type: Water
|
||||
IsWater: true
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 92, 116, 164
|
||||
TerrainType@Road:
|
||||
Type: Road
|
||||
Buildable: True
|
||||
AcceptSmudge: True
|
||||
Color: 88, 116, 116
|
||||
TerrainType@Rock:
|
||||
Type: Rock
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Tree:
|
||||
Type: Tree
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 28, 32, 36
|
||||
TerrainType@River:
|
||||
Type: River
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 92, 140, 180
|
||||
TerrainType@Rough:
|
||||
Type: Rough
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 68, 68, 60
|
||||
TerrainType@Wall:
|
||||
Type: Wall
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 208, 192, 160
|
||||
TerrainType@Beach:
|
||||
Type: Beach
|
||||
Buildable: False
|
||||
AcceptSmudge: False
|
||||
Color: 176, 156, 120
|
||||
TerrainType@Ore:
|
||||
Type: Ore
|
||||
Buildable: False
|
||||
AcceptSmudge: True
|
||||
Color: 148, 128, 96
|
||||
|
||||
|
||||
Reference in New Issue
Block a user