using System.Collections.Generic; using ColdMint.scripts.debug; using ColdMint.scripts.utils; using Godot; namespace ColdMint.scripts.bubble; /// /// BubbleMarker /// 气泡位置标记 /// public partial class BubbleMarker : Marker2D { private readonly Dictionary _bubbleDictionary = []; /// /// Add bubbles /// 添加气泡 /// /// /// /// public bool AddBubble(int id, Node node) { if (!_bubbleDictionary.TryAdd(id, node)) { return false; } NodeUtils.HideNode(node); NodeUtils.CallDeferredAddChild(this, node); return true; } /// /// DisplayBubble /// 显示气泡 /// /// ///Display specific nodes above the creature as "bubbles", for example, question bubbles when an enemy finds the player. ///在生物头顶显示特定的节点作为“气泡”,例如:当敌人发现玩家后将显示疑问气泡。 /// /// public void ShowBubble(int id) { if (!_bubbleDictionary.TryGetValue(id, out var value)) { LogCat.LogErrorWithFormat("bubble_not_found", LogCat.LogLabel.BubbleMarker, id); return; } NodeUtils.ShowNode(value); } /// /// Hidden bubble /// 隐藏气泡 /// public void HideBubble(int id) { if (!_bubbleDictionary.TryGetValue(id, out var value)) { LogCat.LogErrorWithFormat("bubble_not_found", LogCat.LogLabel.BubbleMarker, id); return; } NodeUtils.HideNode(value); } }