using System.Collections.Generic; namespace Model { [ObjectEvent] public class ActorManagerComponentEvent : ObjectEvent, IAwake { public void Awake() { this.Get().Awake(); } } /// /// 用来管理该服务器上所有的Actor对象 /// public class ActorManagerComponent : Component { private readonly Dictionary dictionary = new Dictionary(); public void Awake() { } public void Add(Entity entity) { dictionary.Add(entity.Id, entity); } public void Remove(long id) { this.dictionary.Remove(id); } public Entity Get(long id) { this.dictionary.TryGetValue(id, out Entity entity); return entity; } public override void Dispose() { if (this.Id == 0) { return; } base.Dispose(); } } }