/// /// Adds a single or multiple tags for this type or member. Tags can then be retrieved via DisplayInfo library. /// public class TagAttribute : Attribute { /// /// The tags to add for this type or member. /// public string[] Value { get; private set; } public TagAttribute( params string[] tag ) { Value = tag; } /// /// Returns all the tags as an enumerable. /// /// public IEnumerable EnumerateValues() { foreach ( var tag in Value ) { yield return tag; } } } /// /// Alternate class name(s) for this type to the one specified via LibraryAttribute. This info can then be retrieved via DisplayInfo library. /// public class AliasAttribute : Attribute, IUninheritable { /// /// The aliases for this class. /// public string[] Value { get; private set; } public AliasAttribute( params string[] tag ) { Value = tag; } } /// /// Tell the tools or gameui property editor which editor we should be using for this property or type. /// public class EditorAttribute : Attribute, IUninheritable { /// /// The editor to use. /// public string Value { get; private set; } public EditorAttribute( string editorName ) { Value = editorName; } } /// /// This entity is expected to be spawnable in-game, like from Sandbox's spawnmenu. /// public sealed class SpawnableAttribute : TagAttribute, IUninheritable { public SpawnableAttribute() : base( "spawnable" ) { } } /// /// Hide this in tools/editors. /// [System.Obsolete( "Moved to [Hide]" )] public sealed class HideInEditorAttribute : TagAttribute, IUninheritable { public HideInEditorAttribute() : base( "hideineditor" ) { } } /// /// Mark property as having a minimum and maximum value. /// [AttributeUsage( AttributeTargets.Property )] public class MinMaxAttribute : Attribute { /// /// The minimum value for this property. /// public float MinValue { get; set; } /// /// The maximum value for this property. /// public float MaxValue { get; set; } public MinMaxAttribute( float min, float max ) { MinValue = min; MaxValue = max; } } /// /// Declare a model to represent this entity in editor. This is a common attribute so it's leaked out of the Editor namespace. /// [AttributeUsage( AttributeTargets.Class )] public class EditorModelAttribute : Attribute { /// /// The model to display in the editor. /// public string Model { get; set; } /// /// Whether the model should cast shadows in the editor. /// public bool CastShadows { get; set; } = false; /// /// Don't reorient bounds. This is used for things that have fixed bounds in the game, like info_player_start. /// public bool FixedBounds { get; set; } = false; /// /// Tint color for this editor model instance when the entity it represents is static. /// public Color StaticColor { get; set; } /// /// Tint color for this editor model instance when the entity it represents is dynamic. /// public Color DynamicColor { get; set; } public EditorModelAttribute( string model, string staticColor = "white", string dynamicColor = "white" ) { Model = model; StaticColor = staticColor; DynamicColor = dynamicColor; } } /// /// Sometimes with CodeGen we want reflection to be able to get the original initial value /// of a property (which is set with {get;set;} = initialvalue;). For this reason sometimes /// we'll drop this attribute on that property. /// You might want to use this manually for instances where codegen can't define the default /// value. This will usually happen for structs like vector and color.. if the default value isn't /// defined as a number or string. /// public sealed class DefaultValueAttribute : Attribute { /// /// The default value. /// public object Value { get; internal set; } public DefaultValueAttribute( object value ) { Value = value; } } /// /// Allows any task defined in this assembly to continue after a sync context expires. /// Other tasks that await tasks in this assembly will still be cancelled if their assembly /// isn't also marked with this attribute. /// [AttributeUsage( AttributeTargets.Assembly )] internal sealed class TasksPersistOnContextResetAttribute : Attribute { } namespace Sandbox { /// /// Hide this in tools/editors. /// public sealed class HideAttribute : TagAttribute, IUninheritable { public HideAttribute() : base( "hide" ) { } } }