using System; using System.Collections.Generic; using System.Text; using UnityEngine; public class ScriptManagerFast { public ScriptManagerFast(ScriptManager f_ParentScriptMgr) { this.m_ParentScriptMgr = f_ParentScriptMgr; this.m_MotionKag = new MotionKagManager(f_ParentScriptMgr.tjs, f_ParentScriptMgr); this.m_MotionKag.Initialize(); this.m_KagCache = new ScriptManagerFast.KagParserFastCache(this.m_MotionKag); this.m_listKagSlotSet.Add(new ScriptManagerFast.KagSet(this.m_ParentScriptMgr, this.m_KagCache, 0, null)); } public void Initialize() { } ~ScriptManagerFast() { this.SelfDispose(); } public void SelfDispose() { if (this.is_disposed_) { return; } foreach (ScriptManagerFast.KagSet kagSet in this.m_listKagSlotSet) { kagSet.SelfDispose(); } if (this.m_MotionCacheKag != null) { this.m_MotionCacheKag.SelfDispose(); } if (this.m_MotionKag != null) { this.m_MotionKag.Dispose(); } GC.SuppressFinalize(this); this.is_disposed_ = true; } public bool LoadAndCacheScript(string f_strFileName) { this.m_KagCache.LoadAndCacheScript(f_strFileName); return true; } public void StartMotionScript(string f_strFileName, string f_strLabel = "", int f_nSlot = 0, Maid f_maid = null) { ScriptManagerFast.KagSet kagSet = this.m_listKagSlotSet.Find((ScriptManagerFast.KagSet a) => a.m_nSlotNo == f_nSlot); if (kagSet == null) { kagSet = new ScriptManagerFast.KagSet(this.m_ParentScriptMgr, this.m_KagCache, f_nSlot, f_maid); this.m_listKagSlotSet.Add(kagSet); } kagSet.m_KagMgr.Reset(); kagSet.m_KagMgr.LoadScript(f_strFileName); if (!string.IsNullOrEmpty(f_strLabel)) { kagSet.m_KagMgr.Jump(f_strLabel); } kagSet.m_KagMgr.Start(); } public void StopAndResetScriptAll() { for (int i = 0; i < this.m_listKagSlotSet.Count; i++) { this.m_listKagSlotSet[i].m_KagMgr.Reset(); } } public void StopAndResetScript(int f_nSlot) { ScriptManagerFast.KagSet kagSet = this.m_listKagSlotSet.Find((ScriptManagerFast.KagSet a) => a.m_nSlotNo == f_nSlot); if (kagSet != null) { kagSet.m_KagMgr.Reset(); } } private ScriptManagerFast.MotionCacheKagManagerFast GetMotionCacheKag() { if (this.m_MotionCacheKag == null) { this.m_MotionCacheKag = new ScriptManagerFast.MotionCacheKagManagerFast(this.m_KagCache, GameMain.Instance.ScriptMgr, null); this.m_MotionCacheKag.Initialize(); } return this.m_MotionCacheKag; } public void LoadMotionCacheKag(string f_strFileName) { ScriptManagerFast.MotionCacheKagManagerFast motionCacheKag = this.GetMotionCacheKag(); if (motionCacheKag.LoadScript(f_strFileName)) { motionCacheKag.Start(); while (!motionCacheKag.IsFinished()) { motionCacheKag.Update(); } } } public void Update() { for (int i = 0; i < this.m_listKagSlotSet.Count; i++) { this.m_listKagSlotSet[i].m_KagMgr.Update(); } } private bool is_disposed_; private MotionKagManager m_MotionKag; private ScriptManager m_ParentScriptMgr; private List m_listKagSlotSet = new List(); private ScriptManagerFast.KagParserFastCache m_KagCache; private ScriptManagerFast.MotionCacheKagManagerFast m_MotionCacheKag; public class TJSVariantRefFast : TJSVariantRef { public TJSVariantRefFast(string value_str) { if (value_str != null) { this.value_string_ = value_str; this.type_ = TJSVariantRef.Type.tvtString; if (float.TryParse(value_str, out this.value_float_)) { this.type_ = TJSVariantRef.Type.tvtReal; } if (int.TryParse(value_str, out this.value_int_)) { this.type_ = TJSVariantRef.Type.tvtInteger; } if (bool.TryParse(value_str, out this.value_bool_)) { this.type_ = TJSVariantRef.Type.tvtInteger; } } else { this.type_ = TJSVariantRef.Type.tvtVoid; } } public override void Clear() { } public override int AsInteger() { return this.value_int_; } public override bool AsBool() { return this.value_bool_; } public override float AsReal() { return this.value_float_; } public override string AsString() { return this.value_string_; } public override void SetInteger(int nums) { this.value_int_ = nums; } public override void SetBool(bool value) { this.value_bool_ = value; } public override void SetReal(float nums) { this.value_float_ = nums; } public override void SetString(string str) { this.value_string_ = str; } public override TJSVariantRef.Type type { get { return this.type_; } } private TJSVariantRef.Type type_; private int value_int_; private bool value_bool_; private float value_float_; private string value_string_; } public class KagTagSupportFast : KagTagSupport { ~KagTagSupportFast() { } public void AddTagProperty(string prop_name, string prop_value) { this.m_dicTJSVariant.Add(prop_name, new ScriptManagerFast.TJSVariantRefFast(prop_value)); } public override bool IsValid(string prop_name) { return this.m_dicTJSVariant.ContainsKey(prop_name); } public override TJSVariantRef GetTagProperty(string prop_name) { ScriptManagerFast.TJSVariantRefFast result = null; this.m_dicTJSVariant.TryGetValue(prop_name, out result); return result; } public override ulong GetTagKey() { return 0UL; } public override ulong GetClassUniqueid() { return 0UL; } public override Dictionary GetTagList() { return new Dictionary(); } public override void Dispose() { } protected override void Dispose(bool is_release_managed_code) { } public Dictionary m_dicTJSVariant = new Dictionary(); } public class KagParserFast { public KagParserFast(BaseKagManager motion_kag_mgr) { } public ulong GetKey(string tag_name) { return GameMain.Instance.ScriptMgr.adv_kag.kag.GetKey(tag_name); } public ScriptManagerFast.KagParserFast.KLabel FindLabel(string label_name) { return this.m_listLabel.Find((ScriptManagerFast.KagParserFast.KLabel a) => a.m_strLabel == label_name); } public int GetCommandNum() { return this.m_listCommand.Count; } public ScriptManagerFast.KagParserFast.KCommand GetCommand(int index) { return this.m_listCommand[index]; } public bool LoadScript(string f_strFileName) { this.m_listCommand.Clear(); f_strFileName += ".ks"; byte[] sjis_bytes; try { using (AFileBase afileBase = GameUty.FileOpen(f_strFileName, null)) { NDebug.Assert(afileBase.IsValid(), "LoadScript スクリプトが開けません。 :" + f_strFileName); sjis_bytes = new byte[afileBase.GetSize()]; afileBase.Read(ref sjis_bytes, afileBase.GetSize()); } } catch (Exception ex) { Debug.LogError(string.Concat(new string[] { "LoadScript スクリプトが読み込めませんでした。 : ", f_strFileName, " : ", ex.Message, " : StackTrace :\n", ex.StackTrace })); throw ex; } string text = NUty.SjisToUnicode(sjis_bytes); string[] array = text.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries); ScriptManagerFast.KagParserFast.KIf kif = null; Stack stack = new Stack(); int num = 0; foreach (string text2 in array) { num++; if (text2.Length != 0 && text2[0] != ';') { StringBuilder stringBuilder = new StringBuilder(text2); for (int j = 0; j < stringBuilder.Length; j++) { char c = stringBuilder[j]; if (c == '=') { char c2 = stringBuilder[(j - 1 >= 0) ? (j - 1) : j]; char c3 = stringBuilder[(j + 1 >= 0) ? (j + 1) : j]; if (c2 == ' ' || c2 == '\t' || c3 == ' ' || c3 == '\t') { Debug.LogError(string.Concat(new object[] { "KagParser:イコール記号の前後に不正な文字があります。file=", f_strFileName, "Line=", j })); } } if (c == '"') { bool flag = false; int k; for (k = j + 1; k < stringBuilder.Length; k++) { char c4 = stringBuilder[k]; if (c4 == '"') { flag = true; break; } if (c4 == ' ' || c4 == '\t') { stringBuilder[k] = '^'; } if (c4 == '=') { stringBuilder[k] = '~'; } } if (!flag) { Debug.LogError(string.Concat(new object[] { "KagParser:ダブルクォートが対になっていません。file=", f_strFileName, "Line=", num })); } j = k; } } text2 = stringBuilder.ToString(); string[] array2 = text2.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); if (array2.Length != 0) { if (array2[0].IndexOf('@') == 0) { ScriptManagerFast.KagParserFast.KCommand kcommand = new ScriptManagerFast.KagParserFast.KCommand(); kcommand.m_strTagName = array2[0].Substring(1).ToLower(); kcommand.m_ulTagKey = this.GetKey(kcommand.m_strTagName); for (int l = 1; l < array2.Length; l++) { string[] array3 = array2[l].Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (array3.Length == 0) { Debug.LogError(string.Concat(new object[] { "ScriptManagerFast Error プロパティが不正です。 file=", f_strFileName, " Line=", num })); return false; } array3[0] = array3[0].ToLower(); if (array3.Length > 2) { Debug.LogError(string.Concat(new object[] { "ScriptManagerFast Error '=' の数が不正です。file=", f_strFileName, " Line=", num })); return false; } if (array3.Length >= 2) { array3[1] = array3[1].Replace('^', ' '); array3[1] = array3[1].Replace('~', '='); array3[1] = array3[1].Replace("\"", string.Empty); } if (!kcommand.m_dicParam.ContainsKey(array3[0])) { kcommand.m_dicParam.Add(array3[0], (array3.Length < 2) ? null : array3[1]); kcommand.m_kagTagSupport.AddTagProperty(array3[0], (array3.Length < 2) ? null : array3[1]); } else { Debug.LogWarning(string.Concat(new object[] { "ScriptManagerFast Error 同じプロパティ名が一つのタグの中にあります。file=", f_strFileName, " Line=", num })); } } this.m_listCommand.Add(kcommand); int num2 = this.m_listCommand.Count - 1; if (kcommand.m_strTagName == "if") { ScriptManagerFast.KagParserFast.KIf kif2 = new ScriptManagerFast.KagParserFast.KIf(num2); if (kif != null) { stack.Push(kif); kif.listChild.Add(kif2); } kcommand.m_if = kif2; kif = kif2; } else if (kcommand.m_strTagName == "elsif") { kif.listElsifPos.Add(num2); } else if (kcommand.m_strTagName == "else") { kif.nElsePos = num2; } else if (kcommand.m_strTagName == "endif") { kif.nEndifPos = num2; this.m_listIf.Add(kif); if (stack.Count != 0) { kif = stack.Pop(); } else { kif = null; } } } else if (array2[0].IndexOf('*') == 0) { ScriptManagerFast.KagParserFast.KLabel klabel = new ScriptManagerFast.KagParserFast.KLabel(); klabel.m_strLabel = array2[0]; klabel.m_nLine = this.m_listCommand.Count; this.m_listLabel.Add(klabel); } } } } if (kif != null) { Debug.LogError(string.Concat(new object[] { "ifとendifが対になっていません。file=", f_strFileName, " Line=", num })); } this.m_strFileName = f_strFileName; return true; } private List m_listCommand = new List(); private List m_listLabel = new List(); private List m_listIf = new List(); public string m_strFileName; public class KCommand { public string m_strTagName; public ulong m_ulTagKey; public Dictionary m_dicParam = new Dictionary(); public ScriptManagerFast.KagTagSupportFast m_kagTagSupport = new ScriptManagerFast.KagTagSupportFast(); public ScriptManagerFast.KagParserFast.KIf m_if; } public class KLabel { public string m_strLabel; public int m_nLine; } public class KIf { public KIf(int nPos) { this.nMyPos = nPos; } public int nMyPos; public List listElsifPos = new List(); public int nElsePos; public int nEndifPos; public List listChild = new List(); } } public class KagParserFastCache { public KagParserFastCache(BaseKagManager kag_mgr) { this.kag_mgr_ = kag_mgr; } public bool LoadAndCacheScript(string f_strFileName) { bool flag = true; if (!this.m_CacheKagParser.ContainsKey(f_strFileName)) { ScriptManagerFast.KagParserFast kagParserFast = new ScriptManagerFast.KagParserFast(this.kag_mgr_); flag = kagParserFast.LoadScript(f_strFileName); if (flag) { this.m_CacheKagParser[f_strFileName] = kagParserFast; } } return flag; } public ScriptManagerFast.KagParserFast GetKagParser(string f_strFileName) { ScriptManagerFast.KagParserFast result; if (!this.m_CacheKagParser.TryGetValue(f_strFileName, out result)) { if (!this.LoadAndCacheScript(f_strFileName)) { Debug.LogError("kagスクリプトが見つかりません。" + f_strFileName); return null; } result = this.m_CacheKagParser[f_strFileName]; } return result; } private Dictionary m_CacheKagParser = new Dictionary(); private BaseKagManager kag_mgr_; } public class BaseKagManagerFast { public BaseKagManagerFast(BaseKagManager kag_mgr, ScriptManagerFast.KagParserFastCache kag_cache, ScriptManagerFast.BaseKagManagerFast kag_parent = null) { this.m_BaseKagMgr = kag_mgr; this.m_KagCache = kag_cache; this.m_KagParent = kag_parent; this.m_TjsResultShare = new TJSVariant(); } public virtual void Initialize() { this.AddTagCallBack("wait", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideWait)); this.AddTagCallBack("jump", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideJump)); this.AddTagCallBack("call", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideCall)); this.AddTagCallBack("return", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideReturn)); this.AddTagCallBack("s", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideStop)); this.AddTagCallBack("eval", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideEval)); this.AddTagCallBack("if", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideIf)); this.AddTagCallBack("elsif", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideElsif)); this.AddTagCallBack("else", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideElse)); this.AddTagCallBack("endif", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideEndif)); } public virtual void SelfDispose() { if (this.m_KagChild != null) { this.m_KagChild.SelfDispose(); } this.m_TjsResultShare.Dispose(); } protected virtual ulong GetKey(string tag_name) { return GameMain.Instance.ScriptMgr.adv_kag.kag.GetKey(tag_name); } public virtual bool LoadScript(string f_strFileName) { this.Reset(); this.m_KagParser = this.m_KagCache.GetKagParser(f_strFileName); return this.m_KagParser != null; } public virtual void AddTagCallBack(string tag_name, ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack call_back_function) { this.m_dicCallbackOverride.Add(this.GetKey(tag_name), call_back_function); } protected virtual ScriptManagerFast.BaseKagManagerFast CreateChild() { return new ScriptManagerFast.BaseKagManagerFast(this.m_BaseKagMgr, this.m_KagCache, this); } public virtual bool TagOverrideWait(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { TJSVariantRef tagProperty = tag_data.GetTagProperty("time"); this.m_listWaitEvent.Add(new ScriptManagerFast.BaseKagManagerFast.WaitEventTime((float)tagProperty.AsInteger() / 1000f)); return true; } public virtual bool TagOverrideJump(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { string text = null; if (tag_data.IsValid("label")) { TJSVariantRef tagProperty = tag_data.GetTagProperty("label"); text = tagProperty.AsString().ToLower(); } if (tag_data.IsValid("file")) { TJSVariantRef tagProperty2 = tag_data.GetTagProperty("file"); string text2 = tagProperty2.AsString(); this.LoadScript(tagProperty2.AsString()); if (!string.IsNullOrEmpty(text)) { this.Jump(text); } return false; } this.m_IfExecStack.Clear(); this.m_IfExeNow = null; return !this.Jump(text); } public virtual bool TagOverrideCall(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { string text = null; if (tag_data.IsValid("label")) { TJSVariantRef tagProperty = tag_data.GetTagProperty("label"); text = tagProperty.AsString().ToLower(); } if (tag_data.IsValid("file")) { TJSVariantRef tagProperty2 = tag_data.GetTagProperty("file"); string text2 = tagProperty2.AsString(); if (this.m_KagChild != null) { this.m_KagChild.Reset(); this.m_KagChild = null; } this.m_KagChild = this.CreateChild(); this.m_KagChild.Initialize(); this.m_KagChild.LoadScript(tagProperty2.AsString()); if (!string.IsNullOrEmpty(text)) { this.m_KagChild.Jump(text); } this.m_KagChild.Start(); this.m_bKagChild = true; return true; } this.m_CallStack.Push(this.m_nNowIndex + 1); return !this.Jump(text); } public virtual bool TagOverrideReturn(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { if (this.m_CallStack.Count != 0) { int index = this.m_CallStack.Pop(); this.SetIndex(index); } else { if (this.m_KagParent != null) { this.m_KagParent.OnReturnFromChild(); this.Reset(); return true; } Debug.LogError("Returnこれ以上戻る親が居ません。"); } return false; } public virtual bool TagOverrideStop(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { return true; } public virtual bool TagOverrideEval(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { TJSVariantRef tagProperty = tag_data.GetTagProperty("exp"); string eval_str = tagProperty.AsString(); GameMain.Instance.ScriptMgr.EvalScript(eval_str); return false; } public virtual bool TagOverrideIf(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { TJSVariantRef tagProperty = tag_data.GetTagProperty("exp"); string eval_str = tagProperty.AsString(); ScriptManagerFast.BaseKagManagerFast.IfExec ifExeNow = new ScriptManagerFast.BaseKagManagerFast.IfExec(command.m_if); if (this.m_IfExeNow != null) { this.m_IfExecStack.Push(this.m_IfExeNow); } this.m_IfExeNow = ifExeNow; GameMain.Instance.ScriptMgr.EvalScript(eval_str, this.m_TjsResultShare); bool flag = this.m_TjsResultShare.AsBool(); if (!flag) { int num = this.m_IfExeNow.DequeueElsif(); if (num == 0) { num = this.m_IfExeNow.m_kif.nElsePos; if (num == 0) { num = this.m_IfExeNow.m_kif.nEndifPos; if (num == 0) { Debug.LogError("endifが見つかりません。"); } } } this.SetIndex(num); } this.m_IfExeNow.m_mach = flag; return false; } public virtual bool TagOverrideElsif(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { if (this.m_IfExeNow.m_mach) { int nEndifPos = this.m_IfExeNow.m_kif.nEndifPos; if (nEndifPos == 0) { Debug.LogError("endifが見つかりません。"); } this.SetIndex(nEndifPos); return false; } TJSVariantRef tagProperty = tag_data.GetTagProperty("exp"); string eval_str = tagProperty.AsString(); GameMain.Instance.ScriptMgr.EvalScript(eval_str, this.m_TjsResultShare); bool flag = this.m_TjsResultShare.AsBool(); if (!flag) { int num = this.m_IfExeNow.DequeueElsif(); if (num == 0) { num = this.m_IfExeNow.m_kif.nElsePos; if (num == 0) { num = this.m_IfExeNow.m_kif.nEndifPos; if (num == 0) { Debug.LogError("endifが見つかりません。"); } } } this.SetIndex(num); } this.m_IfExeNow.m_mach = flag; return false; } public virtual bool TagOverrideElse(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { if (this.m_IfExeNow.m_mach) { int nEndifPos = this.m_IfExeNow.m_kif.nEndifPos; if (nEndifPos == 0) { Debug.LogError("endifが見つかりません。"); } this.SetIndex(nEndifPos); return false; } this.m_IfExeNow.m_mach = true; return false; } public virtual bool TagOverrideEndif(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { if (this.m_IfExecStack.Count == 0) { this.m_IfExeNow = null; } else { this.m_IfExeNow = this.m_IfExecStack.Pop(); } return false; } public virtual void OnReturnFromChild() { this.m_bKagChild = false; this.m_bExec = true; } public virtual void Reset() { this.m_bExec = false; this.SetIndex(0); this.m_listWaitEvent.Clear(); this.m_CallStack.Clear(); if (this.m_KagChild != null) { this.m_KagChild.Reset(); } this.m_bKagChild = false; this.m_IfExecStack.Clear(); this.m_IfExeNow = null; } public virtual void Start() { if (!this.m_bKagChild) { this.m_bExec = true; } else { this.m_KagChild.Start(); } } protected virtual void SetIndex(int f_nNewIndex) { this.m_nNowIndex = f_nNewIndex; this.m_bIndexIncrement = false; } public virtual bool Jump(string f_strLabelName) { ScriptManagerFast.KagParserFast.KLabel klabel = this.m_KagParser.FindLabel(f_strLabelName); if (klabel == null) { Debug.LogError("ScriptManagerFast Call タグ指定のラベルはありません。"); return false; } this.SetIndex(klabel.m_nLine); return true; } public virtual void Update() { this.m_bWait = false; int num = this.m_listWaitEvent.Count - 1; while (0 <= num) { bool flag = this.m_listWaitEvent[num].Update(); this.m_bWait = (this.m_bWait || flag); if (!flag) { this.m_listWaitEvent.RemoveAt(num); } num--; } while (this.m_bExec && !this.m_bKagChild && !this.m_bWait) { if (this.m_KagParser.GetCommandNum() <= this.m_nNowIndex) { this.m_bExec = false; break; } ScriptManagerFast.KagParserFast.KCommand command = this.m_KagParser.GetCommand(this.m_nNowIndex); this.m_bIndexIncrement = true; float realtimeSinceStartup = Time.realtimeSinceStartup; ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack kagFastTagCallBack; bool flag2; if (this.m_dicCallbackOverride.TryGetValue(command.m_ulTagKey, out kagFastTagCallBack)) { flag2 = kagFastTagCallBack(command.m_kagTagSupport, command); } else { flag2 = this.m_BaseKagMgr.kag.CallTag(command.m_ulTagKey, command.m_kagTagSupport, true); } if (this.m_bIndexIncrement) { this.m_nNowIndex++; } if (flag2) { this.m_bExec = !flag2; break; } } if (this.m_bKagChild) { this.m_KagChild.Update(); } } protected bool m_bExec; protected bool m_bWait; protected int m_nNowIndex; protected bool m_bIndexIncrement = true; protected Dictionary m_dicCallbackOverride = new Dictionary(); protected BaseKagManager m_BaseKagMgr; protected ScriptManagerFast.KagParserFastCache m_KagCache; protected ScriptManagerFast.KagParserFast m_KagParser; protected ScriptManagerFast.BaseKagManagerFast m_KagParent; protected ScriptManagerFast.BaseKagManagerFast m_KagChild; protected bool m_bKagChild; protected Stack m_CallStack = new Stack(); protected Stack m_IfExecStack = new Stack(); protected ScriptManagerFast.BaseKagManagerFast.IfExec m_IfExeNow; protected TJSVariant m_TjsResultShare; protected List m_listWaitEvent = new List(); protected class IfExec { public IfExec(ScriptManagerFast.KagParserFast.KIf kif) { this.m_kif = kif; } public int DequeueElsif() { int result = 0; if (this.m_queue < this.m_kif.listElsifPos.Count) { result = this.m_kif.listElsifPos[this.m_queue]; this.m_queue++; } return result; } public ScriptManagerFast.KagParserFast.KIf m_kif; public bool m_mach; private int m_queue; } protected abstract class WaitEvent { public abstract bool IsWait(); public abstract bool Update(); } protected class WaitEventTime : ScriptManagerFast.BaseKagManagerFast.WaitEvent { public WaitEventTime(float f_time) { this.m_fBackTime = Time.realtimeSinceStartup; this.m_fWaitTime = f_time; this.m_bWait = true; } public override bool IsWait() { return this.m_bWait; } public override bool Update() { if (this.m_fWaitTime <= Time.realtimeSinceStartup - this.m_fBackTime) { this.m_bWait = false; return this.m_bWait; } return this.m_bWait; } private bool m_bWait; private float m_fBackTime; private float m_fWaitTime; } public delegate bool KagFastTagCallBack(KagTagSupport val_data, ScriptManagerFast.KagParserFast.KCommand command); } public class MotionKagManagerFast : ScriptManagerFast.BaseKagManagerFast { public MotionKagManagerFast(MotionKagManager motion_kag_mgr, ScriptManagerFast.KagParserFastCache kag_cache, ScriptManagerFast.BaseKagManagerFast kag_parent = null) : base(motion_kag_mgr, kag_cache, kag_parent) { this.m_MotionKagMgr = motion_kag_mgr; this.m_KagCache = kag_cache; } protected override ScriptManagerFast.BaseKagManagerFast CreateChild() { return new ScriptManagerFast.MotionKagManagerFast(this.m_MotionKagMgr, this.m_KagCache, this); } private MotionKagManager m_MotionKagMgr; } public class MotionCacheKagManagerFast : ScriptManagerFast.BaseKagManagerFast { public MotionCacheKagManagerFast(ScriptManagerFast.KagParserFastCache kag_cache, ScriptManager script_mgr, ScriptManagerFast.BaseKagManagerFast kag_parent = null) : base(null, kag_cache, kag_parent) { this.m_ScriptMgr = script_mgr; } public bool IsFinished() { return this.m_bFinish; } public override void Initialize() { this.AddTagCallBack("jump", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideJump)); this.AddTagCallBack("call", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideCall)); this.AddTagCallBack("motion", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideMotion)); this.AddTagCallBack("motionnextabs", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideMotionNextAbs)); this.AddTagCallBack("bustmove", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagOverrideBustMove)); } protected override ScriptManagerFast.BaseKagManagerFast CreateChild() { return new ScriptManagerFast.MotionCacheKagManagerFast(this.m_KagCache, this.m_ScriptMgr, this); } public override bool TagOverrideJump(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { return this.TagOverrideCall(tag_data, command); } public override bool TagOverrideCall(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { if (!tag_data.IsValid("file")) { return false; } TJSVariantRef tagProperty = tag_data.GetTagProperty("file"); string text = tagProperty.AsString(); if (this.m_dicCached.ContainsKey(text.GetHashCode())) { return false; } this.m_dicCached.Add(text.GetHashCode(), true); if (this.m_KagChild != null) { this.m_KagChild.Reset(); this.m_KagChild = null; } this.m_KagChild = this.CreateChild(); this.m_KagChild.Initialize(); this.m_KagChild.LoadScript(tagProperty.AsString()); this.m_KagChild.Start(); this.m_bKagChild = true; return true; } public bool TagOverrideMotion(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { Maid maid = null; string str = string.Empty; if (tag_data.IsValid("maid")) { TJSVariantRef tagProperty = tag_data.GetTagProperty("maid"); maid = GameMain.Instance.CharacterMgr.GetMaid(tagProperty.AsInteger()); } if (tag_data.IsValid("mot")) { TJSVariantRef tagProperty2 = tag_data.GetTagProperty("mot"); str = tagProperty2.AsString(); } if (tag_data.IsValid("loop")) { TJSVariantRef tagProperty3 = tag_data.GetTagProperty("loop"); bool flag = tagProperty3.AsBool(); } if (maid != null) { maid.body0.CacheLoadAnime(this.m_ScriptMgr.file_system, str + ".anm", !this.m_bMuneYureL, !this.m_bMuneYureR); } return false; } public bool TagOverrideMotionNextAbs(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { return this.TagOverrideMotion(tag_data, command); } public bool TagOverrideBustMove(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { if (tag_data.IsValid("maid")) { TJSVariantRef tagProperty = tag_data.GetTagProperty("maid"); Maid maid = GameMain.Instance.CharacterMgr.GetMaid(tagProperty.AsInteger()); } if (tag_data.IsValid("move")) { TJSVariantRef tagProperty2 = tag_data.GetTagProperty("move"); if (tagProperty2.AsString() == "non") { this.m_bMuneYureL = true; this.m_bMuneYureR = true; } else if (tagProperty2.AsString() == "stop") { this.m_bMuneYureL = false; this.m_bMuneYureR = false; } else if (tagProperty2.AsString() == "Lstop") { this.m_bMuneYureL = false; } else if (tagProperty2.AsString() == "Rstop") { this.m_bMuneYureR = false; } } return false; } public override void OnReturnFromChild() { this.m_KagChild = null; this.m_bKagChild = false; this.m_bExec = true; } public override void Update() { if (this.m_bExec && !this.m_bKagChild) { if (this.m_KagParser.GetCommandNum() <= this.m_nNowIndex) { this.m_bExec = false; this.m_bFinish = true; if (this.m_KagParent != null) { this.m_KagParent.OnReturnFromChild(); } return; } ScriptManagerFast.KagParserFast.KCommand command = this.m_KagParser.GetCommand(this.m_nNowIndex); bool flag = false; ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack kagFastTagCallBack; if (this.m_dicCallbackOverride.TryGetValue(command.m_ulTagKey, out kagFastTagCallBack)) { flag = kagFastTagCallBack(command.m_kagTagSupport, command); } this.m_nNowIndex++; this.m_bExec = !flag; } if (this.m_bKagChild) { this.m_KagChild.Update(); } } private Dictionary m_dicCached = new Dictionary(); private bool m_bMuneYureL; private bool m_bMuneYureR; private bool m_bFinish; private ScriptManager m_ScriptMgr; } public class VRTouchKagManagerFast : ScriptManagerFast.BaseKagManagerFast { public VRTouchKagManagerFast(BaseKagManager base_kag_mgr, ScriptManagerFast.KagParserFastCache kag_cache, ScriptManagerFast.BaseKagManagerFast kag_parent = null) : base(base_kag_mgr, kag_cache, kag_parent) { } public override void Initialize() { this.AddTagCallBack("vrtouch", new ScriptManagerFast.BaseKagManagerFast.KagFastTagCallBack(this.TagVRTouch)); } protected override ScriptManagerFast.BaseKagManagerFast CreateChild() { return new ScriptManagerFast.VRTouchKagManagerFast(this.m_BaseKagMgr, this.m_KagCache, this); } public bool TagVRTouch(KagTagSupport tag_data, ScriptManagerFast.KagParserFast.KCommand command) { SceneVRCommunication.Instance.TouchComm.Add_Touch(tag_data); return false; } } private class KagSet { public KagSet(ScriptManager f_ParentScriptMgr, ScriptManagerFast.KagParserFastCache f_Cache, int f_nSlotNo, Maid f_MainMaid = null) { this.m_nSlotNo = f_nSlotNo; this.m_MotionKag = new MotionKagManager(f_ParentScriptMgr.tjs, f_ParentScriptMgr); this.m_MotionKag.Initialize(); if (f_MainMaid == null) { this.m_MotionKag.SetMainMan(f_MainMaid); this.m_MotionKag.SetMainMaid(f_MainMaid); } else if (f_MainMaid.boMAN) { this.m_MotionKag.SetMainMan(f_MainMaid); } else { this.m_MotionKag.SetMainMaid(f_MainMaid); } this.m_KagMgr = new ScriptManagerFast.MotionKagManagerFast(this.m_MotionKag, f_Cache, null); this.m_KagMgr.Initialize(); } public void SelfDispose() { this.m_KagMgr.SelfDispose(); this.m_MotionKag.Dispose(); } public int m_nSlotNo; public MotionKagManager m_MotionKag; public ScriptManagerFast.MotionKagManagerFast m_KagMgr; } }