From c6c52eac7dd5a1f488571bfcaf8715d291b98e4c Mon Sep 17 00:00:00 2001 From: Taryn Hill Date: Tue, 31 Mar 2015 15:26:04 -0500 Subject: [PATCH] Expose and document the palette used by PlaceBuildingOrderGenerator for the structure placement overlay --- OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs | 4 +++- OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs index 07e720662d..1de95bee5c 100644 --- a/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs +++ b/OpenRA.Mods.Common/Orders/PlaceBuildingOrderGenerator.cs @@ -23,6 +23,7 @@ namespace OpenRA.Mods.Common.Orders readonly Actor producer; readonly string building; readonly BuildingInfo buildingInfo; + readonly PlaceBuildingInfo placeBuildingInfo; readonly string race; readonly Sprite buildOk; readonly Sprite buildBlocked; @@ -33,6 +34,7 @@ namespace OpenRA.Mods.Common.Orders public PlaceBuildingOrderGenerator(ProductionQueue queue, string name) { producer = queue.Actor; + placeBuildingInfo = producer.Info.Traits.Get(); building = name; // Clear selection if using Left-Click Orders @@ -155,7 +157,7 @@ namespace OpenRA.Mods.Common.Orders cells.Add(t, isCloseEnough && world.IsCellBuildable(t, buildingInfo) && res.GetResource(t) == null); } - var pal = wr.Palette("terrain"); + var pal = wr.Palette(placeBuildingInfo.Palette); foreach (var c in cells) { var tile = c.Value ? buildOk : buildBlocked; diff --git a/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs b/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs index aa4c0c3a2e..91d118f0de 100644 --- a/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Player/PlaceBuilding.cs @@ -16,7 +16,11 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Allows to execute build orders.", " Attach this to the player actor.")] - class PlaceBuildingInfo : TraitInfo { } + class PlaceBuildingInfo : TraitInfo + { + [Desc("Palette to use for rendering the placement sprite.")] + public readonly string Palette = "terrain"; + } class PlaceBuilding : IResolveOrder {