Added Upgrade support to Sellable
This commit is contained in:
@@ -223,7 +223,7 @@
|
|||||||
<Compile Include="Move\PathFinder.cs" />
|
<Compile Include="Move\PathFinder.cs" />
|
||||||
<Compile Include="Move\PathSearch.cs" />
|
<Compile Include="Move\PathSearch.cs" />
|
||||||
<Compile Include="Orders\PlaceBuildingOrderGenerator.cs" />
|
<Compile Include="Orders\PlaceBuildingOrderGenerator.cs" />
|
||||||
<Compile Include="Orders\PowerDownOrderGenerator.cs" />
|
<Compile Include="Orders\GlobalButtonOrderGenerator.cs" />
|
||||||
<Compile Include="Orders\RepairOrderGenerator.cs" />
|
<Compile Include="Orders\RepairOrderGenerator.cs" />
|
||||||
<Compile Include="OreRefinery.cs" />
|
<Compile Include="OreRefinery.cs" />
|
||||||
<Compile Include="ParaDrop.cs" />
|
<Compile Include="ParaDrop.cs" />
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
public string GetCursor(World world, CPos xy, MouseInput mi)
|
public string GetCursor(World world, CPos xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
mi.Button = MouseButton.Left;
|
mi.Button = MouseButton.Left;
|
||||||
return cursor + (OrderInner(world, mi).Any() ? "" : "-blocked");
|
return cursor + (OrderInner(world, mi).Any() ? "" : "-blocked");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Mods.Common;
|
||||||
using OpenRA.Mods.RA.Activities;
|
using OpenRA.Mods.RA.Activities;
|
||||||
using OpenRA.Mods.RA.Buildings;
|
using OpenRA.Mods.RA.Buildings;
|
||||||
using OpenRA.Mods.RA.Render;
|
using OpenRA.Mods.RA.Render;
|
||||||
@@ -18,7 +19,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
|
|
||||||
[Desc("Actor can be sold")]
|
[Desc("Actor can be sold")]
|
||||||
public class SellableInfo : ITraitInfo
|
public class SellableInfo : UpgradableTraitInfo, ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly int RefundPercent = 50;
|
public readonly int RefundPercent = 50;
|
||||||
public readonly string[] SellSounds = { };
|
public readonly string[] SellSounds = { };
|
||||||
@@ -26,11 +27,10 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new Sellable(this); }
|
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)
|
||||||
|
: base(info) { }
|
||||||
public Sellable(SellableInfo info) { this.info = info; }
|
|
||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
@@ -40,13 +40,16 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Sell(Actor self)
|
public void Sell(Actor self)
|
||||||
{
|
{
|
||||||
|
if (IsTraitDisabled)
|
||||||
|
return;
|
||||||
|
|
||||||
var building = self.TraitOrDefault<Building>();
|
var building = self.TraitOrDefault<Building>();
|
||||||
if (building != null && !building.Lock())
|
if (building != null && !building.Lock())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
foreach (var s in info.SellSounds)
|
foreach (var s in Info.SellSounds)
|
||||||
Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
|
Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);
|
||||||
|
|
||||||
foreach (var ns in self.TraitsImplementing<INotifySold>())
|
foreach (var ns in self.TraitsImplementing<INotifySold>())
|
||||||
|
|||||||
Reference in New Issue
Block a user