Replace ITraitInfo interface with TraitInfo class.

This commit is contained in:
Paul Chote
2020-05-11 18:12:19 +01:00
committed by reaperrr
parent 3cd7ec3878
commit 86f61298e6
243 changed files with 510 additions and 505 deletions

View File

@@ -17,14 +17,14 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
[Desc("Display the time remaining until the next cash is given by actor's CashTrickler trait.")]
class CashTricklerBarInfo : ITraitInfo, Requires<CashTricklerInfo>
class CashTricklerBarInfo : TraitInfo, Requires<CashTricklerInfo>
{
[Desc("Defines to which players the bar is to be shown.")]
public readonly Stance DisplayStances = Stance.Ally;
public readonly Color Color = Color.Magenta;
public object Create(ActorInitializer init) { return new CashTricklerBar(init.Self, this); }
public override object Create(ActorInitializer init) { return new CashTricklerBar(init.Self, this); }
}
class CashTricklerBar : ISelectionBar

View File

@@ -18,11 +18,11 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Displays custom terrain types.")]
class CustomTerrainDebugOverlayInfo : ITraitInfo
class CustomTerrainDebugOverlayInfo : TraitInfo
{
public readonly string Font = "TinyBold";
public object Create(ActorInitializer init) { return new CustomTerrainDebugOverlay(init.Self, this); }
public override object Create(ActorInitializer init) { return new CustomTerrainDebugOverlay(init.Self, this); }
}
class CustomTerrainDebugOverlay : IWorldLoaded, IChatCommand, IRenderAnnotations

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Renders target lines between order waypoints.")]
public class DrawLineToTargetInfo : ITraitInfo
public class DrawLineToTargetInfo : TraitInfo
{
[Desc("Delay (in ticks) before the target lines disappear.")]
public readonly int Delay = 60;
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Width (in pixels) of the queued end node markers.")]
public readonly int QueuedMarkerWidth = 2;
public virtual object Create(ActorInitializer init) { return new DrawLineToTarget(init.Self, this); }
public override object Create(ActorInitializer init) { return new DrawLineToTarget(init.Self, this); }
}
public class DrawLineToTarget : IRenderAboveShroud, IRenderAnnotationsWhenSelected, INotifySelected

View File

@@ -17,14 +17,14 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
[Desc("Visualizes the minimum remaining time for reloading the armaments.")]
class ReloadArmamentsBarInfo : ITraitInfo
class ReloadArmamentsBarInfo : TraitInfo
{
[Desc("Armament names")]
public readonly string[] Armaments = { "primary", "secondary" };
public readonly Color Color = Color.Red;
public object Create(ActorInitializer init) { return new ReloadArmamentsBar(init.Self, this); }
public override object Create(ActorInitializer init) { return new ReloadArmamentsBar(init.Self, this); }
}
class ReloadArmamentsBar : ISelectionBar, INotifyCreated

View File

@@ -19,11 +19,11 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
[Desc("Displays the actor's type and ID above the actor.")]
class RenderDebugStateInfo : ITraitInfo
class RenderDebugStateInfo : TraitInfo
{
public readonly string Font = "TinyBold";
public object Create(ActorInitializer init) { return new RenderDebugState(init.Self, this); }
public override object Create(ActorInitializer init) { return new RenderDebugState(init.Self, this); }
}
class RenderDebugState : INotifyAddedToWorld, INotifyOwnerChanged, INotifyCreated, IRenderAnnotationsWhenSelected

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
class RenderDetectionCircleInfo : ITraitInfo, Requires<DetectCloakedInfo>
class RenderDetectionCircleInfo : TraitInfo, Requires<DetectCloakedInfo>
{
[Desc("WAngle the Radar update line advances per tick.")]
public readonly WAngle UpdateLineTick = new WAngle(-1);
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Contrast color of the circle and scanner update line.")]
public readonly Color ContrastColor = Color.FromArgb(96, Color.Black);
public object Create(ActorInitializer init) { return new RenderDetectionCircle(init.Self, this); }
public override object Create(ActorInitializer init) { return new RenderDetectionCircle(init.Self, this); }
}
class RenderDetectionCircle : ITick, IRenderAnnotationsWhenSelected

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public enum RangeCircleMode { Maximum, Minimum }
[Desc("Draw a circle indicating my weapon's range.")]
class RenderRangeCircleInfo : ITraitInfo, IPlaceBuildingDecorationInfo, IRulesetLoaded, Requires<AttackBaseInfo>
class RenderRangeCircleInfo : TraitInfo, IPlaceBuildingDecorationInfo, IRulesetLoaded, Requires<AttackBaseInfo>
{
public readonly string RangeCircleType = null;
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.Common.Traits.Render
return otherRanges.Append(localRange);
}
public object Create(ActorInitializer init) { return new RenderRangeCircle(init.Self, this); }
public override object Create(ActorInitializer init) { return new RenderRangeCircle(init.Self, this); }
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
{

View File

@@ -18,7 +18,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
class RenderShroudCircleInfo : ITraitInfo, IPlaceBuildingDecorationInfo
class RenderShroudCircleInfo : TraitInfo, IPlaceBuildingDecorationInfo
{
[Desc("Color of the circle.")]
public readonly Color Color = Color.FromArgb(128, Color.Cyan);
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
return otherRangeRenderables.Append(localRangeRenderable);
}
public object Create(ActorInitializer init) { return new RenderShroudCircle(init.Self, this); }
public override object Create(ActorInitializer init) { return new RenderShroudCircle(init.Self, this); }
}
class RenderShroudCircle : INotifyCreated, IRenderAnnotationsWhenSelected

View File

@@ -19,13 +19,13 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
public interface IRenderActorPreviewSpritesInfo : ITraitInfo
public interface IRenderActorPreviewSpritesInfo : ITraitInfoInterface
{
IEnumerable<IActorPreview> RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p);
}
[Desc("Render trait fundament that won't work without additional With* render traits.")]
public class RenderSpritesInfo : IRenderActorPreviewInfo, ITraitInfo
public class RenderSpritesInfo : TraitInfo, IRenderActorPreviewInfo
{
[Desc("The sequence name that defines the actor sprites. Defaults to the actor name.")]
public readonly string Image = null;
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Change the sprite image size.")]
public readonly float Scale = 1f;
public virtual object Create(ActorInitializer init) { return new RenderSprites(init, this); }
public override object Create(ActorInitializer init) { return new RenderSprites(init, this); }
public IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init)
{

View File

@@ -19,13 +19,13 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
public interface IRenderActorPreviewVoxelsInfo : ITraitInfo
public interface IRenderActorPreviewVoxelsInfo : ITraitInfoInterface
{
IEnumerable<ModelAnimation> RenderPreviewVoxels(
ActorPreviewInitializer init, RenderVoxelsInfo rv, string image, Func<WRot> orientation, int facings, PaletteReference p);
}
public class RenderVoxelsInfo : ITraitInfo, IRenderActorPreviewInfo, Requires<BodyOrientationInfo>
public class RenderVoxelsInfo : TraitInfo, IRenderActorPreviewInfo, Requires<BodyOrientationInfo>
{
[Desc("Defaults to the actor name.")]
public readonly string Image = null;
@@ -52,7 +52,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public readonly float[] LightAmbientColor = { 0.6f, 0.6f, 0.6f };
public readonly float[] LightDiffuseColor = { 0.4f, 0.4f, 0.4f };
public virtual object Create(ActorInitializer init) { return new RenderVoxels(init.Self, this); }
public override object Create(ActorInitializer init) { return new RenderVoxels(init.Self, this); }
public virtual IEnumerable<IActorPreview> RenderPreview(ActorPreviewInitializer init)
{

View File

@@ -17,11 +17,9 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
public abstract class SelectionDecorationsBaseInfo : ITraitInfo
public abstract class SelectionDecorationsBaseInfo : TraitInfo
{
public readonly Color SelectionBoxColor = Color.White;
public abstract object Create(ActorInitializer init);
}
public abstract class SelectionDecorationsBase : ISelectionDecorations, IRenderAnnotations, INotifyCreated

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
[Desc("Visualizes the remaining time for a condition.")]
class TimedConditionBarInfo : ITraitInfo
class TimedConditionBarInfo : TraitInfo
{
[FieldLoader.Require]
[Desc("Condition that this bar corresponds to")]
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public readonly Color Color = Color.Red;
public object Create(ActorInitializer init) { return new TimedConditionBar(init.Self, this); }
public override object Create(ActorInitializer init) { return new TimedConditionBar(init.Self, this); }
}
class TimedConditionBar : ISelectionBar, IConditionTimerWatcher

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Attach this to the player actor. When attached, enables all actors possessing the ProducibleWithLevel ",
"trait to have their production queue icons render with an overlay defined in this trait. ",
"The icon change occurs when ProducibleWithLevel.Prerequisites are met.")]
public class VeteranProductionIconOverlayInfo : ITraitInfo, Requires<TechTreeInfo>
public class VeteranProductionIconOverlayInfo : TraitInfo, Requires<TechTreeInfo>
{
[FieldLoader.Require]
[Desc("Image used for the overlay.")]
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Palette to render the sprite in. Reference the world actor's PaletteFrom* traits.")]
public readonly string Palette = "chrome";
public object Create(ActorInitializer init) { return new VeteranProductionIconOverlay(init, this); }
public override object Create(ActorInitializer init) { return new VeteranProductionIconOverlay(init, this); }
}
public class VeteranProductionIconOverlay : ITechTreeElement, IProductionIconOverlay

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
[Desc("Rendered together with an attack.")]
public class WithAttackOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
public class WithAttackOverlayInfo : TraitInfo, Requires<RenderSpritesInfo>
{
[SequenceReference]
[FieldLoader.Require]
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Should the overlay be delayed relative to preparation or actual attack?")]
public readonly AttackDelayType DelayRelativeTo = AttackDelayType.Preparation;
public object Create(ActorInitializer init) { return new WithAttackOverlay(init, this); }
public override object Create(ActorInitializer init) { return new WithAttackOverlay(init, this); }
}
public class WithAttackOverlay : INotifyAttack, ITick

View File

@@ -19,7 +19,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
[Desc("Renders crates with both water and land variants.")]
class WithCrateBodyInfo : ITraitInfo, Requires<RenderSpritesInfo>, IRenderActorPreviewSpritesInfo
class WithCrateBodyInfo : TraitInfo, Requires<RenderSpritesInfo>, IRenderActorPreviewSpritesInfo
{
[Desc("Easteregg sequences to use in December.")]
public readonly string[] XmasImages = { };
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[SequenceReference]
public readonly string LandSequence = null;
public object Create(ActorInitializer init) { return new WithCrateBody(init.Self, this); }
public override object Create(ActorInitializer init) { return new WithCrateBody(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.Render
{
[Desc("Renders an overlay when the actor is taking heavy damage.")]
public class WithDamageOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>
public class WithDamageOverlayInfo : TraitInfo, Requires<RenderSpritesInfo>
{
public readonly string Image = "smoke_m";
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits.Render
public readonly DamageState MinimumDamageState = DamageState.Heavy;
public readonly DamageState MaximumDamageState = DamageState.Dead;
public object Create(ActorInitializer init) { return new WithDamageOverlay(init.Self, this); }
public override object Create(ActorInitializer init) { return new WithDamageOverlay(init.Self, this); }
}
public class WithDamageOverlay : INotifyDamage

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
public class WithHarvestAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>, Requires<HarvesterInfo>
public class WithHarvestAnimationInfo : TraitInfo, Requires<WithSpriteBodyInfo>, Requires<HarvesterInfo>
{
[SequenceReference]
[Desc("Displayed while harvesting.")]
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Which sprite body to play the animation on.")]
public readonly string Body = "body";
public object Create(ActorInitializer init) { return new WithHarvestAnimation(init, this); }
public override object Create(ActorInitializer init) { return new WithHarvestAnimation(init, this); }
}
public class WithHarvestAnimation : INotifyHarvesterAction

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
[Desc("Displays an overlay whenever resources are harvested by the actor.")]
class WithHarvestOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
class WithHarvestOverlayInfo : TraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>
{
[SequenceReference]
[Desc("Sequence name to use")]
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[PaletteReference]
public readonly string Palette = "effect";
public object Create(ActorInitializer init) { return new WithHarvestOverlay(init.Self, this); }
public override object Create(ActorInitializer init) { return new WithHarvestOverlay(init.Self, this); }
}
class WithHarvestOverlay : INotifyHarvesterAction

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
[Desc("Replaces the sprite during construction/deploy/undeploy.")]
public class WithMakeAnimationInfo : ITraitInfo, Requires<WithSpriteBodyInfo>
public class WithMakeAnimationInfo : TraitInfo, Requires<WithSpriteBodyInfo>
{
[SequenceReference]
[Desc("Sequence name to use.")]
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Apply to sprite bodies with these names.")]
public readonly string[] BodyNames = { "body" };
public object Create(ActorInitializer init) { return new WithMakeAnimation(init, this); }
public override object Create(ActorInitializer init) { return new WithMakeAnimation(init, this); }
}
public class WithMakeAnimation : INotifyCreated, INotifyDeployTriggered

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
[Desc("Renders Ctrl groups using pixel art.")]
public class WithSpriteControlGroupDecorationInfo : ITraitInfo
public class WithSpriteControlGroupDecorationInfo : TraitInfo
{
[PaletteReference]
public readonly string Palette = "chrome";
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits.Render
[Desc("Offset sprite center position from the selection box edge.")]
public readonly int2 Margin = int2.Zero;
public object Create(ActorInitializer init) { return new WithSpriteControlGroupDecoration(init.Self, this); }
public override object Create(ActorInitializer init) { return new WithSpriteControlGroupDecoration(init.Self, this); }
}
public class WithSpriteControlGroupDecoration : IDecoration

View File

@@ -20,7 +20,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits.Render
{
[Desc("Renders Ctrl groups using typeface.")]
public class WithTextControlGroupDecorationInfo : ITraitInfo, IRulesetLoaded
public class WithTextControlGroupDecorationInfo : TraitInfo, IRulesetLoaded
{
public readonly string Font = "TinyBold";
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits.Render
throw new YamlException("Font '{0}' is not listed in the mod.yaml's Fonts section".F(Font));
}
public object Create(ActorInitializer init) { return new WithTextControlGroupDecoration(init.Self, this); }
public override object Create(ActorInitializer init) { return new WithTextControlGroupDecoration(init.Self, this); }
}
public class WithTextControlGroupDecoration : IDecoration, INotifyOwnerChanged