Class PlayerCommandAttribute
Marks an instance method on an ISystem as a player command. The method is invoked when a connected player sends matching chat input (a slash followed by the command name and optional arguments).
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class PlayerCommandAttribute : Attribute, ICommandAttribute
- Inheritance
-
PlayerCommandAttribute
- Implements
- Inherited Members
Remarks
The signature can be:
(Player player, [args...])- if the first parameter is Player, it's provided automatically(SomeComponent player, [args...])- if the first parameter is a component, the command is only available if the player has the specified component- subsequent parameters are parsed from the player input via ICommandParameterParser
- Return type may be void, bool, or Task.
Constructors
PlayerCommandAttribute()
Initializes a new instance with the command name inferred from the method name (lowercased, trailing "Command" stripped).
public PlayerCommandAttribute()
PlayerCommandAttribute(string)
Initializes a new instance with the explicit command name.
public PlayerCommandAttribute(string name)
Parameters
namestring
Properties
Name
The command name (optional; derives from method name if not specified).
public string? Name { get; set; }