UpgradeManager after IUpgradables

This commit is contained in:
atlimit8
2015-06-28 10:24:00 -05:00
parent c6c12ee4ac
commit a9908bffb4
26 changed files with 53 additions and 46 deletions

View File

@@ -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<PoisonedByTiberiumInfo>, ITick, ISync

View File

@@ -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<AttackBaseInfo>
public class ArmamentInfo : UpgradableTraitInfo, Requires<AttackBaseInfo>
{
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<ArmamentInfo>, ITick, IExplodeModifier

View File

@@ -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<AttackBaseInfo>, IIssueOrder, IResolveOrder, IOrderVoice, ISync

View File

@@ -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<HealthInfo>
public class RepairableBuildingInfo : UpgradableTraitInfo, Requires<HealthInfo>
{
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<RepairableBuildingInfo>, ITick

View File

@@ -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<CloakInfo>, IRenderModifier, INotifyDamageStateChanged, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier

View File

@@ -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<DetectCloakedInfo>

View File

@@ -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<KillsSelfInfo>, INotifyAddedToWorld

View File

@@ -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<UpgradeOverlayInfo>, IRenderModifier

View File

@@ -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<PowerInfo>
public class CanPowerDownInfo : UpgradableTraitInfo, Requires<PowerInfo>
{
[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<CanPowerDownInfo>, IPowerModifier, IResolveOrder, IDisable, INotifyOwnerChanged

View File

@@ -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<PowerInfo>, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOwnerChanged

View File

@@ -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<UpgradeManager>().RegisterWatcher(info.Upgrade, Update);
}

View File

@@ -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<WithDecorationInfo>, IRender

View File

@@ -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<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
public class WithIdleOverlayInfo : UpgradableTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<IBodyOrientationInfo>
{
[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<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
{

View File

@@ -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<IMoveInfo>, Requires<RenderSpritesInfo>
{
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<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
{

View File

@@ -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<RenderSpritesInfo>, Requires<AttackBaseInfo>, Requires<ArmamentInfo>
class WithMuzzleFlashInfo : UpgradableTraitInfo, Requires<RenderSpritesInfo>, Requires<AttackBaseInfo>, Requires<ArmamentInfo>
{
[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<WithMuzzleFlashInfo>, INotifyAttack, IRender, ITick

View File

@@ -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<RenderSpritesInfo>
{
[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<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
{

View File

@@ -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<RenderSpritesInfo>, Requires<TurretedInfo>, Requires<IBodyOrientationInfo>
{
[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<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p)
{

View File

@@ -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<HealthInfo>
class SelfHealingInfo : UpgradableTraitInfo, Requires<HealthInfo>
{
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<SelfHealingInfo>, ITick, INotifyDamage

View File

@@ -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<SellableInfo>, IResolveOrder, IProvideTooltipInfo

View File

@@ -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"; }
}

View File

@@ -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<DisableUpgradeInfo>, IDisable, IDisableMove

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
/// <summary>Use as base class for *Info to subclass of UpgradableTrait. (See UpgradableTrait.)</summary>
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);
}
/// <summary>

View File

@@ -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<IUpgradableInfo>
{
public object Create(ActorInitializer init) { return new UpgradeManager(init); }
}

View File

@@ -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);

View File

@@ -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<AttractsWormsInfo>

View File

@@ -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<InvulnerabilityUpgradeInfo>, IDamageModifier