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

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
{
[Desc("Plays an audio notification and shows a radar ping when a building is attacked.",
"Attach this to the player actor.")]
public class BaseAttackNotifierInfo : ITraitInfo
public class BaseAttackNotifierInfo : TraitInfo
{
[Desc("Minimum duration (in seconds) between notification events.")]
public readonly int NotifyInterval = 30;
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
"Won't play a notification to allies if this is null.")]
public string AllyNotification = null;
public object Create(ActorInitializer init) { return new BaseAttackNotifier(init.Self, this); }
public override object Create(ActorInitializer init) { return new BaseAttackNotifier(init.Self, this); }
}
public class BaseAttackNotifier : INotifyDamage

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public class ConquestVictoryConditionsInfo : ITraitInfo, Requires<MissionObjectivesInfo>
public class ConquestVictoryConditionsInfo : TraitInfo, Requires<MissionObjectivesInfo>
{
[Desc("Delay for the end game notification in milliseconds.")]
public readonly int NotificationDelay = 1500;
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Disable the win/loss messages and audio notifications?")]
public readonly bool SuppressNotifications = false;
public object Create(ActorInitializer init) { return new ConquestVictoryConditions(init.Self, this); }
public override object Create(ActorInitializer init) { return new ConquestVictoryConditions(init.Self, this); }
}
public class ConquestVictoryConditions : ITick, INotifyWinStateChanged, INotifyTimeLimit

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Attach this to the player actor.")]
public class DeveloperModeInfo : ITraitInfo, ILobbyOptions
public class DeveloperModeInfo : TraitInfo, ILobbyOptions
{
[Translate]
[Desc("Descriptive label for the developer mode checkbox in the lobby.")]
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
yield return new LobbyBooleanOption("cheats", CheckboxLabel, CheckboxDescription, CheckboxVisible, CheckboxDisplayOrder, CheckboxEnabled, CheckboxLocked);
}
public object Create(ActorInitializer init) { return new DeveloperMode(this); }
public override object Create(ActorInitializer init) { return new DeveloperMode(this); }
}
public class DeveloperMode : IResolveOrder, ISync, INotifyCreated, IUnlocksRenderPlayer

View File

@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("A placeholder bot that doesn't do anything.")]
public sealed class DummyBotInfo : ITraitInfo, IBotInfo
public sealed class DummyBotInfo : TraitInfo, IBotInfo
{
[Desc("Human-readable name this bot uses.")]
public readonly string Name = "Unnamed Bot";
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
string IBotInfo.Name { get { return Name; } }
public object Create(ActorInitializer init) { return new DummyBot(this); }
public override object Create(ActorInitializer init) { return new DummyBot(this); }
}
public sealed class DummyBot : IBot

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
{
[Desc("Tracks neutral and enemy actors' visibility and notifies the player.",
"Attach this to the player actor. The actors to track need the 'AnnounceOnSeen' trait.")]
class EnemyWatcherInfo : ITraitInfo
class EnemyWatcherInfo : TraitInfo
{
[Desc("Interval in ticks between scanning for enemies.")]
public readonly int ScanInterval = 25;
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Minimal ticks in-between notifications.")]
public readonly int NotificationInterval = 750;
public object Create(ActorInitializer init) { return new EnemyWatcher(this); }
public override object Create(ActorInitializer init) { return new EnemyWatcher(this); }
}
class EnemyWatcher : ITick

View File

@@ -17,9 +17,9 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Attach this to the player actor.")]
public class GrantConditionOnPrerequisiteManagerInfo : ITraitInfo, Requires<TechTreeInfo>
public class GrantConditionOnPrerequisiteManagerInfo : TraitInfo, Requires<TechTreeInfo>
{
public object Create(ActorInitializer init) { return new GrantConditionOnPrerequisiteManager(init); }
public override object Create(ActorInitializer init) { return new GrantConditionOnPrerequisiteManager(init); }
}
public class GrantConditionOnPrerequisiteManager : ITechTreeElement

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits
{
[Desc("Plays an audio notification and shows a radar ping when a harvester is attacked.",
"Attach this to the player actor.")]
public class HarvesterAttackNotifierInfo : ITraitInfo
public class HarvesterAttackNotifierInfo : TraitInfo
{
[Desc("Minimum duration (in seconds) between notification events.")]
public readonly int NotifyInterval = 30;
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("The audio notification type to play.")]
public string Notification = "HarvesterAttack";
public object Create(ActorInitializer init) { return new HarvesterAttackNotifier(init.Self, this); }
public override object Create(ActorInitializer init) { return new HarvesterAttackNotifier(init.Self, this); }
}
public class HarvesterAttackNotifier : INotifyDamage

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
public class MissionObjectivesInfo : ITraitInfo
public class MissionObjectivesInfo : TraitInfo
{
[Desc("Set this to true if multiple cooperative players have a distinct set of " +
"objectives that each of them has to complete to win the game. This is mainly " +
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
[NotificationReference("Speech")]
public readonly string LeaveNotification = null;
public object Create(ActorInitializer init) { return new MissionObjectives(init.World, this); }
public override object Create(ActorInitializer init) { return new MissionObjectives(init.World, this); }
}
public class MissionObjectives : INotifyWinStateChanged, ISync, IResolveOrder
@@ -259,14 +259,14 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Provides game mode progress information for players.",
"Goes on WorldActor - observers don't have a player it can live on.",
"Current options for PanelName are 'SKIRMISH_STATS' and 'MISSION_OBJECTIVES'.")]
public class ObjectivesPanelInfo : ITraitInfo
public class ObjectivesPanelInfo : TraitInfo
{
public string PanelName = null;
[Desc("in ms")]
public int ExitDelay = 1400;
public object Create(ActorInitializer init) { return new ObjectivesPanel(this); }
public override object Create(ActorInitializer init) { return new ObjectivesPanel(this); }
}
public class ObjectivesPanel : IObjectivesPanel

View File

@@ -19,7 +19,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Bot that uses BotModules.")]
public sealed class ModularBotInfo : IBotInfo, ITraitInfo
public sealed class ModularBotInfo : TraitInfo, IBotInfo
{
[FieldLoader.Require]
[Desc("Internal id for this bot.")]
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
string IBotInfo.Name { get { return Name; } }
public object Create(ActorInitializer init) { return new ModularBot(this, init); }
public override object Create(ActorInitializer init) { return new ModularBot(this, init); }
}
public sealed class ModularBot : ITick, IBot, INotifyDamage

View File

@@ -15,7 +15,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("A beacon that is constructed from a circle sprite that is animated once and a moving arrow sprite.")]
public class PlaceBeaconInfo : ITraitInfo
public class PlaceBeaconInfo : TraitInfo
{
public readonly int Duration = 30 * 25;
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Traits
[SequenceReference("BeaconImage")]
public readonly string CircleSequence = "circles";
public object Create(ActorInitializer init) { return new PlaceBeacon(init.Self, this); }
public override object Create(ActorInitializer init) { return new PlaceBeacon(init.Self, this); }
}
public class PlaceBeacon : IResolveOrder

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Traits
public class PlaceBuildingInit : IActorInit { }
[Desc("Allows the player to execute build orders.", " Attach this to the player actor.")]
public class PlaceBuildingInfo : ITraitInfo
public class PlaceBuildingInfo : TraitInfo
{
[Desc("Play NewOptionsNotification this many ticks after building placement.")]
public readonly int NewOptionsNotificationDelay = 10;
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Hotkey to toggle between PlaceBuildingVariants when placing a structure.")]
public HotkeyReference ToggleVariantKey = new HotkeyReference();
public object Create(ActorInitializer init) { return new PlaceBuilding(this); }
public override object Create(ActorInitializer init) { return new PlaceBuilding(this); }
}
public class PlaceBuilding : IResolveOrder, ITick

View File

@@ -16,9 +16,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("This trait can be used to track player experience based on units killed with the `GivesExperience` trait.",
"It can also be used as a point score system in scripted maps, for example.",
"Attach this to the player actor.")]
public class PlayerExperienceInfo : ITraitInfo
public class PlayerExperienceInfo : TraitInfo
{
public object Create(ActorInitializer init) { return new PlayerExperience(); }
public override object Create(ActorInitializer init) { return new PlayerExperience(); }
}
public class PlayerExperience : ISync

View File

@@ -17,9 +17,9 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public class PlayerRadarTerrainInfo : ITraitInfo, Requires<ShroudInfo>
public class PlayerRadarTerrainInfo : TraitInfo, Requires<ShroudInfo>
{
public object Create(ActorInitializer init)
public override object Create(ActorInitializer init)
{
return new PlayerRadarTerrain(init.Self);
}

View File

@@ -16,7 +16,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public class PlayerResourcesInfo : ITraitInfo, ILobbyOptions
public class PlayerResourcesInfo : TraitInfo, ILobbyOptions
{
[Translate]
[Desc("Descriptive label for the starting cash option in the lobby.")]
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
new ReadOnlyDictionary<string, string>(startingCash), DefaultCash.ToString(), DefaultCashDropdownLocked);
}
public object Create(ActorInitializer init) { return new PlayerResources(init.Self, this); }
public override object Create(ActorInitializer init) { return new PlayerResources(init.Self, this); }
}
public class PlayerResources : ISync

View File

@@ -20,9 +20,9 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Attach this to the player actor to collect observer stats.")]
public class PlayerStatisticsInfo : ITraitInfo
public class PlayerStatisticsInfo : TraitInfo
{
public object Create(ActorInitializer init) { return new PlayerStatistics(init.Self); }
public override object Create(ActorInitializer init) { return new PlayerStatistics(init.Self); }
}
public class PlayerStatistics : ITick, IResolveOrder, INotifyCreated, IWorldLoaded
@@ -200,7 +200,7 @@ namespace OpenRA.Mods.Common.Traits
}
[Desc("Attach this to a unit to update observer stats.")]
public class UpdatesPlayerStatisticsInfo : ITraitInfo
public class UpdatesPlayerStatisticsInfo : TraitInfo
{
[Desc("Add to army value in statistics")]
public bool AddToArmyValue = false;
@@ -209,7 +209,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Count this actor as a different type in the spectator army display.")]
public string OverrideActor = null;
public object Create(ActorInitializer init) { return new UpdatesPlayerStatistics(this, init.Self); }
public override object Create(ActorInitializer init) { return new UpdatesPlayerStatistics(this, init.Self); }
}
public class UpdatesPlayerStatistics : INotifyKilled, INotifyCreated, INotifyOwnerChanged, INotifyActorDisposing

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Attach this to an actor (usually a building) to let it produce units or construct buildings.",
"If one builds another actor of this type, he will get a separate queue to create two actors",
"at the same time. Will only work together with the Production: trait.")]
public class ProductionQueueInfo : ITraitInfo
public class ProductionQueueInfo : TraitInfo
{
[FieldLoader.Require]
[Desc("What kind of production will be added (e.g. Building, Infantry, Vehicle, ...)")]
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
"The filename of the audio is defined per faction in notifications.yaml.")]
public readonly string CancelledAudio = null;
public virtual object Create(ActorInitializer init) { return new ProductionQueue(init, init.Self.Owner.PlayerActor, this); }
public override object Create(ActorInitializer init) { return new ProductionQueue(init, init.Self.Owner.PlayerActor, this); }
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
{

View File

@@ -10,10 +10,11 @@
#endregion
using System.Collections.Generic;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public class ProvidesTechPrerequisiteInfo : ITechTreePrerequisiteInfo
public class ProvidesTechPrerequisiteInfo : TraitInfo, ITechTreePrerequisiteInfo
{
[Desc("Internal id for this tech level.")]
public readonly string Id;
@@ -27,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<string> ITechTreePrerequisiteInfo.Prerequisites(ActorInfo info) { return Prerequisites; }
public object Create(ActorInitializer init) { return new ProvidesTechPrerequisite(this, init); }
public override object Create(ActorInitializer init) { return new ProvidesTechPrerequisite(this, init); }
}
public class ProvidesTechPrerequisite : ITechTreePrerequisite

View File

@@ -14,7 +14,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Provides the player with an audible warning when their storage is nearing full.")]
public class ResourceStorageWarningInfo : ITraitInfo, Requires<PlayerResourcesInfo>
public class ResourceStorageWarningInfo : TraitInfo, Requires<PlayerResourcesInfo>
{
[Desc("Interval, in seconds, at which to check if more storage is needed.")]
public readonly int AdviceInterval = 20;
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("The speech to play for the warning.")]
public readonly string Notification = "SilosNeeded";
public object Create(ActorInitializer init) { return new ResourceStorageWarning(init.Self, this); }
public override object Create(ActorInitializer init) { return new ResourceStorageWarning(init.Self, this); }
}
public class ResourceStorageWarning : ITick

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
public class StrategicPoint { }
[Desc("Allows King of the Hill (KotH) style gameplay.")]
public class StrategicVictoryConditionsInfo : ITraitInfo, Requires<MissionObjectivesInfo>
public class StrategicVictoryConditionsInfo : TraitInfo, Requires<MissionObjectivesInfo>
{
[Desc("Amount of time (in game ticks) that the player has to hold all the strategic points.", "Defaults to 7500 ticks (5 minutes at default speed).")]
public readonly int HoldDuration = 7500;
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Disable the win/loss messages and audio notifications?")]
public readonly bool SuppressNotifications = false;
public object Create(ActorInitializer init) { return new StrategicVictoryConditions(init.Self, this); }
public override object Create(ActorInitializer init) { return new StrategicVictoryConditions(init.Self, this); }
}
public class StrategicVictoryConditions : ITick, ISync, INotifyWinStateChanged, INotifyTimeLimit

View File

@@ -18,9 +18,9 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Manages build limits and pre-requisites.", " Attach this to the player actor.")]
public class TechTreeInfo : ITraitInfo
public class TechTreeInfo : TraitInfo
{
public object Create(ActorInitializer init) { return new TechTree(init); }
public override object Create(ActorInitializer init) { return new TechTree(init); }
}
public class TechTree

View File

@@ -20,7 +20,7 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Traits
{
[Desc("This trait allows setting a time limit on matches. Attach this to the World actor.")]
public class TimeLimitManagerInfo : ITraitInfo, ILobbyOptions, IRulesetLoaded
public class TimeLimitManagerInfo : TraitInfo, ILobbyOptions, IRulesetLoaded
{
[Desc("Label that will be shown for the time limit option in the lobby.")]
public readonly string TimeLimitLabel = "Time Limit";
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.Common.Traits
new ReadOnlyDictionary<string, string>(timelimits), TimeLimitDefault.ToString(), TimeLimitLocked);
}
public object Create(ActorInitializer init) { return new TimeLimitManager(init.Self, this); }
public override object Create(ActorInitializer init) { return new TimeLimitManager(init.Self, this); }
}
public class TimeLimitManager : INotifyTimeLimit, ITick, IWorldLoaded