diff --git a/OpenRA.Mods.RA/Buildings/Building.cs b/OpenRA.Mods.RA/Buildings/Building.cs index 83e4ef697a..2e2331d274 100755 --- a/OpenRA.Mods.RA/Buildings/Building.cs +++ b/OpenRA.Mods.RA/Buildings/Building.cs @@ -25,8 +25,6 @@ namespace OpenRA.Mods.RA.Buildings public readonly bool Capturable = false; public readonly string Footprint = "x"; public readonly int2 Dimensions = new int2(1, 1); - public readonly bool Unsellable = false; - public readonly int RefundPercent = 50; public readonly string[] BuildSounds = {"placbldg.aud", "build5.aud"}; public readonly string[] SellSounds = {"cashturn.aud"}; diff --git a/OpenRA.Mods.RA/Buildings/Sell.cs b/OpenRA.Mods.RA/Buildings/Sell.cs index 671e1cfeb4..881aadfe22 100755 --- a/OpenRA.Mods.RA/Buildings/Sell.cs +++ b/OpenRA.Mods.RA/Buildings/Sell.cs @@ -24,17 +24,18 @@ namespace OpenRA.Mods.RA.Buildings void DoSell(Actor self) { var h = self.TraitOrDefault(); - var bi = self.Info.Traits.Get(); + var si = self.Info.Traits.Get(); var pr = self.Owner.PlayerActor.Trait(); var csv = self.Info.Traits.GetOrDefault(); var cost = csv != null ? csv.Value : self.Info.Traits.Get().Cost; - var refund = (cost * bi.RefundPercent * (h == null ? 1 : h.HP)) / (100 * (h == null ? 1 : h.MaxHP)); + var refund = (cost * si.RefundPercent * (h == null ? 1 : h.HP)) / (100 * (h == null ? 1 : h.MaxHP)); pr.GiveCash(refund); foreach (var ns in self.TraitsImplementing()) ns.Sold(self); + self.Destroy(); } diff --git a/OpenRA.Mods.RA/Buildings/Sellable.cs b/OpenRA.Mods.RA/Buildings/Sellable.cs new file mode 100644 index 0000000000..7624e8ce7c --- /dev/null +++ b/OpenRA.Mods.RA/Buildings/Sellable.cs @@ -0,0 +1,45 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System; +using System.Collections.Generic; +using OpenRA.Orders; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA.Buildings +{ + class SellableInfo : TraitInfo + { + public readonly int RefundPercent = 50; + } + + class Sellable : IIssueOrder, IResolveOrder + { + public IEnumerable Orders + { + get { yield return new PaletteOnlyOrderTargeter("Sell"); } + } + + public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued ) + { + /* todo: make this work */ + throw new NotImplementedException(); + } + + public void ResolveOrder(Actor self, Order order) + { + if (order.OrderString == "Sell") + { + self.CancelActivity(); + self.QueueActivity(new Sell()); + } + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 41abd84712..b54c28ccbf 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -1,4 +1,4 @@ - + Debug @@ -330,6 +330,7 @@ + diff --git a/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs b/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs index c42f291eb3..b09a5dddf8 100755 --- a/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs +++ b/OpenRA.Mods.RA/Orders/SellOrderGenerator.cs @@ -32,12 +32,9 @@ namespace OpenRA.Mods.RA.Orders { var underCursor = world.FindUnitsAtMouse(mi.Location) .Where(a => a.Owner == world.LocalPlayer - && a.HasTrait() - && a.HasTrait()).FirstOrDefault(); - - var building = underCursor != null ? underCursor.Info.Traits.Get() : null; - - if (building != null && !building.Unsellable) + && a.HasTrait()).FirstOrDefault(); + + if (underCursor != null) yield return new Order("Sell", underCursor, false); } }