Add a lint check for trait placement on hardcoded actor names.
This commit is contained in:
committed by
reaperrr
parent
0d3c624bbc
commit
5a0bcc01a6
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
if (!rules.Actors["world"].HasTraitInfo<ITiledTerrainRendererInfo>())
|
||||
if (!rules.Actors[SystemActors.World].HasTraitInfo<ITiledTerrainRendererInfo>())
|
||||
throw new YamlException("Bridge requires a tile-based terrain renderer.");
|
||||
|
||||
if (string.IsNullOrEmpty(DemolishWeapon))
|
||||
|
||||
@@ -14,6 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("A dictionary of buildings placed on the map. Attach this to the world actor.")]
|
||||
public class BuildingInfluenceInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
var locomotorInfos = rules.Actors["world"].TraitInfos<LocomotorInfo>();
|
||||
var locomotorInfos = rules.Actors[SystemActors.World].TraitInfos<LocomotorInfo>();
|
||||
LocomotorInfo = locomotorInfos.FirstOrDefault(li => li.Name == Locomotor);
|
||||
if (LocomotorInfo == null)
|
||||
throw new YamlException("A locomotor named '{0}' doesn't exist.".F(Locomotor));
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public override void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
var locomotorInfos = rules.Actors["world"].TraitInfos<LocomotorInfo>();
|
||||
var locomotorInfos = rules.Actors[SystemActors.World].TraitInfos<LocomotorInfo>();
|
||||
LocomotorInfo = locomotorInfos.FirstOrDefault(li => li.Name == Locomotor);
|
||||
if (LocomotorInfo == null)
|
||||
throw new YamlException("A locomotor named '{0}' doesn't exist.".F(Locomotor));
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var map = init.World.Map;
|
||||
|
||||
// Explore map-placed actors if the "Explore Map" option is enabled
|
||||
var shroudInfo = init.World.Map.Rules.Actors["player"].TraitInfo<ShroudInfo>();
|
||||
var shroudInfo = init.World.Map.Rules.Actors[SystemActors.Player].TraitInfo<ShroudInfo>();
|
||||
var exploredMap = init.World.LobbyInfo.GlobalSettings.OptionOrDefault("explored", shroudInfo.ExploredMapCheckboxEnabled);
|
||||
startsRevealed = exploredMap && init.Contains<SpawnedByMapInit>() && !init.Contains<HiddenUnderFogInit>();
|
||||
var buildingInfo = init.Self.Info.TraitInfoOrDefault<BuildingInfo>();
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
using GUtil = OpenRA.Graphics.Util;
|
||||
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Used for bursted one-colored whole screen effects. Add this to the world actor.")]
|
||||
public class FlashPaletteEffectInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Fades the world from/to black at the start/end of the game, and can (optionally) desaturate the world")]
|
||||
public class MenuPaletteEffectInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Palette effect used for sprinkle \"animations\".")]
|
||||
class RotationPaletteEffectInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Attach this to the player actor to allow building repair by team mates.")]
|
||||
class AllyRepairInfo : TraitInfo<AllyRepair> { }
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Plays an audio notification and shows a radar ping when a building is attacked.",
|
||||
"Attach this to the player actor.")]
|
||||
public class BaseAttackNotifierInfo : TraitInfo
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
"Will only work together with the Production: trait on the actor that actually does the production.",
|
||||
"You will also want to add PrimaryBuildings: to let the user choose where new units should exit.",
|
||||
"The production speed depends on the number of production buildings and units queued at the same time.")]
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
public class ClassicParallelProductionQueueInfo : ProductionQueueInfo, Requires<TechTreeInfo>, Requires<PlayerResourcesInfo>
|
||||
{
|
||||
[Desc("If you build more actors of the same type,", "the same queue will get its build time lowered for every actor produced there.")]
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Attach this to the player actor (not a building!) to define a new shared build queue.",
|
||||
"Will only work together with the Production: trait on the actor that actually does the production.",
|
||||
"You will also want to add PrimaryBuildings: to let the user choose where new units should exit.")]
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Network;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
public class ConquestVictoryConditionsInfo : TraitInfo, Requires<MissionObjectivesInfo>
|
||||
{
|
||||
[Desc("Delay for the end game notification in milliseconds.")]
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Attach this to the player actor.")]
|
||||
public class DeveloperModeInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[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 : TraitInfo
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Attach this to the player actor.")]
|
||||
public class GrantConditionOnPrerequisiteManagerInfo : TraitInfo, Requires<TechTreeInfo>
|
||||
{
|
||||
|
||||
@@ -16,6 +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.")]
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
public class HarvesterAttackNotifierInfo : TraitInfo
|
||||
{
|
||||
[Desc("Minimum duration (in seconds) between notification events.")]
|
||||
|
||||
@@ -35,6 +35,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
public class MissionObjectivesInfo : TraitInfo
|
||||
{
|
||||
[Desc("Set this to true if multiple cooperative players have a distinct set of " +
|
||||
@@ -258,6 +259,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[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'.")]
|
||||
@@ -271,6 +273,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public override object Create(ActorInitializer init) { return new ObjectivesPanel(this); }
|
||||
}
|
||||
|
||||
[TraitLocation(SystemActors.World)]
|
||||
public class ObjectivesPanel : IObjectivesPanel
|
||||
{
|
||||
readonly ObjectivesPanelInfo info;
|
||||
|
||||
@@ -14,6 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("A beacon that is constructed from a circle sprite that is animated once and a moving arrow sprite.")]
|
||||
public class PlaceBeaconInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Allows third party mods to detect whether an actor was created by PlaceBuilding.
|
||||
public class PlaceBuildingInit : RuntimeFlagInit { }
|
||||
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Allows the player to execute build orders.", " Attach this to the player actor.")]
|
||||
public class PlaceBuildingInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[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.")]
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
|
||||
using System;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
public class PlayerRadarTerrainInfo : TraitInfo, Requires<ShroudInfo>
|
||||
{
|
||||
public override object Create(ActorInitializer init)
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player | SystemActors.EditorPlayer)]
|
||||
public class PlayerResourcesInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
[Desc("Descriptive label for the starting cash option in the lobby.")]
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Attach this to the player actor to collect observer stats.")]
|
||||
public class PlayerStatisticsInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
public class ProvidesTechPrerequisiteInfo : TraitInfo, ITechTreePrerequisiteInfo
|
||||
{
|
||||
[Desc("Internal id for this tech level.")]
|
||||
|
||||
@@ -13,6 +13,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Provides the player with an audible warning when their storage is nearing full.")]
|
||||
public class ResourceStorageWarningInfo : TraitInfo, Requires<PlayerResourcesInfo>
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Manages build limits and pre-requisites.", " Attach this to the player actor.")]
|
||||
public class TechTreeInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("This trait allows setting a time limit on matches. Attach this to the World actor.")]
|
||||
public class TimeLimitManagerInfo : TraitInfo, ILobbyOptions, IRulesetLoaded
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Attach this to the player actor.")]
|
||||
public class PowerManagerInfo : TraitInfo, Requires<DeveloperModeInfo>
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
class ProductionQueueFromSelectionInfo : TraitInfo
|
||||
{
|
||||
public string ProductionTabsWidget = null;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo info)
|
||||
{
|
||||
var pci = rules.Actors["player"].TraitInfoOrDefault<ProximityCaptorInfo>();
|
||||
var pci = rules.Actors[SystemActors.Player].TraitInfoOrDefault<ProximityCaptorInfo>();
|
||||
if (pci == null)
|
||||
throw new YamlException("ProximityCapturable requires the `Player` actor to have the ProximityCaptor trait.");
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Displays custom terrain types.")]
|
||||
class CustomTerrainDebugOverlayInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
// No queues available - check for classic production queues
|
||||
if (queue == null)
|
||||
queue = rules.Actors["player"].TraitInfos<ProductionQueueInfo>().FirstOrDefault(q => ProductionType == q.Type);
|
||||
queue = rules.Actors[SystemActors.Player].TraitInfos<ProductionQueueInfo>().FirstOrDefault(q => ProductionType == q.Type);
|
||||
|
||||
if (queue == null)
|
||||
throw new YamlException("Can't find a queue with ProductionType '{0}'".F(ProductionType));
|
||||
|
||||
@@ -15,6 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[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.")]
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Attach this to the player actor.")]
|
||||
public class SupportPowerManagerInfo : TraitInfo, Requires<DeveloperModeInfo>, Requires<TechTreeInfo>
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void RulesetLoaded(Ruleset rules, ActorInfo ai)
|
||||
{
|
||||
if (!rules.Actors["world"].HasTraitInfo<TerrainLightingInfo>())
|
||||
if (!rules.Actors[SystemActors.World].HasTraitInfo<TerrainLightingInfo>())
|
||||
throw new YamlException("TerrainLightSource can only be used with the world TerrainLighting trait.");
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
public class ActorMapInfo : TraitInfo
|
||||
{
|
||||
[Desc("Size of partition bins (cells)")]
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Controls the spawning of specified actor types. Attach this to the world actor.")]
|
||||
[TraitLocation(SystemActors.World)]
|
||||
public class ActorSpawnManagerInfo : ConditionalTraitInfo, Requires<MapCreepsInfo>
|
||||
{
|
||||
[Desc("Minimum number of actors.")]
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
public class CrateSpawnerInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
[Desc("Descriptive label for the crates checkbox in the lobby.")]
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Attach this to the world actor.")]
|
||||
public class CreateMapPlayersInfo : TraitInfo<CreateMapPlayers>, ICreatePlayersInfo
|
||||
{
|
||||
@@ -27,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
/// </summary>
|
||||
void ICreatePlayersInfo.CreateServerPlayers(MapPreview map, Session lobbyInfo, List<GameInformation.Player> players, MersenneTwister playerRandom)
|
||||
{
|
||||
var worldInfo = map.Rules.Actors["world"];
|
||||
var worldInfo = map.Rules.Actors[SystemActors.World];
|
||||
var factions = worldInfo.TraitInfos<FactionInfo>().ToArray();
|
||||
var assignSpawnLocations = worldInfo.TraitInfoOrDefault<IAssignSpawnPointsInfo>();
|
||||
var spawnState = assignSpawnLocations?.InitializeState(map, lobbyInfo);
|
||||
@@ -41,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
// Create the regular playable players.
|
||||
var bots = map.Rules.Actors["player"].TraitInfos<IBotInfo>().ToArray();
|
||||
var bots = map.Rules.Actors[SystemActors.Player].TraitInfos<IBotInfo>().ToArray();
|
||||
|
||||
foreach (var kv in lobbyInfo.Slots)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Identify untraversable regions of the map for faster pathfinding, especially with AI.",
|
||||
"This trait is required. Every mod needs it attached to the world actor.")]
|
||||
class DomainIndexInfo : TraitInfo<DomainIndex> { }
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.EditorWorld)]
|
||||
public class EditorActionManagerInfo : TraitInfo<EditorActionManager> { }
|
||||
|
||||
public class EditorActionManager : IWorldLoaded
|
||||
|
||||
@@ -21,6 +21,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.EditorWorld)]
|
||||
[Desc("Required for the map editor to work. Attach this to the world actor.")]
|
||||
public class EditorActorLayerInfo : TraitInfo, ICreatePlayersInfo
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
public enum EditorCursorType { None, Actor, TerrainTemplate, Resource }
|
||||
|
||||
[TraitLocation(SystemActors.EditorWorld)]
|
||||
[Desc("Required for the map editor to work. Attach this to the world actor.")]
|
||||
public class EditorCursorLayerInfo : TraitInfo, Requires<EditorActorLayerInfo>, Requires<ITiledTerrainRendererInfo>
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.EditorWorld)]
|
||||
[Desc("Required for the map editor to work. Attach this to the world actor.")]
|
||||
public class EditorResourceLayerInfo : TraitInfo, IResourceLayerInfo, IMapPreviewSignatureInfo
|
||||
{
|
||||
@@ -94,7 +95,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (w.Type != WorldType.Editor)
|
||||
return;
|
||||
|
||||
var playerResourcesInfo = w.Map.Rules.Actors["player"].TraitInfoOrDefault<PlayerResourcesInfo>();
|
||||
var playerResourcesInfo = w.Map.Rules.Actors[SystemActors.Player].TraitInfoOrDefault<PlayerResourcesInfo>();
|
||||
resourceValues = playerResourcesInfo?.ResourceValues ?? new Dictionary<string, int>();
|
||||
|
||||
foreach (var cell in Map.AllCells)
|
||||
|
||||
@@ -15,6 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.EditorWorld)]
|
||||
[Desc("Required for the map editor to work. Attach this to the world actor.")]
|
||||
public class EditorSelectionLayerInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
public class GameSaveViewportManagerInfo : TraitInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new GameSaveViewportManager(); }
|
||||
|
||||
@@ -17,6 +17,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Define a palette by swapping palette indices.")]
|
||||
public class IndexedPaletteInfo : TraitInfo, IRulesetLoaded
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
class LegacyBridgeLayerInfo : TraitInfo
|
||||
{
|
||||
[ActorReference]
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
public class LoadWidgetAtGameStartInfo : TraitInfo
|
||||
{
|
||||
[Desc("The widget tree to open when a shellmap is loaded (i.e. the main menu).")]
|
||||
|
||||
@@ -14,6 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.Player)]
|
||||
[Desc("Enables defined prerequisites at game start for all players if the checkbox is enabled.")]
|
||||
public class LobbyPrerequisiteCheckboxInfo : TraitInfo, ILobbyOptions, ITechTreePrerequisiteInfo
|
||||
{
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public const byte ElevatedBridge = 4;
|
||||
}
|
||||
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Used by Mobile. Attach these to the world actor. You can have multiple variants by adding @suffixes.")]
|
||||
public class LocomotorInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Controls the build radius checkboxes in the lobby options.")]
|
||||
public class MapBuildRadiusInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Controls the 'Creeps' checkbox in the lobby options.")]
|
||||
[TraitLocation(SystemActors.World)]
|
||||
public class MapCreepsInfo : TraitInfo, ILobbyOptions
|
||||
{
|
||||
[Desc("Descriptive label for the creeps checkbox in the lobby.")]
|
||||
|
||||
@@ -15,6 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Controls the game speed, tech level, and short game lobby options.")]
|
||||
public class MapOptionsInfo : TraitInfo, ILobbyOptions, IRulesetLoaded
|
||||
{
|
||||
@@ -77,7 +78,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
yield return new LobbyBooleanOption("shortgame", ShortGameCheckboxLabel, ShortGameCheckboxDescription,
|
||||
ShortGameCheckboxVisible, ShortGameCheckboxDisplayOrder, ShortGameCheckboxEnabled, ShortGameCheckboxLocked);
|
||||
|
||||
var techLevels = rules.Actors["player"].TraitInfos<ProvidesTechPrerequisiteInfo>()
|
||||
var techLevels = rules.Actors[SystemActors.Player].TraitInfos<ProvidesTechPrerequisiteInfo>()
|
||||
.ToDictionary(t => t.Id, t => t.Name);
|
||||
|
||||
if (techLevels.Any())
|
||||
|
||||
@@ -19,6 +19,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Allows the map to have working spawnpoints. Also controls the 'Separate Team Spawns' checkbox in the lobby options.")]
|
||||
public class MapStartingLocationsInfo : TraitInfo, ILobbyOptions, IAssignSpawnPointsInfo
|
||||
{
|
||||
|
||||
@@ -14,6 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Used by SpawnStartingUnits. Attach these to the world actor. You can have multiple variants by adding @suffixes.")]
|
||||
public class StartingUnitsInfo : TraitInfo<StartingUnits>
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Trait for music handling. Attach this to the world actor.")]
|
||||
public class MusicPlaylistInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Load VGA palette (.pal) registers.")]
|
||||
class PaletteFromFileInfo : TraitInfo, IProvidesCursorPaletteInfo
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Load a GIMP .gpl or JASC .pal palette file. Supports per-color alpha.")]
|
||||
class PaletteFromGimpOrJascFileInfo : TraitInfo, IProvidesCursorPaletteInfo
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Create a palette by applying alpha transparency to another palette.")]
|
||||
class PaletteFromPaletteWithAlphaInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Create player palettes by applying alpha transparency to another player palette.")]
|
||||
class PaletteFromPlayerPaletteWithAlphaInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Load a PNG and use its embedded palette.")]
|
||||
class PaletteFromPngInfo : TraitInfo, IProvidesCursorPaletteInfo
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Creates a single color palette without any base palette file.")]
|
||||
class PaletteFromRGBAInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Calculates routes for mobile units based on the A* search algorithm.", " Attach this to the world actor.")]
|
||||
public class PathFinderInfo : TraitInfo, Requires<LocomotorInfo>
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
public class RadarPingsInfo : TraitInfo
|
||||
{
|
||||
public readonly int FromRadius = 200;
|
||||
|
||||
@@ -15,6 +15,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Allows harvesters to coordinate their operations. Attach this to the world actor.")]
|
||||
public sealed class ResourceClaimLayerInfo : TraitInfo<ResourceClaimLayer> { }
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Attach this to the world actor.")]
|
||||
public class ResourceLayerInfo : TraitInfo, IResourceLayerInfo, Requires<BuildingInfluenceInfo>, IMapPreviewSignatureInfo
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Visualizes the state of the `ResourceLayer`.", " Attach this to the world actor.")]
|
||||
public class ResourceRendererInfo : TraitInfo, Requires<IResourceLayerInfo>
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public override object Create(ActorInitializer init) { return new Selection(this); }
|
||||
}
|
||||
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
public class Selection : ISelection, INotifyCreated, INotifyOwnerChanged, ITick, IGameSaveTraitData
|
||||
{
|
||||
public int Hash { get; private set; }
|
||||
|
||||
@@ -19,6 +19,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
public class ShroudRendererInfo : TraitInfo
|
||||
{
|
||||
public readonly string Sequence = "shroud";
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public int Depth;
|
||||
}
|
||||
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Attach this to the world actor.", "Order of the layers defines the Z sorting.")]
|
||||
public class SmudgeLayerInfo : TraitInfo
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Spawns the initial units for each player upon game start.")]
|
||||
public class SpawnMapActorsInfo : TraitInfo<SpawnMapActors> { }
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Spawn base actor at the spawnpoint and support units in an annulus around the base actor. Both are defined at MPStartUnits. Attach this to the world actor.")]
|
||||
public class SpawnStartingUnitsInfo : TraitInfo, Requires<StartingUnitsInfo>, ILobbyOptions
|
||||
{
|
||||
@@ -43,7 +44,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var startingUnits = new Dictionary<string, string>();
|
||||
|
||||
// Duplicate classes are defined for different race variants
|
||||
foreach (var t in rules.Actors["world"].TraitInfos<StartingUnitsInfo>())
|
||||
foreach (var t in rules.Actors[SystemActors.World].TraitInfos<StartingUnitsInfo>())
|
||||
startingUnits[t.Class] = t.ClassName;
|
||||
|
||||
if (startingUnits.Any())
|
||||
@@ -75,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var spawnClass = p.PlayerReference.StartingUnitsClass ?? w.LobbyInfo.GlobalSettings
|
||||
.OptionOrDefault("startingunits", info.StartingUnitsClass);
|
||||
|
||||
var unitGroup = w.Map.Rules.Actors["world"].TraitInfos<StartingUnitsInfo>()
|
||||
var unitGroup = w.Map.Rules.Actors[SystemActors.World].TraitInfos<StartingUnitsInfo>()
|
||||
.Where(g => g.Class == spawnClass && g.Factions != null && g.Factions.Contains(p.Faction.InternalName))
|
||||
.RandomOrDefault(w.SharedRandom);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
class StartGameNotificationInfo : TraitInfo
|
||||
{
|
||||
[NotificationReference("Speech")]
|
||||
|
||||
@@ -18,6 +18,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
[Desc("Renders a debug overlay showing the terrain cells. Attach this to the world actor.")]
|
||||
public class TerrainGeometryOverlayInfo : TraitInfo<TerrainGeometryOverlay> { }
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
|
||||
public class TerrainRendererInfo : TraitInfo, ITiledTerrainRendererInfo
|
||||
{
|
||||
bool ITiledTerrainRendererInfo.ValidateTileSprites(ITemplatedTerrainInfo terrainInfo, Action<string> onError)
|
||||
|
||||
@@ -14,6 +14,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Used to detect exploits. Attach this to the world actor.")]
|
||||
public class ValidateOrderInfo : TraitInfo<ValidateOrder> { }
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[TraitLocation(SystemActors.World)]
|
||||
[Desc("Part of the combat overlay from DeveloperMode. Attach this to the world actor.")]
|
||||
public class WarheadDebugOverlayInfo : TraitInfo
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user