From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/XAIGlobal.cs | 61 ++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XAIGlobal.cs (limited to 'Client/Assets/Scripts/XMainClient/XAIGlobal.cs') diff --git a/Client/Assets/Scripts/XMainClient/XAIGlobal.cs b/Client/Assets/Scripts/XMainClient/XAIGlobal.cs new file mode 100644 index 00000000..db89ee1d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XAIGlobal.cs @@ -0,0 +1,61 @@ +using System; +using XUtliPoolLib; + +namespace XMainClient +{ + internal sealed class XAIGlobal + { + public XEntity Host + { + get + { + return this._host; + } + } + + private XEntity _host = null; + + public void InitAIGlobal(string ainame) + { + this._host = XSingleton.singleton.CreateEmpty(); + this._host.AI = (XSingleton.singleton.CreateComponent(this._host, XAIComponent.uuID) as XAIComponent); + this._host.AI.SetBehaviorTree(ainame); + } + + public void UnInitAIGlobal() + { + bool flag = this._host != null; + if (flag) + { + XSingleton.singleton.DestroyEntity(this._host); + } + this._host = null; + } + + public void SendAIMsg(string msg, float time = 0f, int typeid = 0, int argid = 0) + { + bool flag = this._host == null || this._host.AI == null; + if (!flag) + { + XAIEventArgs @event = XEventPool.GetEvent(); + @event.DepracatedPass = false; + @event.Firer = this._host; + @event.EventType = 1; + @event.EventArg = msg; + @event.SkillId = argid; + @event.TypeId = typeid; + uint item = XSingleton.singleton.FireEvent(@event, (time > 0f) ? time : 0.05f); + this._host.AI.TimerToken.Add(item); + } + } + + public void ClearAllTimer() + { + bool flag = this._host != null && this._host.AI != null; + if (flag) + { + this._host.AI.ClearAllTimer(); + } + } + } +} -- cgit v1.1-26-g67d0