private T SendMessage <T>(ScriptMsgType nType, Action <COutPacket> pEncode, ScriptFlagType nFlag, byte bParam, int nSpeakerTemplateID)
        {
            SendDialog(nType, pEncode, nFlag, bParam, nSpeakerTemplateID);

            m_response = new AwaitValue <object>();

            var task = m_response.Get();

            task.Wait();

            var result = task.Result;

            if (result is Exception ex)
            {
                throw ex;
            }
            else
            {
                return((T)result);
            }

            //TODO: Find a way to not block, async await doesnt work when called by python ( as below )
            //{
            //var resp = await Response.Get();
            //return (T)resp;
            //}
        }
        private void SendDialog(ScriptMsgType nType, Action <COutPacket> pEncode, ScriptFlagType nFlag, byte bParam, int nSpeakerTemplateID)
        {
            var outPacket = new COutPacket(SendOps.LP_ScriptMessage);

            outPacket.Encode1((byte)nFlag);
            outPacket.Encode4(SpeakerTemplateID);
            outPacket.Encode1((byte)nType);
            outPacket.Encode1(bParam);

            pEncode?.Invoke(outPacket);

            LastMsgType = nType;

            Parent.SendPacket(outPacket);
        }