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.Common;
|
||||||
using Vintagestory.API.Datastructures;
|
using Vintagestory.API.Datastructures;
|
||||||
using Vintagestory.API.Server;
|
using Vintagestory.API.Server;
|
||||||
@@ -7,9 +7,8 @@ namespace CommandHook;
|
|||||||
|
|
||||||
public class CommandHookModSystem : ModSystem
|
public class CommandHookModSystem : ModSystem
|
||||||
{
|
{
|
||||||
private ModEntry[] modEntries = Array.Empty<ModEntry>();
|
private FrozenDictionary<string, FrozenDictionary<string, CommandRegistration>> registrations =
|
||||||
private HookEntry[] hashTable = Array.Empty<HookEntry>();
|
FrozenDictionary<string, FrozenDictionary<string, CommandRegistration>>.Empty;
|
||||||
private uint hashTableSize = 0;
|
|
||||||
|
|
||||||
public override bool ShouldLoad(EnumAppSide forSide) => forSide == EnumAppSide.Server;
|
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