Moved SellSounds from Building to Sellable & added upgrade to rules.

This commit is contained in:
atlimit8
2014-08-29 12:55:19 -05:00
parent f9255ecc49
commit cc9c253419
8 changed files with 51 additions and 10 deletions

View File

@@ -8,6 +8,7 @@
*/
#endregion
using System.Linq;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Render;
@@ -15,14 +16,22 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
[Desc("Building can be sold")]
public class SellableInfo : TraitInfo<Sellable>
[Desc("Actor can be sold")]
public class SellableInfo : ITraitInfo
{
public readonly int RefundPercent = 50;
public readonly string[] SellSounds = { };
public object Create(ActorInitializer init) { return new Sellable(this); }
}
public class Sellable : IResolveOrder
{
readonly SellableInfo info;
public Sellable(SellableInfo info) { this.info = info; }
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Sell")
@@ -37,6 +46,9 @@ namespace OpenRA.Mods.RA
self.CancelActivity();
foreach (var s in info.SellSounds)
Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
foreach (var ns in self.TraitsImplementing<INotifySold>())
ns.Selling(self);