private void RegisterSignal(string signal, Table conditions, Closure closure, bool runOnce = false, string runOnceFlag = "") { var reservedId = _signal.ReserveId(); var action = new Action <IGameEventArgs>(obj => { // condition checks first if (conditions != null) { if (conditions.Values.Select(condition => condition.Function) .Any(cs => Equals(cs.Call(), DynValue.False))) { return; } } if (runOnce && !string.Equals(runOnceFlag, string.Empty)) { if (_player.PlayerData.GetFlag(runOnceFlag)) { return; } } _interpreter.RunCoroutine( $"event subscribed to ({signal})", closure); if (runOnce) { _signal.Unsubscribe(reservedId); if (!string.Equals(runOnceFlag, string.Empty)) { _player.PlayerData.SetFlag(runOnceFlag, true); } } }); _signal.Subscribe(reservedId, signal, action); }