From a9908bffb434fa9e5d564a6c87446752d7acc32f Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Sun, 28 Jun 2015 10:24:00 -0500 Subject: [PATCH] UpgradeManager after IUpgradables --- OpenRA.Mods.Cnc/Traits/PoisonedByTiberium.cs | 4 ++-- OpenRA.Mods.Common/Traits/Armament.cs | 4 ++-- OpenRA.Mods.Common/Traits/Attack/AttackBase.cs | 2 +- OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs | 4 ++-- OpenRA.Mods.Common/Traits/Cloak.cs | 4 ++-- OpenRA.Mods.Common/Traits/DetectCloaked.cs | 4 ++-- OpenRA.Mods.Common/Traits/KillsSelf.cs | 4 ++-- OpenRA.Mods.Common/Traits/Modifiers/UpgradeOverlay.cs | 4 ++-- OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs | 4 ++-- OpenRA.Mods.Common/Traits/Power/Power.cs | 4 ++-- OpenRA.Mods.Common/Traits/Render/TimedUpgradeBar.cs | 5 ++++- OpenRA.Mods.Common/Traits/Render/WithDecoration.cs | 4 ++-- OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs | 4 ++-- OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs | 4 ++-- OpenRA.Mods.Common/Traits/Render/WithMuzzleFlash.cs | 4 ++-- OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs | 4 ++-- OpenRA.Mods.Common/Traits/Render/WithTurret.cs | 4 ++-- OpenRA.Mods.Common/Traits/SelfHealing.cs | 4 ++-- OpenRA.Mods.Common/Traits/Sellable.cs | 4 ++-- OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs | 3 +-- OpenRA.Mods.Common/Traits/Upgrades/DisableUpgrade.cs | 4 ++-- OpenRA.Mods.Common/Traits/Upgrades/UpgradableTrait.cs | 4 +++- OpenRA.Mods.Common/Traits/Upgrades/UpgradeManager.cs | 2 +- OpenRA.Mods.Common/TraitsInterfaces.cs | 3 +++ OpenRA.Mods.D2k/Traits/AttractsWorms.cs | 4 ++-- OpenRA.Mods.RA/Traits/InvulnerabilityUpgrade.cs | 4 ++-- 26 files changed, 53 insertions(+), 46 deletions(-) diff --git a/OpenRA.Mods.Cnc/Traits/PoisonedByTiberium.cs b/OpenRA.Mods.Cnc/Traits/PoisonedByTiberium.cs index e42cc06b2b..c046a622d5 100644 --- a/OpenRA.Mods.Cnc/Traits/PoisonedByTiberium.cs +++ b/OpenRA.Mods.Cnc/Traits/PoisonedByTiberium.cs @@ -15,12 +15,12 @@ using OpenRA.Traits; namespace OpenRA.Mods.Cnc.Traits { - class PoisonedByTiberiumInfo : UpgradableTraitInfo, ITraitInfo + class PoisonedByTiberiumInfo : UpgradableTraitInfo { [WeaponReference] public readonly string Weapon = "Tiberium"; public readonly string[] Resources = { "Tiberium", "BlueTiberium" }; - public object Create(ActorInitializer init) { return new PoisonedByTiberium(this); } + public override object Create(ActorInitializer init) { return new PoisonedByTiberium(this); } } class PoisonedByTiberium : UpgradableTrait, ITick, ISync diff --git a/OpenRA.Mods.Common/Traits/Armament.cs b/OpenRA.Mods.Common/Traits/Armament.cs index 4afb573f11..6068aa29d5 100644 --- a/OpenRA.Mods.Common/Traits/Armament.cs +++ b/OpenRA.Mods.Common/Traits/Armament.cs @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits } [Desc("Allows you to attach weapons to the unit (use @IdentifierSuffix for > 1)")] - public class ArmamentInfo : UpgradableTraitInfo, ITraitInfo, Requires + public class ArmamentInfo : UpgradableTraitInfo, Requires { public readonly string Name = "primary"; @@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Use multiple muzzle images if non-zero")] public readonly int MuzzleSplitFacings = 0; - public object Create(ActorInitializer init) { return new Armament(init.Self, this); } + public override object Create(ActorInitializer init) { return new Armament(init.Self, this); } } public class Armament : UpgradableTrait, ITick, IExplodeModifier diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 369e8689bf..0cca327725 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits [VoiceReference] public readonly string Voice = "Action"; - public abstract object Create(ActorInitializer init); + public override abstract object Create(ActorInitializer init); } public abstract class AttackBase : UpgradableTrait, IIssueOrder, IResolveOrder, IOrderVoice, ISync diff --git a/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs b/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs index b966bc6129..8c9f222f11 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs @@ -17,7 +17,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Building can be repaired by the repair button.")] - public class RepairableBuildingInfo : UpgradableTraitInfo, ITraitInfo, Requires + public class RepairableBuildingInfo : UpgradableTraitInfo, Requires { public readonly int RepairPercent = 20; public readonly int RepairInterval = 24; @@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Suffixed by the interal repairing player name.")] public readonly string IndicatorPalettePrefix = "player"; - public object Create(ActorInitializer init) { return new RepairableBuilding(init.Self, this); } + public override object Create(ActorInitializer init) { return new RepairableBuilding(init.Self, this); } } public class RepairableBuilding : UpgradableTrait, ITick diff --git a/OpenRA.Mods.Common/Traits/Cloak.cs b/OpenRA.Mods.Common/Traits/Cloak.cs index 43b71c9fcb..1c03974653 100644 --- a/OpenRA.Mods.Common/Traits/Cloak.cs +++ b/OpenRA.Mods.Common/Traits/Cloak.cs @@ -18,7 +18,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("This unit can cloak and uncloak in specific situations.")] - public class CloakInfo : UpgradableTraitInfo, ITraitInfo + public class CloakInfo : UpgradableTraitInfo { [Desc("Measured in game ticks.")] public readonly int InitialDelay = 10; @@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string[] CloakTypes = { "Cloak" }; - public object Create(ActorInitializer init) { return new Cloak(init.Self, this); } + public override object Create(ActorInitializer init) { return new Cloak(init.Self, this); } } public class Cloak : UpgradableTrait, IRenderModifier, INotifyDamageStateChanged, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier diff --git a/OpenRA.Mods.Common/Traits/DetectCloaked.cs b/OpenRA.Mods.Common/Traits/DetectCloaked.cs index cd5fcb1d6f..0c28a32ca7 100644 --- a/OpenRA.Mods.Common/Traits/DetectCloaked.cs +++ b/OpenRA.Mods.Common/Traits/DetectCloaked.cs @@ -13,7 +13,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Actor can reveal Cloak actors in a specified range.")] - public class DetectCloakedInfo : UpgradableTraitInfo, ITraitInfo + public class DetectCloakedInfo : UpgradableTraitInfo { [Desc("Specific cloak classifications I can reveal.")] public readonly string[] CloakTypes = { "Cloak" }; @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Measured in cells.")] public readonly int Range = 5; - public object Create(ActorInitializer init) { return new DetectCloaked(this); } + public override object Create(ActorInitializer init) { return new DetectCloaked(this); } } public class DetectCloaked : UpgradableTrait diff --git a/OpenRA.Mods.Common/Traits/KillsSelf.cs b/OpenRA.Mods.Common/Traits/KillsSelf.cs index 3b5e6b6b6a..48ccc153ba 100644 --- a/OpenRA.Mods.Common/Traits/KillsSelf.cs +++ b/OpenRA.Mods.Common/Traits/KillsSelf.cs @@ -12,12 +12,12 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - class KillsSelfInfo : UpgradableTraitInfo, ITraitInfo + class KillsSelfInfo : UpgradableTraitInfo { [Desc("Remove the actor from the world (and destroy it) instead of killing it.")] public readonly bool RemoveInstead = false; - public object Create(ActorInitializer init) { return new KillsSelf(this); } + public override object Create(ActorInitializer init) { return new KillsSelf(this); } } class KillsSelf : UpgradableTrait, INotifyAddedToWorld diff --git a/OpenRA.Mods.Common/Traits/Modifiers/UpgradeOverlay.cs b/OpenRA.Mods.Common/Traits/Modifiers/UpgradeOverlay.cs index f63ff61856..53ef3ffdca 100644 --- a/OpenRA.Mods.Common/Traits/Modifiers/UpgradeOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Modifiers/UpgradeOverlay.cs @@ -15,12 +15,12 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Display a colored overlay when a timed upgrade is active.")] - public class UpgradeOverlayInfo : UpgradableTraitInfo, ITraitInfo + public class UpgradeOverlayInfo : UpgradableTraitInfo { [Desc("Palette to use when rendering the overlay")] public readonly string Palette = "invuln"; - public object Create(ActorInitializer init) { return new UpgradeOverlay(this); } + public override object Create(ActorInitializer init) { return new UpgradeOverlay(this); } } public class UpgradeOverlay : UpgradableTrait, IRenderModifier diff --git a/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs b/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs index b6902f44b1..bb8c7777bd 100644 --- a/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs +++ b/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("The player can disable the power individually on this actor.")] - public class CanPowerDownInfo : UpgradableTraitInfo, ITraitInfo, Requires + public class CanPowerDownInfo : UpgradableTraitInfo, Requires { [Desc("Restore power when this trait is disabled.")] public readonly bool CancelWhenDisabled = false; @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits public readonly string IndicatorPalette = "chrome"; - public object Create(ActorInitializer init) { return new CanPowerDown(init.Self, this); } + public override object Create(ActorInitializer init) { return new CanPowerDown(init.Self, this); } } public class CanPowerDown : UpgradableTrait, IPowerModifier, IResolveOrder, IDisable, INotifyOwnerChanged diff --git a/OpenRA.Mods.Common/Traits/Power/Power.cs b/OpenRA.Mods.Common/Traits/Power/Power.cs index b44d09c575..871ffac5b4 100644 --- a/OpenRA.Mods.Common/Traits/Power/Power.cs +++ b/OpenRA.Mods.Common/Traits/Power/Power.cs @@ -14,12 +14,12 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public class PowerInfo : UpgradableTraitInfo, ITraitInfo + public class PowerInfo : UpgradableTraitInfo { [Desc("If negative, it will drain power. If positive, it will provide power.")] public readonly int Amount = 0; - public object Create(ActorInitializer init) { return new Power(init.Self, this); } + public override object Create(ActorInitializer init) { return new Power(init.Self, this); } } public class Power : UpgradableTrait, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOwnerChanged diff --git a/OpenRA.Mods.Common/Traits/Render/TimedUpgradeBar.cs b/OpenRA.Mods.Common/Traits/Render/TimedUpgradeBar.cs index 06a431fade..a447433aba 100644 --- a/OpenRA.Mods.Common/Traits/Render/TimedUpgradeBar.cs +++ b/OpenRA.Mods.Common/Traits/Render/TimedUpgradeBar.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits public object Create(ActorInitializer init) { return new TimedUpgradeBar(init.Self, this); } } - class TimedUpgradeBar : ISelectionBar + class TimedUpgradeBar : ISelectionBar, INotifyCreated { readonly TimedUpgradeBarInfo info; readonly Actor self; @@ -36,7 +36,10 @@ namespace OpenRA.Mods.Common.Traits { this.self = self; this.info = info; + } + public void Created(Actor self) + { self.Trait().RegisterWatcher(info.Upgrade, Update); } diff --git a/OpenRA.Mods.Common/Traits/Render/WithDecoration.cs b/OpenRA.Mods.Common/Traits/Render/WithDecoration.cs index 589d5bcdf2..b35ec76a46 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithDecoration.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithDecoration.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits } [Desc("Displays a custom animation if conditions are satisfied.")] - public class WithDecorationInfo : UpgradableTraitInfo, ITraitInfo + public class WithDecorationInfo : UpgradableTraitInfo { [Desc("Image used for this decoration. Defaults to the actor's type.")] public readonly string Image = null; @@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Should this be visible to enemy players?")] public readonly bool ShowToEnemies = false; - public virtual object Create(ActorInitializer init) { return new WithDecoration(init.Self, this); } + public override object Create(ActorInitializer init) { return new WithDecoration(init.Self, this); } } public class WithDecoration : UpgradableTrait, IRender diff --git a/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs index 2ad7cb7af5..b08cf18505 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithIdleOverlay.cs @@ -17,7 +17,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Renders a decorative animation on units and buildings.")] - public class WithIdleOverlayInfo : UpgradableTraitInfo, ITraitInfo, IRenderActorPreviewSpritesInfo, Requires, Requires + public class WithIdleOverlayInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires, Requires { [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "idle-overlay"; @@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits public readonly bool PauseOnLowPower = false; - public object Create(ActorInitializer init) { return new WithIdleOverlay(init.Self, this); } + public override object Create(ActorInitializer init) { return new WithIdleOverlay(init.Self, this); } public IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { diff --git a/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs b/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs index d06ac20c50..15067206ee 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithInfantryBody.cs @@ -16,7 +16,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public class WithInfantryBodyInfo : UpgradableTraitInfo, ITraitInfo, IQuantizeBodyOrientationInfo, IRenderActorPreviewSpritesInfo, + public class WithInfantryBodyInfo : UpgradableTraitInfo, IQuantizeBodyOrientationInfo, IRenderActorPreviewSpritesInfo, Requires, Requires { public readonly int MinIdleWaitTicks = 30; @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits [SequenceReference] public readonly string[] IdleSequences = { }; [SequenceReference] public readonly string[] StandSequences = { "stand" }; - public virtual object Create(ActorInitializer init) { return new WithInfantryBody(init, this); } + public override object Create(ActorInitializer init) { return new WithInfantryBody(init, this); } public IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { diff --git a/OpenRA.Mods.Common/Traits/Render/WithMuzzleFlash.cs b/OpenRA.Mods.Common/Traits/Render/WithMuzzleFlash.cs index e768b56f03..01acee6593 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithMuzzleFlash.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithMuzzleFlash.cs @@ -17,12 +17,12 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Renders the MuzzleSequence from the Armament trait.")] - class WithMuzzleFlashInfo : UpgradableTraitInfo, ITraitInfo, Requires, Requires, Requires + class WithMuzzleFlashInfo : UpgradableTraitInfo, Requires, Requires, Requires { [Desc("Ignore the weapon position, and always draw relative to the center of the actor")] public readonly bool IgnoreOffset = false; - public object Create(ActorInitializer init) { return new WithMuzzleFlash(init.Self, this); } + public override object Create(ActorInitializer init) { return new WithMuzzleFlash(init.Self, this); } } class WithMuzzleFlash : UpgradableTrait, INotifyAttack, IRender, ITick diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs index 797312a2d8..3cd3a2414a 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteBody.cs @@ -17,7 +17,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Default trait for rendering sprite-based actors.")] - public class WithSpriteBodyInfo : UpgradableTraitInfo, ITraitInfo, IRenderActorPreviewSpritesInfo, IQuantizeBodyOrientationInfo, + public class WithSpriteBodyInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, IQuantizeBodyOrientationInfo, Requires { [Desc("Animation to play when the actor is created.")] @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Animation to play when the actor is idle.")] [SequenceReference] public readonly string Sequence = "idle"; - public virtual object Create(ActorInitializer init) { return new WithSpriteBody(init, this); } + public override object Create(ActorInitializer init) { return new WithSpriteBody(init, this); } public virtual IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { diff --git a/OpenRA.Mods.Common/Traits/Render/WithTurret.cs b/OpenRA.Mods.Common/Traits/Render/WithTurret.cs index 66580a2537..398a24edc8 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithTurret.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithTurret.cs @@ -17,7 +17,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Renders turrets for units with the Turreted trait.")] - public class WithTurretInfo : UpgradableTraitInfo, ITraitInfo, IRenderActorPreviewSpritesInfo, + public class WithTurretInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires, Requires, Requires { [Desc("Sequence name to use")] @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Render recoil")] public readonly bool Recoils = true; - public object Create(ActorInitializer init) { return new WithTurret(init.Self, this); } + public override object Create(ActorInitializer init) { return new WithTurret(init.Self, this); } public IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) { diff --git a/OpenRA.Mods.Common/Traits/SelfHealing.cs b/OpenRA.Mods.Common/Traits/SelfHealing.cs index 67fab8f8a5..bb4986725b 100644 --- a/OpenRA.Mods.Common/Traits/SelfHealing.cs +++ b/OpenRA.Mods.Common/Traits/SelfHealing.cs @@ -15,14 +15,14 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Attach this to actors which should be able to regenerate their health points.")] - class SelfHealingInfo : UpgradableTraitInfo, ITraitInfo, Requires + class SelfHealingInfo : UpgradableTraitInfo, Requires { public readonly int Step = 5; public readonly int Ticks = 5; public readonly float HealIfBelow = .5f; public readonly int DamageCooldown = 0; - public virtual object Create(ActorInitializer init) { return new SelfHealing(init.Self, this); } + public override object Create(ActorInitializer init) { return new SelfHealing(init.Self, this); } } class SelfHealing : UpgradableTrait, ITick, INotifyDamage diff --git a/OpenRA.Mods.Common/Traits/Sellable.cs b/OpenRA.Mods.Common/Traits/Sellable.cs index ab3bef9bf5..03e889bd47 100644 --- a/OpenRA.Mods.Common/Traits/Sellable.cs +++ b/OpenRA.Mods.Common/Traits/Sellable.cs @@ -17,12 +17,12 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Actor can be sold")] - public class SellableInfo : UpgradableTraitInfo, ITraitInfo + public class SellableInfo : UpgradableTraitInfo { public readonly int RefundPercent = 50; public readonly string[] SellSounds = { }; - public object Create(ActorInitializer init) { return new Sellable(init.Self, this); } + public override object Create(ActorInitializer init) { return new Sellable(init.Self, this); } } public class Sellable : UpgradableTrait, IResolveOrder, IProvideTooltipInfo diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs index edaf6d0849..8e5ce89f40 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs @@ -12,7 +12,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public abstract class SupportPowerInfo : UpgradableTraitInfo, ITraitInfo + public abstract class SupportPowerInfo : UpgradableTraitInfo { [Desc("Measured in seconds.")] public readonly int ChargeTime = 0; @@ -54,7 +54,6 @@ namespace OpenRA.Mods.Common.Traits public readonly int RadarPingDuration = 5 * 25; public readonly string OrderName; - public abstract object Create(ActorInitializer init); public SupportPowerInfo() { OrderName = GetType().Name + "Order"; } } diff --git a/OpenRA.Mods.Common/Traits/Upgrades/DisableUpgrade.cs b/OpenRA.Mods.Common/Traits/Upgrades/DisableUpgrade.cs index 1a567ea310..2e07036146 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/DisableUpgrade.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/DisableUpgrade.cs @@ -15,9 +15,9 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - public class DisableUpgradeInfo : UpgradableTraitInfo, ITraitInfo + public class DisableUpgradeInfo : UpgradableTraitInfo { - public object Create(ActorInitializer init) { return new DisableUpgrade(this); } + public override object Create(ActorInitializer init) { return new DisableUpgrade(this); } } public class DisableUpgrade : UpgradableTrait, IDisable, IDisableMove diff --git a/OpenRA.Mods.Common/Traits/Upgrades/UpgradableTrait.cs b/OpenRA.Mods.Common/Traits/Upgrades/UpgradableTrait.cs index 06e2d4044d..2aeab13948 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/UpgradableTrait.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/UpgradableTrait.cs @@ -15,7 +15,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { /// Use as base class for *Info to subclass of UpgradableTrait. (See UpgradableTrait.) - public abstract class UpgradableTraitInfo + public abstract class UpgradableTraitInfo : IUpgradableInfo { [UpgradeUsedReference] [Desc("The upgrade types which can enable or disable this trait.")] @@ -32,6 +32,8 @@ namespace OpenRA.Mods.Common.Traits [Desc("The maximum upgrade level that this trait will accept.")] public readonly int UpgradeMaxAcceptedLevel = 1; + + public abstract object Create(ActorInitializer init); } /// diff --git a/OpenRA.Mods.Common/Traits/Upgrades/UpgradeManager.cs b/OpenRA.Mods.Common/Traits/Upgrades/UpgradeManager.cs index 09a07cbe50..3817752705 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/UpgradeManager.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/UpgradeManager.cs @@ -19,7 +19,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("Attach this to a unit to enable dynamic upgrades by warheads, experience, crates, support powers, etc.")] - public class UpgradeManagerInfo : ITraitInfo + public class UpgradeManagerInfo : ITraitInfo, Requires { public object Create(ActorInitializer init) { return new UpgradeManager(init); } } diff --git a/OpenRA.Mods.Common/TraitsInterfaces.cs b/OpenRA.Mods.Common/TraitsInterfaces.cs index 5cffc5a85e..5dd5863784 100644 --- a/OpenRA.Mods.Common/TraitsInterfaces.cs +++ b/OpenRA.Mods.Common/TraitsInterfaces.cs @@ -49,6 +49,9 @@ namespace OpenRA.Mods.Common.Traits void UpgradeLevelChanged(Actor self, string type, int oldLevel, int newLevel); } + // Implement to construct before UpgradeManager + public interface IUpgradableInfo : ITraitInfo { } + public interface INotifyHarvesterAction { void MovingToResources(Actor self, CPos targetCell, Activity next); diff --git a/OpenRA.Mods.D2k/Traits/AttractsWorms.cs b/OpenRA.Mods.D2k/Traits/AttractsWorms.cs index 84bac6eda9..e5fbb72d7a 100644 --- a/OpenRA.Mods.D2k/Traits/AttractsWorms.cs +++ b/OpenRA.Mods.D2k/Traits/AttractsWorms.cs @@ -14,7 +14,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.D2k.Traits { [Desc("This actor makes noise, which causes them to be targeted by actors with the Sandworm trait.")] - public class AttractsWormsInfo : UpgradableTraitInfo, ITraitInfo + public class AttractsWormsInfo : UpgradableTraitInfo { [Desc("How much noise this actor produces.")] public readonly int Intensity = 0; @@ -28,7 +28,7 @@ namespace OpenRA.Mods.D2k.Traits [Desc("Ranges at which each Falloff step is defined. Overrides Spread.")] public WRange[] Range = null; - public object Create(ActorInitializer init) { return new AttractsWorms(init, this); } + public override object Create(ActorInitializer init) { return new AttractsWorms(init, this); } } public class AttractsWorms : UpgradableTrait diff --git a/OpenRA.Mods.RA/Traits/InvulnerabilityUpgrade.cs b/OpenRA.Mods.RA/Traits/InvulnerabilityUpgrade.cs index b7e735d07d..d024cf196d 100644 --- a/OpenRA.Mods.RA/Traits/InvulnerabilityUpgrade.cs +++ b/OpenRA.Mods.RA/Traits/InvulnerabilityUpgrade.cs @@ -14,9 +14,9 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - public class InvulnerabilityUpgradeInfo : UpgradableTraitInfo, ITraitInfo + public class InvulnerabilityUpgradeInfo : UpgradableTraitInfo { - public object Create(ActorInitializer init) { return new InvulnerabilityUpgrade(this); } + public override object Create(ActorInitializer init) { return new InvulnerabilityUpgrade(this); } } public class InvulnerabilityUpgrade : UpgradableTrait, IDamageModifier