Game_CodeMM/Assets/00_scripts/Events/CombatScenarioEventOS.cs
2025-11-18 01:08:04 +08:00

45 lines
1.7 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;
public class CombatScenarioEventOS : MonoBehaviour
{
public static CombatScenarioEventOS Instance { get; private set; }
private EventLockSvc eventLockSvc;
private EventHandlerSvc eventHandlerSvc;
[SerializeField] private bool needDebugLog = true;
public void SetDebugLog(bool value) => needDebugLog = value;
public bool GetNeedDebugLog() => needDebugLog;
private void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
eventLockSvc = new EventLockSvc();
eventHandlerSvc = new EventHandlerSvc();
DontDestroyOnLoad(gameObject);
}
// *************** 锁 ****************
public bool LOCK_APPLY(EventLock.LOCK_EXCLUSIVE_CARD_ENUM lock_name) => eventLockSvc.LOCK_APPLY(lock_name);
public void LOCK_RELEASE(EventLock.LOCK_EXCLUSIVE_CARD_ENUM lock_name) => eventLockSvc.LOCK_RELEASE(lock_name);
public bool LOCK_GET(EventLock.LOCK_EXCLUSIVE_CARD_ENUM lock_name) => eventLockSvc.LOCK_GET(lock_name);
// *************** 事件系统 ****************
public void EVENT_REGISTER<T>(EventData.EVENT_REGISTER_CARD_ENUM event_name, Action<T> callback) where T : struct =>
eventHandlerSvc.EVENT_REGISTER(event_name, callback);
public void EVENT_TRIGGER(EventData.EVENT_REGISTER_CARD_ENUM event_name, object data) =>
eventHandlerSvc.EVENT_TRIGGER(event_name, data);
public void EVENT_UNREGISTER<T>(EventData.EVENT_REGISTER_CARD_ENUM event_name, Action<T> callback) where T : struct =>
eventHandlerSvc.EVENT_UNREGISTER(event_name, callback);
}