Powerdown etc... untested
This commit is contained in:
@@ -12,17 +12,23 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
public class CanPowerDownInfo : TraitInfo<CanPowerDown> { }
|
||||
public class CanPowerDownInfo : ITraitInfo
|
||||
{
|
||||
public object Create(ActorInitializer init) { return new CanPowerDown(init); }
|
||||
}
|
||||
|
||||
public class CanPowerDown : IDisable, IPowerModifier, IResolveOrder
|
||||
public class CanPowerDown : IResolveOrder
|
||||
{
|
||||
[Sync]
|
||||
bool disabled = false;
|
||||
|
||||
|
||||
readonly PowerManager PlayerPower;
|
||||
public CanPowerDown(ActorInitializer init)
|
||||
{
|
||||
PlayerPower = init.self.Owner.PlayerActor.Trait<PowerManager>();
|
||||
}
|
||||
public bool Disabled { get { return disabled; } }
|
||||
|
||||
public float GetPowerModifier() { return (disabled) ? 0.0f : 1.0f; }
|
||||
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "PowerDown")
|
||||
@@ -30,6 +36,11 @@ namespace OpenRA.Mods.RA
|
||||
disabled = !disabled;
|
||||
var eva = self.World.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
|
||||
Sound.PlayToPlayer(self.Owner, disabled ? eva.EnablePower : eva.DisablePower);
|
||||
|
||||
if (disabled)
|
||||
PlayerPower.Disable(self, "PowerDown");
|
||||
else
|
||||
PlayerPower.RemoveDisable(self, "PowerDown");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user