using System; using System.Collections.Generic; 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, Node2D node) { if (!_bubbleDictionary.TryAdd(id, node)) { return false; } node.Hide(); 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)) { return; } value.Show(); } /// /// Hidden bubble /// 隐藏气泡 /// public void HideBubble(int id) { if (!_bubbleDictionary.TryGetValue(id, out var value)) { return; } value.Hide(); } }