using System.Collections; using System.Collections.Generic; using UnityEngine; public class EventLockSvc { private readonly HashSet _exclusive_lock_queue = new(); private bool GetNeedDebugLog() => CombatScenarioEventOS.Instance.GetNeedDebugLog(); public bool LOCK_APPLY(EventLock.LOCK_EXCLUSIVE_CARD_ENUM lock_name) // return true 加锁成功 { if (!_exclusive_lock_queue.Add(lock_name)) { if (GetNeedDebugLog()) Debug.LogWarning($"拒绝加锁: [{lock_name}]"); return false; } if (GetNeedDebugLog()) Debug.Log($"申请加锁: [{lock_name}]"); return true; } public void LOCK_RELEASE(EventLock.LOCK_EXCLUSIVE_CARD_ENUM lock_name) { if (!_exclusive_lock_queue.Contains(lock_name)) return; _exclusive_lock_queue.Remove(lock_name); if (GetNeedDebugLog()) Debug.Log($"释放解锁: [{lock_name}]"); } public bool LOCK_GET(EventLock.LOCK_EXCLUSIVE_CARD_ENUM lock_name) { if (_exclusive_lock_queue.Contains(lock_name)) { if (GetNeedDebugLog()) Debug.LogWarning($"状态已被锁定: [{lock_name}]"); return true; } return false; } }