Add a lint check for trait placement on hardcoded actor names.
This commit is contained in:
committed by
reaperrr
parent
0d3c624bbc
commit
5a0bcc01a6
@@ -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