Add a lint check for trait placement on hardcoded actor names.

This commit is contained in:
Matthias Mailänder
2021-04-11 14:30:00 +01:00
committed by reaperrr
parent 0d3c624bbc
commit 5a0bcc01a6
129 changed files with 266 additions and 67 deletions

View File

@@ -11,6 +11,7 @@
namespace OpenRA.Traits
{
[TraitLocation(SystemActors.World)]
[Desc("Checks for pause related desyncs. Attach this to the world actor.")]
public class DebugPauseStateInfo : TraitInfo
{

View File

@@ -105,4 +105,14 @@ namespace OpenRA.Traits
PlayerPaletteReferenceSwitch = playerPaletteReferenceSwitch;
}
}
[AttributeUsage(AttributeTargets.Class)]
public sealed class TraitLocationAttribute : Attribute
{
public readonly SystemActors SystemActors;
public TraitLocationAttribute(SystemActors systemActors)
{
SystemActors = systemActors;
}
}
}

View File

@@ -22,6 +22,7 @@ namespace OpenRA.Traits
void OnVisibilityChanged(FrozenActor frozen);
}
[TraitLocation(SystemActors.Player)]
[Desc("Required for FrozenUnderFog to work. Attach this to the player actor.")]
public class FrozenActorLayerInfo : TraitInfo, Requires<ShroudInfo>
{

View File

@@ -14,7 +14,8 @@ using OpenRA.Primitives;
namespace OpenRA.Traits
{
[Desc("Add this to the Player actor definition.")]
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
[Desc("Add this to the World actor definition.")]
public class PlayerColorPaletteInfo : TraitInfo
{
[PaletteReference]

View File

@@ -14,6 +14,7 @@ using System.Collections.Generic;
namespace OpenRA.Traits
{
[TraitLocation(SystemActors.Player | SystemActors.EditorPlayer)]
[Desc("Required for shroud and fog visibility checks. Add this to the player actor.")]
public class ShroudInfo : TraitInfo, ILobbyOptions
{

View File

@@ -11,6 +11,7 @@
namespace OpenRA.Traits
{
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
[Desc("Enables visualization commands. Attach this to the world actor.")]
public class DebugVisualizationsInfo : TraitInfo<DebugVisualizations> { }

View File

@@ -14,6 +14,7 @@ using System.Collections.Generic;
namespace OpenRA.Traits
{
[Desc("Attach this to the `World` actor.")]
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
public class FactionInfo : TraitInfo<Faction>
{
[Desc("This is the name exposed to the players.")]

View File

@@ -30,6 +30,7 @@ namespace OpenRA.Traits
public override string ToString() { return "{0}->{1}".F(Actor.Info.Name, Bounds.GetType().Name); }
}
[TraitLocation(SystemActors.World | SystemActors.EditorWorld)]
public class ScreenMapInfo : TraitInfo
{
[Desc("Size of partition bins (world pixels)")]

View File

@@ -16,6 +16,7 @@ using OpenRA.Graphics;
namespace OpenRA.Traits
{
[TraitLocation(SystemActors.World)]
public class ScreenShakerInfo : TraitInfo
{
public readonly float2 MinMultiplier = new float2(-3, -3);