Merge pull request #6745 from atlimit8/SellableByUpgrade

Upgrade support for Sellable
This commit is contained in:
Paul Chote
2014-11-29 22:08:29 +13:00
3 changed files with 11 additions and 8 deletions

View File

@@ -223,7 +223,7 @@
<Compile Include="Move\PathFinder.cs" />
<Compile Include="Move\PathSearch.cs" />
<Compile Include="Orders\PlaceBuildingOrderGenerator.cs" />
<Compile Include="Orders\PowerDownOrderGenerator.cs" />
<Compile Include="Orders\GlobalButtonOrderGenerator.cs" />
<Compile Include="Orders\RepairOrderGenerator.cs" />
<Compile Include="OreRefinery.cs" />
<Compile Include="ParaDrop.cs" />

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA.Orders
public string GetCursor(World world, CPos xy, MouseInput mi)
{
mi.Button = MouseButton.Left;
return cursor + (OrderInner(world, mi).Any() ? "" : "-blocked");
return cursor + (OrderInner(world, mi).Any() ? "" : "-blocked");
}
}

View File

@@ -9,6 +9,7 @@
#endregion
using System.Linq;
using OpenRA.Mods.Common;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Render;
@@ -18,7 +19,7 @@ namespace OpenRA.Mods.RA
{
[Desc("Actor can be sold")]
public class SellableInfo : ITraitInfo
public class SellableInfo : UpgradableTraitInfo, ITraitInfo
{
public readonly int RefundPercent = 50;
public readonly string[] SellSounds = { };
@@ -26,11 +27,10 @@ namespace OpenRA.Mods.RA
public object Create(ActorInitializer init) { return new Sellable(this); }
}
public class Sellable : IResolveOrder
public class Sellable : UpgradableTrait<SellableInfo>, IResolveOrder
{
readonly SellableInfo info;
public Sellable(SellableInfo info) { this.info = info; }
public Sellable(SellableInfo info)
: base(info) { }
public void ResolveOrder(Actor self, Order order)
{
@@ -40,13 +40,16 @@ namespace OpenRA.Mods.RA
public void Sell(Actor self)
{
if (IsTraitDisabled)
return;
var building = self.TraitOrDefault<Building>();
if (building != null && !building.Lock())
return;
self.CancelActivity();
foreach (var s in info.SellSounds)
foreach (var s in Info.SellSounds)
Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
foreach (var ns in self.TraitsImplementing<INotifySold>())