32 lines
923 B
C#
32 lines
923 B
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class CardLockSvc
|
||
|
|
{
|
||
|
|
private readonly HashSet<CardEventData.LOCK_EXCLUSIVE_CARD_ENUM> _exclusive_lock_queue = new();
|
||
|
|
|
||
|
|
public bool LOCK_APPLY(CardEventData.LOCK_EXCLUSIVE_CARD_ENUM lock_name)
|
||
|
|
{
|
||
|
|
if (!_exclusive_lock_queue.Add(lock_name))
|
||
|
|
{
|
||
|
|
Debug.LogWarning($"拒绝加锁: {lock_name}");
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
Debug.Log($"申请加锁: {lock_name}");
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void LOCK_RELEASE(CardEventData.LOCK_EXCLUSIVE_CARD_ENUM lock_name)
|
||
|
|
{
|
||
|
|
if (!_exclusive_lock_queue.Contains(lock_name)) return;
|
||
|
|
_exclusive_lock_queue.Remove(lock_name);
|
||
|
|
Debug.Log($"释放锁: {lock_name}");
|
||
|
|
}
|
||
|
|
|
||
|
|
public bool LOCK_GET(CardEventData.LOCK_EXCLUSIVE_CARD_ENUM lock_name)
|
||
|
|
{
|
||
|
|
return _exclusive_lock_queue.Contains(lock_name);
|
||
|
|
}
|
||
|
|
}
|