From 3b036c6de871aa519a1f7fbfb52e09618945041f Mon Sep 17 00:00:00 2001
From: chai <215380520@qq.com>
Date: Mon, 15 May 2023 09:28:11 +0800
Subject: *misc
---
.../Assets/Scripts/Tools/FlagManager.cs | 44 ++++++
.../Assets/Scripts/Tools/FlagManager.cs.meta | 11 ++
.../Assets/Scripts/Tools/GlobalEventManager.cs | 2 +-
.../Assets/Scripts/Tools/Notification.meta | 8 +
.../Tools/Notification/NotificationCenter.cs | 167 +++++++++++++++++++++
.../Tools/Notification/NotificationCenter.cs.meta | 11 ++
.../Tools/Notification/NotificationExtensions.cs | 17 +++
.../Notification/NotificationExtensions.cs.meta | 11 ++
.../Tools/Notification/ScopedNotification.cs | 89 +++++++++++
.../Tools/Notification/ScopedNotification.cs.meta | 11 ++
.../Assets/Scripts/Tools/NotificationCenter.cs | 167 ---------------------
.../Scripts/Tools/NotificationCenter.cs.meta | 11 --
.../Assets/Scripts/Tools/TriggerSystem.meta | 8 +
.../Scripts/Tools/TriggerSystem/ActiveTrigger.cs | 19 +++
.../Tools/TriggerSystem/ActiveTrigger.cs.meta | 11 ++
.../Assets/Scripts/Tools/TriggerSystem/Trigger.cs | 110 ++++++++++++++
.../Scripts/Tools/TriggerSystem/Trigger.cs.meta | 11 ++
17 files changed, 529 insertions(+), 179 deletions(-)
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/Notification.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationCenter.cs
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationCenter.cs.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationExtensions.cs
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationExtensions.cs.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/Notification/ScopedNotification.cs
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/Notification/ScopedNotification.cs.meta
delete mode 100644 WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs
delete mode 100644 WorldlineKeepers/Assets/Scripts/Tools/NotificationCenter.cs.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/ActiveTrigger.cs
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/ActiveTrigger.cs.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/Trigger.cs
create mode 100644 WorldlineKeepers/Assets/Scripts/Tools/TriggerSystem/Trigger.cs.meta
(limited to 'WorldlineKeepers/Assets/Scripts/Tools')
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs b/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs
new file mode 100644
index 0000000..b9a9454
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs
@@ -0,0 +1,44 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK
+{
+
+ ///
+ /// 全局标志管理
+ ///
+ public class FlagManager : Singleton
+ {
+ public Dictionary m_Flags;
+
+ public void AddFlag(string flag, bool value = false)
+ {
+ if(!HasFlag(flag))
+ {
+ m_Flags.Add(flag, value);
+ }
+ }
+
+ public bool HasFlag(string flag)
+ {
+ return m_Flags.ContainsKey(flag);
+ }
+
+ public bool IsFlag(string flag)
+ {
+ if(m_Flags.ContainsKey(flag)) return false;
+ return m_Flags[flag];
+ }
+
+ public void RemoveFlag(string flag)
+ {
+ if(HasFlag(flag))
+ {
+ m_Flags.Remove(flag);
+ }
+ }
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs.meta
new file mode 100644
index 0000000..1738634
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2451904bd85094c40a69d59807d51c5e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs b/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs
index 47f3990..c9cde83 100644
--- a/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs
+++ b/WorldlineKeepers/Assets/Scripts/Tools/GlobalEventManager.cs
@@ -6,7 +6,7 @@ using UnityEngine.UIElements;
namespace WK
{
///
- /// 全局事件
+ /// 不指定发送者的全局事件
///
public class GlobalEventManager : Singleton
{
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/Notification.meta b/WorldlineKeepers/Assets/Scripts/Tools/Notification.meta
new file mode 100644
index 0000000..b20b283
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools/Notification.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 12f4a3b409f294746a9546c44272660c
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationCenter.cs b/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationCenter.cs
new file mode 100644
index 0000000..bb4e08e
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools/Notification/NotificationCenter.cs
@@ -0,0 +1,167 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK
+{
+
+ public class NotificationCenter : Singleton
+ {
+ public delegate void NotificatonHandler(params object[] args);
+
+ private Dictionary>> m_EventListeners = new Dictionary>>();
+
+ ///
+ /// 当前在调用中的回调
+ ///
+ private HashSet> m_CurInvokingCallbacks = new HashSet>();
+
+ public void AddObserver(string notificationName, NotificatonHandler handler)
+ {
+ AddObserver(null, notificationName, handler);
+ }
+
+ public void AddObserver(object sender, string notificationName, NotificatonHandler handler)
+ {
+ if (handler == null)
+ {
+ Debug.LogError("Can't add a null event handler for notification, " + notificationName);
+ return;
+ }
+ if (string.IsNullOrEmpty(notificationName))
+ {
+ Debug.LogError("Can't observe an unnamed notification");
+ return;
+ }
+ if (!m_EventListeners.ContainsKey(notificationName))
+ {
+ m_EventListeners.Add(notificationName, new Dictionary