- Reduced console spam when failing to load config file in release builds.

- Added console logging for failing to unload assembly load ctx.
- Removed unused StorageService instance.
- Removed unused luacs settings.
- Added plugin event service and event service dispatcher api.
This commit is contained in:
MapleWheels
2026-03-22 18:01:19 -04:00
parent e62450c763
commit ac329a70a4
11 changed files with 123 additions and 219 deletions
@@ -6,6 +6,8 @@ using OneOf;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
@@ -55,6 +57,7 @@ public partial class EventService : IEventService
private readonly ConcurrentDictionary<TypeStringKey, ConcurrentDictionary<OneOf<IEvent, string>, IEvent>> _subscribers = new();
private readonly ConcurrentDictionary<TypeStringKey, (TypeStringKey Event, Func<LuaCsFunc, IEvent> RunnerFactory)> _luaAliasEventFactory = new();
private readonly ConcurrentDictionary<string, ConcurrentDictionary<string, LuaCsFunc>> _luaLegacyEventsSubscribers = new();
private readonly ConcurrentDictionary<IEventService, IEventService> _subscribedEventDispatchers = new();
#region LifeCycle
@@ -316,9 +319,30 @@ public partial class EventService : IEventService
}
}
foreach (var dispatchers in _subscribedEventDispatchers.ToImmutableArray())
{
dispatchers.Value.PublishEvent(action);
}
return results;
}
public void AddDispatcherEventService(IEventService eventService)
{
using var lck = _operationsLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult();
IService.CheckDisposed(this);
_subscribedEventDispatchers.TryAdd(eventService, eventService);
}
public void RemoveDispatcherEventService(IEventService eventService)
{
using var lck = _operationsLock.AcquireWriterLock().ConfigureAwait(false).GetAwaiter().GetResult();
IService.CheckDisposed(this);
_subscribedEventDispatchers.TryRemove(eventService, out _);
}
#region LuaPatcherAdapter
public string Patch(string identifier, string className, string methodName, string[] parameterTypes, LuaCsPatchFunc patch, LuaCsHook.HookMethodType hookType = LuaCsHook.HookMethodType.Before)
{