(client)chore:将维度区分独立,将加载页面独立,降低代码耦合,写了更好看的注释
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using Logging; // Assuming 'Logging' is a standard or project-specific namespace.
|
||||
using Map; // Assuming 'Map' is a standard or project-specific namespace.
|
||||
using Logging;
|
||||
using Map;
|
||||
using UnityEngine;
|
||||
using Utils; // Assuming 'Utils' is a standard or project-specific namespace.
|
||||
using Utils;
|
||||
|
||||
/// <summary>
|
||||
/// Program 类作为单例模式的核心管理器,负责维护和管理游戏或应用中的维度(Dimension)实例和焦点状态。
|
||||
@ -10,6 +10,11 @@ using Utils; // Assuming 'Utils' is a standard or project-specific namespace.
|
||||
/// </summary>
|
||||
public class Program : Singleton<Program>
|
||||
{
|
||||
/// <summary>
|
||||
/// 指示是否需要加载数据的标志,例如在游戏启动或场景切换时。
|
||||
/// </summary>
|
||||
public bool needLoad = true;
|
||||
|
||||
/// <summary>
|
||||
/// 当前聚焦的实体对象,可能为空。
|
||||
/// </summary>
|
||||
@ -58,12 +63,11 @@ public class Program : Singleton<Program>
|
||||
return;
|
||||
}
|
||||
_registeredDimensions.Add(id, dimension);
|
||||
Debug.Log($"[Program] Dimension '{id}' registered successfully.");
|
||||
|
||||
// 如果注册的维度是当前焦点维度,则更新 FocusedDimension 属性
|
||||
if (focuseDimensionId == id)
|
||||
{
|
||||
FocusedDimension = dimension;
|
||||
Debug.Log($"[Program] FocusedDimension updated to '{id}'.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,13 +85,11 @@ public class Program : Singleton<Program>
|
||||
string id = dimension.DimensionId;
|
||||
if (_registeredDimensions.Remove(id))
|
||||
{
|
||||
Debug.Log($"[Program] Dimension '{id}' unregistered successfully.");
|
||||
|
||||
// 如果注销的维度是当前焦点维度,则清除焦点
|
||||
if (focuseDimensionId == id)
|
||||
{
|
||||
focuseDimensionId = null;
|
||||
FocusedDimension = null;
|
||||
Debug.Log($"[Program] Focused dimension '{id}' was unregistered and has been cleared.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -117,14 +119,12 @@ public class Program : Singleton<Program>
|
||||
{
|
||||
focuseDimensionId = null;
|
||||
FocusedDimension = null;
|
||||
Debug.Log("[Program] Focused dimension cleared.");
|
||||
return;
|
||||
}
|
||||
if (_registeredDimensions.TryGetValue(dimensionId, out Dimension newFocusedDimension))
|
||||
{
|
||||
focuseDimensionId = dimensionId;
|
||||
FocusedDimension = newFocusedDimension;
|
||||
Debug.Log($"[Program] Focused dimension set to '{dimensionId}'.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user