diff --git a/OpenRA.Game/Traits/ProductionSurround.cs b/OpenRA.Game/Traits/ProductionSurround.cs index 74cd072fe6..51cd2de585 100644 --- a/OpenRA.Game/Traits/ProductionSurround.cs +++ b/OpenRA.Game/Traits/ProductionSurround.cs @@ -32,7 +32,7 @@ namespace OpenRA.Traits { public ProductionSurround(Actor self) : base(self) { } - static int2? FindAdjacentTile(Actor self, UnitMovementType umt) + static int2? FindAdjacentTile(Actor self, bool waterBound) { var tiles = Footprint.Tiles(self, self.traits.Get()); var min = tiles.Aggregate(int2.Min) - new int2(1, 1); @@ -40,7 +40,7 @@ namespace OpenRA.Traits for (var j = min.Y; j <= max.Y; j++) for (var i = min.X; i <= max.X; i++) - if (self.World.IsCellBuildable(new int2(i, j), umt)) + if (self.World.IsCellBuildable(new int2(i, j), waterBound)) return new int2(i, j); return null; @@ -48,8 +48,7 @@ namespace OpenRA.Traits public override int2? CreationLocation(Actor self, ActorInfo producee) { - return FindAdjacentTile(self, producee.Traits.Get().WaterBound ? - UnitMovementType.Float : UnitMovementType.Wheel); /* hackety hack */ + return FindAdjacentTile(self, producee.Traits.Get().WaterBound); } public override int CreationFacing(Actor self, Actor newUnit) diff --git a/OpenRA.Game/Traits/SeedsResource.cs b/OpenRA.Game/Traits/SeedsResource.cs index e290e08ee6..503f4e90fb 100644 --- a/OpenRA.Game/Traits/SeedsResource.cs +++ b/OpenRA.Game/Traits/SeedsResource.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -53,7 +53,7 @@ namespace OpenRA.Traits for (var j = -1; j < 2; j++) for (var i = -1; i < 2; i++) if (self.World.SharedRandom.NextDouble() < info.Chance) - if (self.World.IsCellBuildable(self.Location + new int2(i, j), UnitMovementType.Wheel)) + if (self.World.IsCellBuildable(self.Location + new int2(i, j), false)) resLayer.AddResource(resourceType, self.Location.X + i, self.Location.Y + j, 1); ticks = info.Interval; diff --git a/OpenRA.Game/Traits/World/CrateSpawner.cs b/OpenRA.Game/Traits/World/CrateSpawner.cs index 266bb4cafc..e6b3492d03 100644 --- a/OpenRA.Game/Traits/World/CrateSpawner.cs +++ b/OpenRA.Game/Traits/World/CrateSpawner.cs @@ -62,13 +62,12 @@ namespace OpenRA.Traits void SpawnCrate(Actor self, CrateSpawnerInfo info) { var inWater = self.World.SharedRandom.NextDouble() < info.WaterChance; - var umt = inWater ? UnitMovementType.Float : UnitMovementType.Wheel; for (var n = 0; n < ChooseCrateLocationAttempts; n++) { var p = self.World.ChooseRandomCell(self.World.SharedRandom); - if (self.World.IsCellBuildable(p, umt)) + if (self.World.IsCellBuildable(p, inWater)) { self.World.AddFrameEndTask( w => crates.Add(w.CreateActor("crate", p, self.World.NeutralPlayer))); diff --git a/OpenRA.Game/Traits/World/ResourceLayer.cs b/OpenRA.Game/Traits/World/ResourceLayer.cs index fed87dbf99..c38ef02938 100644 --- a/OpenRA.Game/Traits/World/ResourceLayer.cs +++ b/OpenRA.Game/Traits/World/ResourceLayer.cs @@ -176,7 +176,7 @@ namespace OpenRA.Traits for (int i = mini; i < maxi; i++) if (content[i,j].type == null && GetAdjacentCellsWith(info, i,j ) > 0 - && w.IsCellBuildable(new int2(i, j), UnitMovementType.Wheel)) + && w.IsCellBuildable(new int2(i, j), false)) growMask[i, j] = true; for (int j = minj; j < maxj; j++) diff --git a/OpenRA.Game/UiOverlay.cs b/OpenRA.Game/UiOverlay.cs index 5a45c029a2..a7d4bf864d 100644 --- a/OpenRA.Game/UiOverlay.cs +++ b/OpenRA.Game/UiOverlay.cs @@ -71,8 +71,7 @@ namespace OpenRA var res = world.WorldActor.traits.Get(); foreach( var t in Footprint.Tiles( name, bi, topLeft ) ) - spriteRenderer.DrawSprite( ( isCloseEnough && world.IsCellBuildable( t, bi.WaterBound - ? UnitMovementType.Float : UnitMovementType.Wheel ) && res.GetResource(t) == null ) + spriteRenderer.DrawSprite( ( isCloseEnough && world.IsCellBuildable( t, bi.WaterBound) && res.GetResource(t) == null ) ? buildOk : buildBlocked, Game.CellSize * t, "terrain" ); // Linebuild for walls. @@ -105,7 +104,7 @@ namespace OpenRA continue; int2 cell = topLeft + i * vecs[d]; - if (world.IsCellBuildable(cell, bi.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel, null)) + if (world.IsCellBuildable(cell, bi.WaterBound)) continue; // Cell is empty; continue search // Cell contains an actor. Is it the type we want? diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs index 30624280ee..3dfdf143ac 100755 --- a/OpenRA.Game/WorldUtils.cs +++ b/OpenRA.Game/WorldUtils.cs @@ -38,16 +38,19 @@ namespace OpenRA return world.Map.IsInMap(a.X, a.Y) && TerrainCosts.Cost(umt, world.TileSet.GetTerrainType(world.Map.MapTiles[a.X,a.Y])) < double.PositiveInfinity; } - public static bool IsCellBuildable(this World world, int2 a, UnitMovementType umt) + public static bool IsCellBuildable(this World world, int2 a, bool waterBound) { - return world.IsCellBuildable(a, umt, null); + return world.IsCellBuildable(a, waterBound, null); } - public static bool IsCellBuildable(this World world, int2 a, UnitMovementType umt, Actor toIgnore) + public static bool IsCellBuildable(this World world, int2 a, bool waterBound, Actor toIgnore) { if (world.WorldActor.traits.Get().GetBuildingAt(a) != null) return false; if (world.WorldActor.traits.Get().GetUnitsAt(a).Any(b => b != toIgnore)) return false; - + + if (waterBound) + return world.Map.IsInMap(a.X,a.Y) && GetTerrainType(world,a) == TerrainMovementType.Water; + return world.Map.IsInMap(a.X, a.Y) && TerrainCosts.Buildable(world.TileSet.GetTerrainType(world.Map.MapTiles[a.X, a.Y])); } @@ -136,8 +139,7 @@ namespace OpenRA var res = world.WorldActor.traits.Get(); return !Footprint.Tiles(name, building, topLeft).Any( t => !world.Map.IsInMap(t.X, t.Y) || res.GetResource(t) != null || !world.IsCellBuildable(t, - building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel, - toIgnore)); + building.WaterBound, toIgnore)); } public static bool IsCloseEnoughToBase(this World world, Player p, string buildingName, BuildingInfo bi, int2 topLeft) diff --git a/OpenRA.Mods.RA-NG/CrateDrop.cs b/OpenRA.Mods.RA-NG/CrateDrop.cs index f789843578..ea3b84847a 100644 --- a/OpenRA.Mods.RA-NG/CrateDrop.cs +++ b/OpenRA.Mods.RA-NG/CrateDrop.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -64,13 +64,12 @@ namespace OpenRA.Mods.RA_NG void SpawnCrate(Actor self, CrateDropInfo info) { var threshold = 100; - var inWater = self.World.SharedRandom.NextDouble() < info.WaterChance; - var umt = inWater ? UnitMovementType.Float : UnitMovementType.Wheel; + for (var n = 0; n < threshold; n++ ) { var p = self.World.ChooseRandomCell(self.World.SharedRandom); - if (self.World.IsCellBuildable(p, umt)) + if (self.World.IsCellBuildable(p, inWater)) { self.World.AddFrameEndTask(w => {