2024-05-07 11:36:06 +00:00
using ColdMint.scripts.character ;
using ColdMint.scripts.inventory ;
2024-06-19 14:33:00 +00:00
using ColdMint.scripts.loader.uiLoader ;
2024-06-12 15:42:35 +00:00
using ColdMint.scripts.map.events ;
2024-06-19 14:33:00 +00:00
using ColdMint.scripts.utils ;
2024-04-28 13:55:19 +00:00
using Godot ;
namespace ColdMint.scripts ;
/// <summary>
/// <para>The node holder within the game scene</para>
/// <para>游戏场景内的节点持有者</para>
/// </summary>
2024-05-07 11:36:06 +00:00
public static class GameSceneNodeHolder
2024-04-28 13:55:19 +00:00
{
2024-06-12 15:42:35 +00:00
private static Player ? _player ;
2024-04-28 13:55:19 +00:00
/// <summary>
/// <para>Player instances within the game scene</para>
/// <para>游戏场景内的玩家实例</para>
/// </summary>
2024-06-12 15:42:35 +00:00
public static Player ? Player
{
get = > _player ;
set
{
_player = value ;
//Broadcast the event to the outside when the player instance changes.
//当玩家实例改变时,向外广播事件。
var playerInstanceChangeEvent = new PlayerInstanceChangeEvent
{
PlayerInstance = _player
} ;
EventManager . PlayerInstanceChangeEvent ? . Invoke ( playerInstanceChangeEvent ) ;
}
}
2024-04-28 13:55:19 +00:00
/// <summary>
/// <para>WeaponContainer</para>
/// <para>武器容器</para>
/// </summary>
2024-05-08 10:22:04 +00:00
public static Node2D ? WeaponContainer { get ; set ; }
2024-06-12 15:42:35 +00:00
/// <summary>
/// <para>PacksackContainer</para>
/// <para>背包容器</para>
/// </summary>
public static Node2D ? PacksackContainer { get ; set ; }
2024-06-05 13:38:45 +00:00
/// <summary>
/// <para>PlayerContainer</para>
/// <para>玩家容器</para>
/// </summary>
2024-05-31 14:26:38 +00:00
public static Node2D ? PlayerContainer { get ; set ; }
2024-06-12 15:42:35 +00:00
2024-06-03 14:58:59 +00:00
/// <summary>
/// <para>AICharacterContainer</para>
/// <para>AICharacter角色</para>
/// </summary>
2024-06-05 13:38:45 +00:00
public static Node2D ? AiCharacterContainer { get ; set ; }
2024-06-12 15:42:35 +00:00
2024-06-05 13:38:45 +00:00
/// <summary>
/// <para>HotBar</para>
/// <para>快捷栏</para>
/// </summary>
2024-05-08 10:22:04 +00:00
public static HotBar ? HotBar { get ; set ; }
2024-04-28 13:55:19 +00:00
2024-06-05 13:38:45 +00:00
/// <summary>
/// <para>Health Bar UI</para>
/// <para>健康条UI</para>
/// </summary>
2024-05-08 10:22:04 +00:00
public static HealthBarUi ? HealthBarUi { get ; set ; }
2024-06-12 15:42:35 +00:00
2024-06-05 13:38:45 +00:00
/// <summary>
/// <para>operation tip</para>
/// <para>操作提示</para>
/// </summary>
2024-05-09 13:07:14 +00:00
public static RichTextLabel ? OperationTipLabel { get ; set ; }
2024-06-16 12:18:44 +00:00
/// <summary>
/// <para>BackpackUiContainer</para>
/// <para>背包Ui容器</para>
/// </summary>
/// <remarks>
///<para>The knapsack Ui container houses the container of the knapsack ui node. When a user uses a backpack, the node to which his backpack is attached is displayed from within the backpack ui container.</para>
///<para>背包Ui容器内存放的是背包ui节点的容器。当用户使用背包时, 会从背包ui容器内将其背包对于的节点展示出来。</para>
/// </remarks>
public static Control ? BackpackUiContainer { get ; set ; }
2024-06-19 14:33:00 +00:00
/// <summary>
/// <para>Hide the knapsack node in the knapsack Ui if the knapsack UI is displayed</para>
/// <para>如果背包Ui处于显示状态, 那么隐藏背包UI内的背包节点</para>
/// </summary>
public static void HideBackpackUiContainerIfVisible ( )
{
if ( BackpackUiContainer = = null )
{
return ;
}
if ( ! BackpackUiContainer . Visible )
{
return ;
}
NodeUtils . ForEachNode < PacksackUi > ( BackpackUiContainer , node = >
{
//If the child node is not visible, the traversal continues.
//如果子节点不可见,则继续遍历。
if ( ! node . Visible )
return false ;
//Until you find a visible node, hide it, and return true, ending the loop.
//直到找到可见的节点, 隐藏该节点, 然后返回true, 结束遍历。
node . Hide ( ) ;
return true ;
} ) ;
}
2024-04-28 13:55:19 +00:00
}