Fix PBOG and Building to support concrete placement.

This commit is contained in:
Paul Chote
2014-03-16 23:12:46 +13:00
parent cc34a40ebc
commit e6c041e53f
3 changed files with 14 additions and 4 deletions

View File

@@ -32,6 +32,7 @@ namespace OpenRA.Mods.RA.Buildings
public readonly string Footprint = "x";
public readonly int2 Dimensions = new int2(1, 1);
public readonly bool RequiresBaseProvider = false;
public readonly bool AllowInvalidPlacement = false;
public readonly string[] BuildSounds = {"placbldg.aud", "build5.aud"};
public readonly string[] SellSounds = {"cashturn.aud"};

View File

@@ -31,6 +31,9 @@ namespace OpenRA.Mods.RA.Buildings
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, CPos topLeft, Actor toIgnore)
{
if (building.AllowInvalidPlacement)
return true;
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 &&

View File

@@ -90,11 +90,17 @@ namespace OpenRA.Mods.RA.Orders
{
if (!initialized)
{
var rbi = Rules.Info[Building].Traits.Get<RenderBuildingInfo>();
var rbi = Rules.Info[Building].Traits.GetOrDefault<RenderBuildingInfo>();
if (rbi == null)
preview = new IRenderable[0];
else
{
var palette = rbi.Palette ?? (Producer.Owner != null ?
rbi.PlayerPalette + Producer.Owner.InternalName : null);
preview = rbi.RenderPreview(Rules.Info[Building], wr.Palette(palette));
}
initialized = true;
}