using Godot; using System; using System.Collections.Generic; public class ShadowBallManager : Spatial { private Dictionary mBallDict = new Dictionary(); private PackedScene mTemplateShadowBall; // Called when the node enters the scene tree for the first time. public override void _Ready() { mTemplateShadowBall = ResourceLoader.Load("res://scenes/stages/ShadowBall.tscn"); } public Guid AddBall() { var guid = Guid.NewGuid(); var instance = mTemplateShadowBall.Instance(); AddChild(instance); mBallDict.Add(guid, instance); return guid; } public void SetBallName(Guid ballid, string new_name) { if (mBallDict.TryGetValue(ballid, out ShadowBall entity)) { entity.SetPlayerName(new_name); } } public void SetBallState(Guid ballid, Vector3 pos, Quat quad, ShadowBallType btype) { if (mBallDict.TryGetValue(ballid, out ShadowBall entity)) { entity.SetBallState(pos, quad, btype); } } public void RemoveBall(Guid ballid) { if (mBallDict.TryGetValue(ballid, out ShadowBall entity)) { RemoveChild(entity); entity.QueueFree(); mBallDict.Remove(ballid); } } }