diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Compatibility/ILuaCsHook.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Compatibility/ILuaCsHook.cs
index 7dfdb8291..dbe6c4916 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Compatibility/ILuaCsHook.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Compatibility/ILuaCsHook.cs
@@ -11,6 +11,7 @@ public interface ILuaCsHook : ILuaPatcher, ILuaCsShim
void Add(string eventName, string identifier, LuaCsFunc callback, object owner = null);
[Obsolete("ACsMod is deprecated. Use ILuaEventService.Add() instead.")]
void Add(string eventName, LuaCsFunc callback, object owner = null);
+ void Remove(string eventName, string identifier);
// Does anyone use this? TODO: Analyze old Lua mods for usage scenarios.
//bool Exists(string eventName, string identifier);
object Call(string eventName, params object[] args);
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs
index e973d12f1..654fa0c0a 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/EventService.cs
@@ -200,6 +200,29 @@ public partial class EventService : IEventService
}
public void Remove(string eventName, string identifier)
+ {
+ Guard.IsNotNullOrWhiteSpace(eventName, nameof(eventName));
+ Guard.IsNotNullOrWhiteSpace(identifier, nameof(identifier));
+
+ using var lck = _operationsLock.AcquireReaderLock().ConfigureAwait(false).GetAwaiter().GetResult();
+ IService.CheckDisposed(this);
+
+ if (_luaAliasEventFactory.TryGetValue(eventName, out var eventFunc))
+ {
+ if (_subscribers.TryGetValue(eventFunc.Event, out var eventSubs))
+ {
+ eventSubs.TryRemove(identifier, out _);
+ }
+ }
+ else
+ {
+ if (_luaLegacyEventsSubscribers.TryGetValue(eventName, out var eventSubs))
+ {
+ eventSubs.TryRemove(identifier, out _);
+ }
+ }
+ }
+ public void Unsubscribe(string eventName, string identifier)
{
Guard.IsNotNullOrWhiteSpace(eventName, nameof(eventName));
Guard.IsNotNullOrWhiteSpace(identifier, nameof(identifier));
diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/_Lua/ILuaEventService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/_Lua/ILuaEventService.cs
index ae789afe5..3e6ed307c 100644
--- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/_Lua/ILuaEventService.cs
+++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/_Lua/ILuaEventService.cs
@@ -19,7 +19,7 @@ public interface ILuaSafeEventService : ILuaService, ILuaCsHook
///
///
///
- void Remove(string eventName, string identifier);
+ void Unsubscribe(string eventName, string identifier);
///
/// Send an event to all subscribers to an interface.
///