refactor: remove underscore prefix from private fields
This commit is contained in:
@@ -7,16 +7,16 @@ public struct CommandData
|
|||||||
public readonly IServerPlayer? Sender;
|
public readonly IServerPlayer? Sender;
|
||||||
public readonly string FullCommand;
|
public readonly string FullCommand;
|
||||||
public readonly string CommandName;
|
public readonly string CommandName;
|
||||||
private byte _flags;
|
private byte flags;
|
||||||
|
|
||||||
private const byte FlagIsPlayerCommand = 1 << 0;
|
private const byte FlagIsPlayerCommand = 1 << 0;
|
||||||
private const byte FlagCancel = 1 << 1;
|
private const byte FlagCancel = 1 << 1;
|
||||||
|
|
||||||
public bool IsPlayerCommand => (_flags & FlagIsPlayerCommand) != 0;
|
public bool IsPlayerCommand => (flags & FlagIsPlayerCommand) != 0;
|
||||||
public bool Cancel
|
public bool Cancel
|
||||||
{
|
{
|
||||||
get => (_flags & FlagCancel) != 0;
|
get => (flags & FlagCancel) != 0;
|
||||||
set => _flags = value ? (byte)(_flags | FlagCancel) : (byte)(_flags & ~FlagCancel);
|
set => flags = value ? (byte)(flags | FlagCancel) : (byte)(flags & ~FlagCancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandData(IServerPlayer? sender, string fullCommand)
|
public CommandData(IServerPlayer? sender, string fullCommand)
|
||||||
@@ -24,6 +24,6 @@ public struct CommandData
|
|||||||
Sender = sender;
|
Sender = sender;
|
||||||
FullCommand = fullCommand.Length > 0 ? fullCommand.Trim() : string.Empty;
|
FullCommand = fullCommand.Length > 0 ? fullCommand.Trim() : string.Empty;
|
||||||
CommandName = FullCommand.Length > 1 ? FullCommand[1..].Split(' ')[0] : string.Empty;
|
CommandName = FullCommand.Length > 1 ? FullCommand[1..].Split(' ')[0] : string.Empty;
|
||||||
_flags = sender != null ? FlagIsPlayerCommand : (byte)0;
|
flags = sender != null ? FlagIsPlayerCommand : (byte)0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace CommandHook;
|
|||||||
|
|
||||||
public class CommandHookModSystem : ModSystem
|
public class CommandHookModSystem : ModSystem
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, List<CommandRegistration>> _registrations = new();
|
private readonly Dictionary<string, List<CommandRegistration>> registrations = new();
|
||||||
|
|
||||||
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
||||||
|
|
||||||
@@ -17,10 +17,10 @@ public class CommandHookModSystem : ModSystem
|
|||||||
|
|
||||||
public void Register(string modId, CommandRegistration registration)
|
public void Register(string modId, CommandRegistration registration)
|
||||||
{
|
{
|
||||||
if (!_registrations.TryGetValue(modId, out var list))
|
if (!registrations.TryGetValue(modId, out var list))
|
||||||
{
|
{
|
||||||
list = new List<CommandRegistration>();
|
list = new List<CommandRegistration>();
|
||||||
_registrations[modId] = list;
|
registrations[modId] = list;
|
||||||
}
|
}
|
||||||
list.Add(registration);
|
list.Add(registration);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user