Fix PBOG and Building to support concrete placement.
This commit is contained in:
@@ -32,6 +32,7 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
public readonly string Footprint = "x";
|
public readonly string Footprint = "x";
|
||||||
public readonly int2 Dimensions = new int2(1, 1);
|
public readonly int2 Dimensions = new int2(1, 1);
|
||||||
public readonly bool RequiresBaseProvider = false;
|
public readonly bool RequiresBaseProvider = false;
|
||||||
|
public readonly bool AllowInvalidPlacement = false;
|
||||||
|
|
||||||
public readonly string[] BuildSounds = {"placbldg.aud", "build5.aud"};
|
public readonly string[] BuildSounds = {"placbldg.aud", "build5.aud"};
|
||||||
public readonly string[] SellSounds = {"cashturn.aud"};
|
public readonly string[] SellSounds = {"cashturn.aud"};
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
|
|
||||||
public static bool CanPlaceBuilding(this World world, string name, BuildingInfo building, CPos topLeft, Actor toIgnore)
|
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>();
|
var res = world.WorldActor.Trait<ResourceLayer>();
|
||||||
return FootprintUtils.Tiles(name, building, topLeft).All(
|
return FootprintUtils.Tiles(name, building, topLeft).All(
|
||||||
t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null &&
|
t => world.Map.IsInMap(t.X, t.Y) && res.GetResource(t) == null &&
|
||||||
|
|||||||
@@ -90,11 +90,17 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
{
|
{
|
||||||
if (!initialized)
|
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 ?
|
var palette = rbi.Palette ?? (Producer.Owner != null ?
|
||||||
rbi.PlayerPalette + Producer.Owner.InternalName : null);
|
rbi.PlayerPalette + Producer.Owner.InternalName : null);
|
||||||
|
|
||||||
preview = rbi.RenderPreview(Rules.Info[Building], wr.Palette(palette));
|
preview = rbi.RenderPreview(Rules.Info[Building], wr.Palette(palette));
|
||||||
|
}
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user