refactor: collapse hooks into nested frozen dictionary
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using Vintagestory.API.Common;
|
||||
using Vintagestory.API.Datastructures;
|
||||
using Vintagestory.API.Server;
|
||||
@@ -7,9 +7,8 @@ namespace CommandHook;
|
||||
|
||||
public class CommandHookModSystem : ModSystem
|
||||
{
|
||||
private ModEntry[] modEntries = Array.Empty<ModEntry>();
|
||||
private HookEntry[] hashTable = Array.Empty<HookEntry>();
|
||||
private uint hashTableSize = 0;
|
||||
private FrozenDictionary<string, FrozenDictionary<string, CommandRegistration>> registrations =
|
||||
FrozenDictionary<string, FrozenDictionary<string, CommandRegistration>>.Empty;
|
||||
|
||||
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace CommandHook;
|
||||
|
||||
public struct HookEntry
|
||||
{
|
||||
public readonly string? CommandName; // null = wildcard
|
||||
public readonly CommandRegistration Registration;
|
||||
|
||||
public HookEntry(string? commandName, CommandRegistration registration)
|
||||
{
|
||||
CommandName = commandName;
|
||||
Registration = registration;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace CommandHook;
|
||||
|
||||
public struct ModEntry
|
||||
{
|
||||
public readonly string ModId;
|
||||
public readonly HookEntry[] Hooks;
|
||||
|
||||
public ModEntry(string modId, HookEntry[] hooks)
|
||||
{
|
||||
ModId = modId;
|
||||
Hooks = hooks;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user