diff --git a/OpenRA.FileFormats/Map/TileSet.cs b/OpenRA.FileFormats/Map/TileSet.cs index 59ad5bc27e..78f6e76c0a 100644 --- a/OpenRA.FileFormats/Map/TileSet.cs +++ b/OpenRA.FileFormats/Map/TileSet.cs @@ -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; diff --git a/OpenRA.Mods.RA/Buildings/Building.cs b/OpenRA.Mods.RA/Buildings/Building.cs index e23949608e..65a4283758 100755 --- a/OpenRA.Mods.RA/Buildings/Building.cs +++ b/OpenRA.Mods.RA/Buildings/Building.cs @@ -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); diff --git a/OpenRA.Mods.RA/Buildings/Util.cs b/OpenRA.Mods.RA/Buildings/Util.cs index 4ec4863c7c..c8c743bdfd 100755 --- a/OpenRA.Mods.RA/Buildings/Util.cs +++ b/OpenRA.Mods.RA/Buildings/Util.cs @@ -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().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(); 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 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().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? diff --git a/OpenRA.Mods.RA/HackyAI.cs b/OpenRA.Mods.RA/HackyAI.cs index 28b3fd129f..69fa6fd3e2 100644 --- a/OpenRA.Mods.RA/HackyAI.cs +++ b/OpenRA.Mods.RA/HackyAI.cs @@ -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(); } 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); diff --git a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs index 7c88fb9197..cab8c6b98c 100755 --- a/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/PlaceBuildingOrderGenerator.cs @@ -22,13 +22,14 @@ namespace OpenRA.Mods.RA.Orders readonly Actor Producer; readonly string Building; readonly IEnumerable Preview; - BuildingInfo BuildingInfo { get { return Rules.Info[ Building ].Traits.Get(); } } + readonly BuildingInfo BuildingInfo; Sprite buildOk, buildBlocked; public PlaceBuildingOrderGenerator(Actor producer, string name) { Producer = producer; Building = name; + BuildingInfo = Rules.Info[Building].Traits.Get(); Preview = Rules.Info[Building].Traits.Get() .RenderPreview(Rules.Info[Building], producer.Owner); @@ -97,7 +98,7 @@ namespace OpenRA.Mods.RA.Orders var res = world.WorldActor.Trait(); 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 ) diff --git a/OpenRA.TilesetBuilder/Form1.cs b/OpenRA.TilesetBuilder/Form1.cs index cd78cfc50a..dd2d26bdeb 100644 --- a/OpenRA.TilesetBuilder/Form1.cs +++ b/OpenRA.TilesetBuilder/Form1.cs @@ -147,7 +147,6 @@ namespace OpenRA.TilesetBuilder var terraintype = new TerrainTypeInfo() { Type = "Clear", - Buildable = true, AcceptSmudge = true, IsWater = false, Color = Color.White diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 0955613383..590a3a35b4 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -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: diff --git a/mods/cnc/tilesets/desert.yaml b/mods/cnc/tilesets/desert.yaml index 4f1f11efef..b8314c4b3b 100644 --- a/mods/cnc/tilesets/desert.yaml +++ b/mods/cnc/tilesets/desert.yaml @@ -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 diff --git a/mods/cnc/tilesets/temperat.yaml b/mods/cnc/tilesets/temperat.yaml index 627eb6f53c..d38917bdc3 100644 --- a/mods/cnc/tilesets/temperat.yaml +++ b/mods/cnc/tilesets/temperat.yaml @@ -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 diff --git a/mods/cnc/tilesets/winter.yaml b/mods/cnc/tilesets/winter.yaml index c6f6b3422e..233e65d54c 100644 --- a/mods/cnc/tilesets/winter.yaml +++ b/mods/cnc/tilesets/winter.yaml @@ -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 diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 7d150a7f5e..df82fc9974 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -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 diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index f38ae85620..697d3ccb36 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -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 diff --git a/mods/ra/tilesets/interior.yaml b/mods/ra/tilesets/interior.yaml index 1952a4abfe..26f2c22f77 100644 --- a/mods/ra/tilesets/interior.yaml +++ b/mods/ra/tilesets/interior.yaml @@ -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 diff --git a/mods/ra/tilesets/snow.yaml b/mods/ra/tilesets/snow.yaml index 23f582313c..f5ab82e895 100644 --- a/mods/ra/tilesets/snow.yaml +++ b/mods/ra/tilesets/snow.yaml @@ -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 diff --git a/mods/ra/tilesets/temperat.yaml b/mods/ra/tilesets/temperat.yaml index 4dd951c41c..7e2729469c 100644 --- a/mods/ra/tilesets/temperat.yaml +++ b/mods/ra/tilesets/temperat.yaml @@ -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