using System; using Base; namespace Model { [ObjectEvent] public class ActorComponentEvent : ObjectEvent, IAwake { public void Awake() { this.Get().Awake(); } } /// /// 挂上这个组件表示该Entity是一个Actor, 它会将Entity位置注册到Location Server /// public class ActorComponent: Component { private long actorId; public async void Awake() { try { this.actorId = this.Owner.Id; Game.Scene.GetComponent().Add(this.Owner); await Game.Scene.GetComponent().Add(this.actorId); } catch (Exception e) { Log.Error(e.ToString()); } } public override async void Dispose() { try { if (this.Id == 0) { return; } base.Dispose(); Game.Scene.GetComponent().Remove(actorId); await Game.Scene.GetComponent().Remove(this.actorId); } catch (Exception e) { Log.Error(e.ToString()); } } } }