Add support for custom sell cursors.

This commit is contained in:
Paul Chote
2017-11-15 17:45:14 +00:00
committed by reaperrr
parent 5030a2257e
commit 4cbc2ee6f3
2 changed files with 11 additions and 1 deletions

View File

@@ -83,7 +83,14 @@ namespace OpenRA.Mods.Common.Orders
public override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) public override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{ {
mi.Button = MouseButton.Left; mi.Button = MouseButton.Left;
return OrderInner(world, mi).Any() ? "sell" : "sell-blocked";
var cursor = OrderInner(world, mi)
.SelectMany(o => o.Subject.TraitsImplementing<Sellable>())
.Where(Exts.IsTraitEnabled)
.Select(si => si.Info.Cursor)
.FirstOrDefault();
return cursor ?? "sell-blocked";
} }
} }
} }

View File

@@ -27,6 +27,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Skip playing (reversed) make animation.")] [Desc("Skip playing (reversed) make animation.")]
public readonly bool SkipMakeAnimation = false; public readonly bool SkipMakeAnimation = false;
[Desc("Cursor type to use when the sell order generator hovers over this actor.")]
public readonly string Cursor = "sell";
public override object Create(ActorInitializer init) { return new Sellable(init.Self, this); } public override object Create(ActorInitializer init) { return new Sellable(init.Self, this); }
} }