using System; using System.Collections.Generic; using System.IO; using System.Linq; using kt.ik; using kt.Physics; using kt.Utility; using script; using UnityEngine; public class MotionKagManager : BaseKagManager { public MotionKagManager(TJSScript tjs, ScriptManager script_mgr) : base(tjs, script_mgr) { for (int i = 0; i < this.last_maid_motion_set_log_.Length; i++) { this.last_maid_motion_set_log_[i] = string.Empty; } for (int j = 0; j < this.last_man_motion_set_log_.Length; j++) { this.last_man_motion_set_log_[j] = string.Empty; } } public override void Initialize() { base.Initialize(); this.LoadMotionScriptMeta(); this.kag_.RemoveTagCallBack("motionscript"); this.kag_.RemoveTagCallBack("allprocpropseqstart"); this.kag_.AddTagCallBack("allprocpropseqstart", new KagScript.KagTagCallBack(this.TagMotAllProcPropSeqStart)); this.kag_.RemoveTagCallBack("setmaidoffsetmultipos"); this.kag_.AddTagCallBack("setmaidoffsetmultipos", new KagScript.KagTagCallBack(this.TagSetMaidOffsetMultiPos2)); this.kag_.RemoveTagCallBack("face"); this.kag_.AddTagCallBack("face", new KagScript.KagTagCallBack(this.TagMotFace)); this.kag_.RemoveTagCallBack("faceblend"); this.kag_.AddTagCallBack("faceblend", new KagScript.KagTagCallBack(this.TagMotFaceBlend)); base.kag.AddTagCallBack("penisikattach", new KagScript.KagTagCallBack(this.TagPenisIKAttach)); base.kag.AddTagCallBack("ikplanecolider", new KagScript.KagTagCallBack(this.TagIKPlaneColider)); base.kag.AddTagCallBack("ikcoliderborder", new KagScript.KagTagCallBack(this.TagIKColiderBorder)); base.kag.AddTagCallBack("ikcolidercorrect", new KagScript.KagTagCallBack(this.TagIKColiderCorrect)); base.kag.AddTagCallBack("ikcoliderenable", new KagScript.KagTagCallBack(this.TagIKColiderEnable)); base.kag.AddTagCallBack("ikcolidertarget", new KagScript.KagTagCallBack(this.TagIKColiderTarget)); base.kag.AddTagCallBack("ikcrosscolider", new KagScript.KagTagCallBack(this.TagIKCrossColider)); base.kag.AddTagCallBack("setpartner", new KagScript.KagTagCallBack(this.TagSetPartner)); base.kag.AddTagCallBack("iksetpelvispull", new KagScript.KagTagCallBack(base.TagIKSetPelvisPull)); base.kag.AddTagCallBack("kupatimer", new KagScript.KagTagCallBack(this.TagKupaTimer)); base.kag.AddTagCallBack("kupainsert", new KagScript.KagTagCallBack(this.TagKupaInsert)); base.kag.AddTagCallBack("shouldertwistcalc", new KagScript.KagTagCallBack(this.TagShoulderTwistCalc)); base.kag.AddTagCallBack("motionoffset", new KagScript.KagTagCallBack(this.TagMotionOffset)); base.kag.AddTagCallBack("autooffset", new KagScript.KagTagCallBack(this.TagAutoOffset)); base.kag.AddTagCallBack("inverseoffset", new KagScript.KagTagCallBack(this.TagInverseOffset)); base.kag.AddTagCallBack("setikorder", new KagScript.KagTagCallBack(this.TagSetIKOrder)); base.kag.AddTagCallBack("setberomorph", new KagScript.KagTagCallBack(this.TagSetBeroMorph)); } private void LoadMotionScriptMeta() { if (!GameUty.FileSystem.IsExistentFile("motionscript.msmeta")) { return; } using (AFileBase afileBase = GameUty.FileSystem.FileOpen("motionscript.msmeta")) { if (afileBase.IsValid()) { byte[] buffer = afileBase.ReadAll(); this.MotionScriptMetaDic.Clear(); using (MemoryStream memoryStream = new MemoryStream(buffer)) { using (StreamReader streamReader = new StreamReader(memoryStream)) { string json = streamReader.ReadToEnd(); MotionKagManager.MotionScriptMetaPackage motionScriptMetaPackage = JsonUtility.FromJson(json); foreach (MotionKagManager.MotionScriptMeta motionScriptMeta in motionScriptMetaPackage.metaList) { this.MotionScriptMetaDic[motionScriptMeta.scriptName] = motionScriptMeta; } } } } else { Debug.LogErrorFormat("{0}はありませんでした", new object[] { "motionscript.msmeta" }); } } } public Maid SetMainMaid(Maid maid) { this.main_maid_ = maid; return this.main_maid_; } public Maid SetMainMaid(string maid_guid) { if (string.IsNullOrEmpty(maid_guid)) { this.main_maid_ = null; return null; } for (int i = 0; i < GameMain.Instance.CharacterMgr.GetMaidCount(); i++) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(i); if (maid != null && maid.status.guid == maid_guid) { this.main_maid_ = maid; break; } } return this.main_maid_; } public Maid SetMainMan(Maid man) { this.main_man_ = man; return this.main_man_; } public Maid SetMainMan(string man_guid) { if (string.IsNullOrEmpty(man_guid)) { this.main_man_ = null; return null; } for (int i = 0; i < GameMain.Instance.CharacterMgr.GetManCount(); i++) { Maid man = GameMain.Instance.CharacterMgr.GetMan(i); if (man != null && man.status.guid == man_guid) { this.main_man_ = man; break; } } return this.main_man_; } public override void LoadScriptFile(string fileName, string labelName = "") { string currentFileName = base.kag.GetCurrentFileName(); string currentLabel = base.kag.GetCurrentLabel(); bool flag = fileName != currentFileName; bool flag2 = labelName != currentLabel; this.CurrentScriptMeta = this.GetMotionScriptMeta(fileName); if (flag) { this.LoadActiveChara(); } else if (this.main_maid || this.main_man) { if (this.main_man && (!this.ActiveManList.Contains(this.main_man) || this.ActiveManList.Count > 1)) { this.ActiveManList.Clear(); this.ActiveManList.Add(this.main_man); } if (this.main_maid && (!this.ActiveMaidList.Contains(this.main_maid) || this.ActiveMaidList.Count > 1)) { this.ActiveMaidList.Clear(); this.ActiveMaidList.Add(this.main_maid); } } else { if (this.ActiveMaidList.Any((Maid ch) => !ch.Visible)) { for (int i = 0; i < this.ActiveMaidList.Count; i++) { Maid maid6 = this.ActiveMaidList[i]; if (!maid6.Visible) { this.ActiveMaidList.Remove(maid6); } } } if (this.ActiveManList.Any((Maid ch) => !ch.Visible)) { for (int j = 0; j < this.ActiveManList.Count; j++) { Maid maid2 = this.ActiveManList[j]; if (!maid2.Visible) { this.ActiveManList.Remove(maid2); } } } } MotionKagManager.MotionScriptMeta currentScriptMeta = this.CurrentScriptMeta; if (currentScriptMeta != null) { if (!this.main_maid && currentScriptMeta.maidCount == 1) { Debug.LogFormat("{0}にメイドの指定がなかったのでメイド0番を自動的に割り振りました", new object[] { fileName }); this.main_maid_ = GameMain.Instance.CharacterMgr.GetMaid(0); this.ActiveMaidList.Clear(); this.ActiveMaidList.Add(this.main_maid); } if (!this.main_man && currentScriptMeta.manCount == 1) { Debug.LogFormat("{0}に男の指定がなかったので男0番を自動的に割り振りました", new object[] { fileName }); this.main_man_ = GameMain.Instance.CharacterMgr.GetMan(0); this.ActiveManList.Clear(); this.ActiveManList.Add(this.main_man); } } bool flag3; if (this.main_maid) { flag3 = this.main_maid.IsCrcBody; } else if (this.ActiveMaidList.Count > 0) { flag3 = this.ActiveMaidList.Any((Maid ch) => ch.IsCrcBody); } else if (this.main_man) { flag3 = this.main_man.IsCrcBody; } else { flag3 = this.ActiveManList.Any((Maid ch) => ch.IsCrcBody); } if (!flag3) { for (int k = 0; k < this.ActiveManList.Count; k++) { Maid maid3 = this.ActiveManList[k]; if (maid3.IsCrcBody) { int activeSlotNo = maid3.ActiveSlotNo; GameMain.Instance.CharacterMgr.SwapNewManBody(activeSlotNo, false); Maid man = GameMain.Instance.CharacterMgr.GetMan(activeSlotNo); this.ActiveManList[k] = man; maid3 = man; maid3.AllProcProp(); if (this.main_man) { this.main_man_ = maid3; } } } base.LoadScriptFile(fileName, labelName); return; } if (fileName.IndexOf("crc_") != 0) { fileName = "crc_" + fileName; } if (!GameUty.IsExistFile(fileName, null)) { Debug.LogWarningFormat("{0}が見つからなかったので{1}を読み込みました。", new object[] { fileName, fileName.Replace("crc_", string.Empty) }); base.LoadScriptFile(fileName.Replace("crc_", string.Empty), labelName); return; } if (this.main_maid || this.main_man) { if (this.main_maid && this.main_maid.body0.isMotionScriptSet && !this.main_maid.body0.IsMotionScritChange(fileName, labelName)) { Debug.LogWarningFormat("Maid{0}に同フレーム内で同じモーションスクリプトが読み込まれました", new object[] { this.main_maid.ActiveSlotNo }); return; } if (this.main_man && this.main_man.body0.isMotionScriptSet && !this.main_man.body0.IsMotionScritChange(fileName, labelName)) { Debug.LogWarningFormat("Man{0}に同フレーム内で同じモーションスクリプトが読み込まれました", new object[] { this.main_man.ActiveSlotNo }); return; } } for (int l = 0; l < this.ActiveMaidList.Count; l++) { Maid maid4 = this.ActiveMaidList[l]; if (maid4.body0.isMotionScriptSet && !maid4.body0.IsMotionScritChange(fileName, labelName)) { Debug.LogWarningFormat("Maid{0}に同フレーム内で同じモーションスクリプトが読み込まれました", new object[] { maid4.ActiveSlotNo }); this.ActiveMaidList.Remove(maid4); } else if (!this.isBodyMixOK && !maid4.IsCrcBody && fileName != "crc_workFF_001.ks") { NDebug.Assert("新ボディと旧ボディのキャラが混在しています。旧ボディキャラ:" + maid4.name, false); return; } } for (int m = 0; m < this.ActiveManList.Count; m++) { Maid maid5 = this.ActiveManList[m]; if (maid5.body0.isMotionScriptSet && !maid5.body0.IsMotionScritChange(fileName, labelName)) { Debug.LogWarningFormat("Man{0}に同フレーム内で同じモーションスクリプトが読み込まれました", new object[] { maid5.ActiveSlotNo }); this.ActiveManList.Remove(maid5); } else if (!maid5.IsCrcBody) { int activeSlotNo2 = maid5.ActiveSlotNo; GameMain.Instance.CharacterMgr.SwapNewManBody(activeSlotNo2, true); Maid man = GameMain.Instance.CharacterMgr.GetMan(activeSlotNo2); this.ActiveManList[m] = man; maid5 = man; maid5.AllProcProp(); if (this.main_man) { this.main_man_ = maid5; } } } if (this.ActiveMaidList.Count == 0 && this.ActiveManList.Count == 0) { Debug.LogWarning("モーションを再生できるキャラが1人もいません"); return; } if (this.isBodyMixOK) { bool flag4 = this.ActiveMaidList.Any((Maid maid) => !maid.IsCrcBody); if (flag4) { this.isBodyMixOK = false; Action> action = delegate(List chara_list) { List list = new List(chara_list); for (int n = 0; n < list.Count; n++) { Maid maid7 = list[n]; if (maid7.boMAN) { this.SetMainMan(maid7); } else { this.SetMainMaid(maid7); } string path = (!maid7.IsCrcBody) ? fileName.Replace("crc_", string.Empty) : fileName; this.LoadScriptFile(string.Format("{0}_{1}.ks", Path.GetFileNameWithoutExtension(path), maid7.ActiveSlotNo), labelName); if (n < list.Count - 1) { this.Exec(); } } }; action(this.ActiveManList); action(this.ActiveMaidList); this.isBodyMixOK = true; return; } } foreach (Maid chara in this.ActiveManList) { this.MotionSettingReset(chara, fileName, labelName); } foreach (Maid chara2 in this.ActiveMaidList) { this.MotionSettingReset(chara2, fileName, labelName); } base.LoadScriptFile(fileName, "*共通"); this.Exec(); base.LoadScriptFile(fileName, labelName); } private MotionKagManager.MotionScriptMeta GetMotionScriptMeta(string file_name) { if (this.MotionScriptMetaDic.ContainsKey(file_name)) { return this.MotionScriptMetaDic[file_name]; } file_name = file_name.Replace("crc_", string.Empty); if (this.MotionScriptMetaDic.ContainsKey(file_name)) { return this.MotionScriptMetaDic[file_name]; } return null; } private void LoadActiveChara() { CharacterMgr characterMgr = GameMain.Instance.CharacterMgr; this.ActiveMaidList.Clear(); if (this.main_maid) { this.ActiveMaidList.Add(this.main_maid); } else { for (int i = 0; i < characterMgr.GetMaidCount(); i++) { if (this.CurrentScriptMeta != null && this.CurrentScriptMeta.maidCount == this.ActiveMaidList.Count) { break; } Maid maid = characterMgr.GetMaid(i); if (maid && maid.Visible) { this.ActiveMaidList.Add(maid); } } } this.ActiveManList.Clear(); if (this.main_man) { this.ActiveManList.Add(this.main_man); } else { for (int j = 0; j < characterMgr.GetManCount(); j++) { if (this.CurrentScriptMeta != null && this.CurrentScriptMeta.manCount == this.ActiveManList.Count) { break; } Maid man = characterMgr.GetMan(j); if (man && man.Visible) { this.ActiveManList.Add(man); } } } } private void MotionSettingReset(Maid chara, string fileName, string labelName) { MotionKagManager.MotionSettingReset(chara); chara.body0.SetMotionScriptInfo(fileName, labelName); } public static void MotionSettingReset(Maid chara) { if (!chara.body0.IsCrcBody) { return; } if (!chara.boMAN) { chara.body0.SetMuneYureL(true); chara.body0.SetMuneYureR(true); chara.body0.KupaReset(); } for (int i = 2; i <= 5; i++) { chara.body0.StopAnimeLayer(i); } chara.body0.SetShoulderTwistCalcType(true, ShoulderTwist.CalcType.Normal); chara.body0.SetShoulderTwistCalcType(false, ShoulderTwist.CalcType.Normal); chara.body0.fullBodyIK.IKReset(); chara.motionOffsetGP03 = Vector3.zero; if (chara.body0.Face.tongueCtrl != null) { chara.body0.Face.tongueCtrl.TongueReset(); } } public override bool TagMotion(KagTagSupport tag_data) { Maid maid = base.GetMaidAndMan(tag_data, true); if (maid == null) { return false; } base.CheckAbsolutelyNecessaryTag(tag_data, "motion", new string[] { "mot" }); string play_motion_name = tag_data.GetTagProperty("mot").AsString() + ".anm"; if (maid.body0.IsCrcBody && play_motion_name.IndexOf("crc_") != 0) { string text = "crc_" + play_motion_name; if (GameUty.IsExistFile(text, null)) { play_motion_name = text; } } int blend = 500; if (tag_data.IsValid("blend")) { blend = tag_data.GetTagProperty("blend").AsInteger(); } bool loop = false; if (tag_data.IsValid("loop")) { loop = tag_data.GetTagProperty("loop").AsBool(); } int num = 0; if (tag_data.IsValid("wait")) { num = tag_data.GetTagProperty("wait").AsInteger(); } WaitEventList waitEventList = base.GetWaitEventList("motion"); if (num <= 0) { if (maid.Visible) { this.PlayMaidMotion(maid, play_motion_name, false, loop, false, GameUty.MillisecondToSecond(blend)); } waitEventList.Clear(); } else { waitEventList.Add(delegate { if (maid != null && maid.Visible && maid.body0 != null && maid.body0.isLoadedBody) { this.PlayMaidMotion(maid, play_motion_name, false, loop, false, GameUty.MillisecondToSecond(blend)); } }, num); } return false; } public override bool TagMotionNext(KagTagSupport tag_data) { Maid maid = base.GetMaidAndMan(tag_data, true); if (maid == null) { return false; } base.CheckAbsolutelyNecessaryTag(tag_data, "motionnext", new string[] { "mot" }); string play_motion_name = tag_data.GetTagProperty("mot").AsString() + ".anm"; if (maid.body0.IsCrcBody && play_motion_name.IndexOf("crc_") != 0) { string text = "crc_" + play_motion_name; if (GameUty.IsExistFile(text, null)) { play_motion_name = text; } } int blend = 500; if (tag_data.IsValid("blend")) { blend = tag_data.GetTagProperty("blend").AsInteger(); } bool loop = false; if (tag_data.IsValid("loop")) { loop = tag_data.GetTagProperty("loop").AsBool(); } WaitEventList waitEventList = base.GetWaitEventList("motion"); if (waitEventList.list.Count <= 0) { if (maid.Visible) { this.PlayMaidMotion(maid, play_motion_name, false, loop, true, GameUty.MillisecondToSecond(blend)); } waitEventList.Clear(); } else { int wait_time = waitEventList.list[waitEventList.list.Count - 1].wait_time; waitEventList.Add(delegate { if (maid != null && maid.Visible) { this.PlayMaidMotion(maid, play_motion_name, false, loop, true, GameUty.MillisecondToSecond(blend)); } }, wait_time); } return false; } private bool TagPenisIKAttach(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "penisikattach", new string[] { "man", "target", "targetbone", "insert_before", "insert_after" }); Maid man = this.GetMan(tagData.GetTagProperty("man").AsInteger()); Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("target").AsString()); if (!man || !maidAndMan) { return false; } PenisIKParam penisIKParam = new PenisIKParam(man, maidAndMan); penisIKParam.targetBoneName = tagData.GetTagProperty("targetbone").AsString(); IKScriptHelper.SetPenisIKPatam(penisIKParam, tagData); man.body0.fullBodyIK.IKAttach(FullBodyIKMgr.IKEffectorType.Penis, penisIKParam); return false; } public bool TagIKPlaneColider(KagTagSupport tagData) { bool flag = tagData.IsValid("on"); if (tagData.IsValid("src")) { Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString()); if (!maidAndMan) { return false; } if (tagData.IsValid("colider")) { string a = tagData.GetTagProperty("colider").AsString(); if (a == "floor") { maidAndMan.body0.fullBodyIK.floorColliderEnable = flag; } else { maidAndMan.body0.fullBodyIK.wallColliderEnable = flag; } } else { maidAndMan.body0.fullBodyIK.floorColliderEnable = flag; maidAndMan.body0.fullBodyIK.wallColliderEnable = flag; } } else { for (int i = 0; i < GameMain.Instance.CharacterMgr.GetMaidCount(); i++) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(i); if (maid) { if (tagData.IsValid("colider")) { string a2 = tagData.GetTagProperty("colider").AsString(); if (a2 == "floor") { maid.body0.fullBodyIK.floorColliderEnable = flag; } else { maid.body0.fullBodyIK.wallColliderEnable = flag; } } else { maid.body0.fullBodyIK.floorColliderEnable = flag; maid.body0.fullBodyIK.wallColliderEnable = flag; } } } for (int j = 0; j < GameMain.Instance.CharacterMgr.GetManCount(); j++) { Maid man = GameMain.Instance.CharacterMgr.GetMan(j); if (man) { if (tagData.IsValid("colider")) { string a3 = tagData.GetTagProperty("colider").AsString(); if (a3 == "floor") { man.body0.fullBodyIK.floorColliderEnable = flag; } else { man.body0.fullBodyIK.wallColliderEnable = flag; } } else { man.body0.fullBodyIK.floorColliderEnable = flag; man.body0.fullBodyIK.wallColliderEnable = flag; } } } } return false; } public bool TagIKColiderBorder(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "ikcoliderborder", new string[] { "colider", "value" }); string a = tagData.GetTagProperty("colider").AsString(); float num = tagData.GetTagProperty("value").AsReal(); string text = (!tagData.IsValid("srcbone")) ? string.Empty : tagData.GetTagProperty("srcbone").AsString(); if (tagData.IsValid("src")) { Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString()); if (!maidAndMan) { return false; } if (a == "floor") { if (string.IsNullOrEmpty(text)) { maidAndMan.body0.fullBodyIK.floorColliderEnable = true; maidAndMan.body0.fullBodyIK.floorColliderY = num; } else { NativePlaneCollider floorCollider = maidAndMan.body0.fullBodyIK.GetFloorCollider(text); if (floorCollider) { floorCollider.enabled = true; floorCollider.status.center.y = num; } } } else if (string.IsNullOrEmpty(text)) { maidAndMan.body0.fullBodyIK.wallColliderEnable = true; maidAndMan.body0.fullBodyIK.wallColliderZ = num; maidAndMan.fullBodyIK.wallDirectionInverse = (a == "wallfront"); } else { NativePlaneCollider wallCollider = maidAndMan.body0.fullBodyIK.GetWallCollider(text); if (wallCollider) { wallCollider.enabled = true; wallCollider.status.center.z = num; wallCollider.planeStatus.isDirectionInverse = (a == "wallfront"); } } } else { for (int i = 0; i < GameMain.Instance.CharacterMgr.GetMaidCount(); i++) { Maid maid = GameMain.Instance.CharacterMgr.GetMaid(i); if (maid) { if (a == "floor") { if (string.IsNullOrEmpty(text)) { maid.body0.fullBodyIK.floorColliderEnable = true; maid.body0.fullBodyIK.floorColliderY = num; } else { NativePlaneCollider floorCollider2 = maid.body0.fullBodyIK.GetFloorCollider(text); if (floorCollider2) { floorCollider2.enabled = true; floorCollider2.status.center.y = num; } } } else if (string.IsNullOrEmpty(text)) { maid.body0.fullBodyIK.wallColliderEnable = true; maid.body0.fullBodyIK.wallColliderZ = num; maid.fullBodyIK.wallDirectionInverse = (a == "wallfront"); } else { NativePlaneCollider wallCollider2 = maid.body0.fullBodyIK.GetWallCollider(text); if (wallCollider2) { wallCollider2.enabled = true; wallCollider2.status.center.z = num; wallCollider2.planeStatus.isDirectionInverse = (a == "wallfront"); } } } } for (int j = 0; j < GameMain.Instance.CharacterMgr.GetManCount(); j++) { Maid man = GameMain.Instance.CharacterMgr.GetMan(j); if (man) { if (a == "floor") { if (string.IsNullOrEmpty(text)) { man.body0.fullBodyIK.floorColliderEnable = true; man.body0.fullBodyIK.floorColliderY = num; } else { NativePlaneCollider floorCollider3 = man.body0.fullBodyIK.GetFloorCollider(text); if (floorCollider3) { floorCollider3.enabled = true; floorCollider3.status.center.y = num; } } } else if (string.IsNullOrEmpty(text)) { man.body0.fullBodyIK.wallColliderEnable = true; man.body0.fullBodyIK.wallColliderZ = num; man.fullBodyIK.wallDirectionInverse = (a == "wallfront"); } else { NativePlaneCollider wallCollider3 = man.body0.fullBodyIK.GetWallCollider(text); if (wallCollider3) { wallCollider3.enabled = true; wallCollider3.status.center.z = num; wallCollider3.planeStatus.isDirectionInverse = (a == "wallfront"); } } } } } return false; } public bool TagIKColiderCorrect(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "ikcolidercorrect", new string[] { "src", "srcbone", "correcttype" }); Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString()); if (!maidAndMan) { return false; } ALimbIKCtrl ikctrl = maidAndMan.body0.fullBodyIK.GetIKCtrl(tagData.GetTagProperty("srcbone").AsString()); if (!ikctrl) { return false; } ikctrl.correctType = (ALimbIKCtrl.BorderCorrectType)Enum.Parse(typeof(ALimbIKCtrl.BorderCorrectType), tagData.GetTagProperty("correcttype").AsString()); return false; } public bool TagIKColiderEnable(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "ikcoliderenable", new string[] { "src", "srcbone" }); Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString()); if (!maidAndMan) { return false; } ALimbIKCtrl ikctrl = maidAndMan.body0.fullBodyIK.GetIKCtrl(tagData.GetTagProperty("srcbone").AsString()); if (!ikctrl) { return false; } ikctrl.colliderEnable = tagData.IsValid("on"); return false; } public bool TagIKColiderTarget(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "ikcolidertarget", new string[] { "src", "srcbone", "target", "targetbone" }); Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString()); Maid maidAndMan2 = base.GetMaidAndMan(tagData.GetTagProperty("target").AsString()); if (!maidAndMan || !maidAndMan2) { return false; } string tag_name = IKScriptHelper.ConvertColliderNameToIKName(tagData.GetTagProperty("srcbone").AsString()); ALimbIKCtrl ikctrl = maidAndMan.fullBodyIK.GetIKCtrl(tag_name); string tag_name2 = IKScriptHelper.ConvertColliderNameToIKName(tagData.GetTagProperty("targetbone").AsString()); ALimbIKCtrl ikctrl2 = maidAndMan2.fullBodyIK.GetIKCtrl(tag_name2); if (!ikctrl || !ikctrl2) { return false; } ikctrl.AddHitCheckLimb(ikctrl2); return false; } public bool TagIKCrossColider(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "ikcrosscolider", new string[] { "src", "body" }); Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString()); if (!maidAndMan) { return false; } string a = tagData.GetTagProperty("body").AsString(); if (a == "上半身") { maidAndMan.fullBodyIK.upperBorderEnable = true; } else if (a == "下半身") { maidAndMan.fullBodyIK.lowerBorderEnable = true; } return false; } public bool TagSetPartner(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "setpartner", new string[] { "partnerlist" }); string[] array = tagData.GetTagProperty("partnerlist").AsString().Split(new char[] { ',' }); if (array.Length <= 1) { Debug.LogError("@setpartnerはキャラクターを2人以上指定してください"); return false; } for (int i = 0; i < array.Length; i++) { Maid maidAndMan = base.GetMaidAndMan(array[i]); if (maidAndMan) { for (int j = i + 1; j < array.Length; j++) { Maid maidAndMan2 = base.GetMaidAndMan(array[j]); if (maidAndMan2) { maidAndMan.body0.fullBodyIK.AddPartner(maidAndMan2, true); } } } } return false; } private bool TagKupaTimer(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "kupatimer", new string[] { "maid", "morph", "move", "time" }); Maid maid = this.GetMaid(tagData.GetTagProperty("maid").AsInteger()); if (!maid) { return false; } AutoKupaCtrl.MorphType morph_type = (AutoKupaCtrl.MorphType)Enum.Parse(typeof(AutoKupaCtrl.MorphType), tagData.GetTagProperty("morph").AsString()); AutoKupaCtrl kupaCtrl = maid.body0.GetKupaCtrl(morph_type); AutoKupaCtrl.KupaType kupa_type = (AutoKupaCtrl.KupaType)Enum.Parse(typeof(AutoKupaCtrl.KupaType), tagData.GetTagProperty("move").AsString()); float kupa_time = MathUtility.MillisecondToSecond(tagData.GetTagProperty("time").AsInteger()); float wait = 0f; if (tagData.IsValid("wait")) { wait = MathUtility.MillisecondToSecond(tagData.GetTagProperty("wait").AsInteger()); } float kupaSpeed = (!tagData.IsValid("kupaspeed")) ? 1f : MathUtility.PercentageToRatio(tagData.GetTagProperty("kupaspeed").AsInteger(), false); float morphValueMax = (!tagData.IsValid("kupamax")) ? 1f : MathUtility.PercentageToRatio(tagData.GetTagProperty("kupamax").AsInteger(), false); kupaCtrl.kupaSpeed = kupaSpeed; kupaCtrl.morphValueMax = morphValueMax; kupaCtrl.SetKupaTimer(kupa_type, kupa_time, wait); return false; } private bool TagKupaInsert(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "kupainsert", new string[] { "maid", "morph", "target", "insert", "insertaxis" }); Maid maid = this.GetMaid(tagData.GetTagProperty("maid").AsInteger()); if (!maid) { return false; } AutoKupaCtrl.MorphType morph_type = (AutoKupaCtrl.MorphType)Enum.Parse(typeof(AutoKupaCtrl.MorphType), tagData.GetTagProperty("morph").AsString()); AutoKupaCtrl kupaCtrl = maid.body0.GetKupaCtrl(morph_type); Vector3 insert_axis = MathUtility.Vec3Parse(tagData.GetTagProperty("insertaxis").AsString(), ','); kupaCtrl.morphInsert.kupaSpeedIn = (kupaCtrl.morphInsert.kupaSpeedOut = 1f); kupaCtrl.SetInsertParamFromScript(tagData); string text = tagData.GetTagProperty("target").AsString(); if (text == "bgitem") { string item_name = tagData.GetTagProperty("insert").AsString(); kupaCtrl.SetKupaInsertFromBgItem(item_name, insert_axis); } else { Maid maidAndMan = base.GetMaidAndMan(text); if (!maidAndMan) { return false; } AutoKupaCtrl.InsertObjType insert = (AutoKupaCtrl.InsertObjType)Enum.Parse(typeof(AutoKupaCtrl.InsertObjType), tagData.GetTagProperty("insert").AsString()); kupaCtrl.SetKupaInsert(insert, maidAndMan.body0, insert_axis); } return false; } private bool TagShoulderTwistCalc(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "shouldertwistcalc", new string[] { "src", "calctype" }); Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString()); ShoulderTwist.CalcType calc_mode = (ShoulderTwist.CalcType)Enum.Parse(typeof(ShoulderTwist.CalcType), tagData.GetTagProperty("calctype").AsString()); if (tagData.IsValid("shoulder")) { bool is_left = tagData.GetTagProperty("shoulder").AsString() == "left"; maidAndMan.body0.SetShoulderTwistCalcType(is_left, calc_mode); } else { maidAndMan.body0.SetShoulderTwistCalcType(true, calc_mode); maidAndMan.body0.SetShoulderTwistCalcType(false, calc_mode); } return false; } private bool TagMotionOffset(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "motionoffset", new string[] { "target" }); if (!tagData.IsValid("set") && !tagData.IsValid("add")) { Debug.LogError("@motionoffset:数値指定がありません"); return false; } Maid src_chara = null; if (tagData.IsValid("src")) { src_chara = base.GetMaidAndMan(tagData.GetTagProperty("src").AsString()); } string[] array = tagData.GetTagProperty("target").AsString().Split(new char[] { ',' }); Func func = delegate(string tag, Maid chara) { Vector3 result = Vector3.zero; string text = tagData.GetTagProperty(tag).AsString(); if (text.Contains("min") && text.Contains("max")) { string[] array3 = text.Split(new char[] { ':' }); MaidProp maidProp = null; try { MPN mpn = (MPN)Enum.Parse(typeof(MPN), array3[0]); maidProp = ((!(src_chara != null)) ? chara.GetProp(mpn) : src_chara.GetProp(mpn)); } catch { Debug.LogError("エディットのパラメータが指定されてません"); return result; } Vector3 a = MathUtility.Vec3Parse(array3[1].Split(new char[] { '=' })[1], ','); Vector3 b2 = MathUtility.Vec3Parse(array3[2].Split(new char[] { '=' })[1], ','); if (maidProp.value > maidProp.value_Default) { float t = Mathf.InverseLerp((float)maidProp.value_Default, (float)maidProp.max, (float)maidProp.value); result = Vector3.Lerp(Vector3.zero, b2, t); } else if (maidProp.value < maidProp.value_Default) { float t2 = Mathf.InverseLerp((float)maidProp.min, (float)maidProp.value_Default, (float)maidProp.value); result = Vector3.Lerp(a, Vector3.zero, t2); } return result; } result = MathUtility.Vec3Parse(text, ','); return result; }; foreach (string tag_str in array) { Maid maidAndMan = base.GetMaidAndMan(tag_str); if (maidAndMan) { Vector3 motionOffsetGP = Vector3.zero; Vector3 b = Vector3.zero; bool flag = tagData.IsValid("set"); if (flag) { motionOffsetGP = func("set", maidAndMan); } if (tagData.IsValid("add")) { b = func("add", maidAndMan); } if (flag) { maidAndMan.motionOffsetGP03 = motionOffsetGP; } maidAndMan.motionOffsetGP03 += b; } } return false; } private bool TagAutoOffset(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "autooffset", new string[] { "target" }); if (!tagData.IsValid("set") && !tagData.IsValid("add")) { Debug.LogError("@motionoffset:数値指定がありません"); return false; } string[] array = tagData.GetTagProperty("target").AsString().Split(new char[] { ',' }); bool flag = GameMain.Instance.CMSystem.GetTmpGenericFlag("AddAllOffset_Ignore") == 1; Func func = delegate(string tag, Maid chara) { Vector3 result = Vector3.zero; string text = tagData.GetTagProperty(tag).AsString(); if (text.Contains("min") && text.Contains("max")) { string[] array3 = text.Split(new char[] { ':' }); MaidProp maidProp = null; try { MPN mpn = (MPN)Enum.Parse(typeof(MPN), array3[0]); maidProp = chara.GetProp(mpn); } catch { Debug.LogError("エディットのパラメータが指定されてません"); return result; } Vector3 a = MathUtility.Vec3Parse(array3[1].Split(new char[] { '=' })[1], ','); Vector3 b = MathUtility.Vec3Parse(array3[2].Split(new char[] { '=' })[1], ','); if (maidProp.value > maidProp.value_Default) { float t = Mathf.InverseLerp((float)maidProp.value_Default, (float)maidProp.max, (float)maidProp.value); result = Vector3.Lerp(Vector3.zero, b, t); } else if (maidProp.value < maidProp.value_Default) { float t2 = Mathf.InverseLerp((float)maidProp.min, (float)maidProp.value_Default, (float)maidProp.value); result = Vector3.Lerp(a, Vector3.zero, t2); } return result; } result = MathUtility.Vec3Parse(text, ','); return result; }; foreach (string tag_str in array) { Maid maidAndMan = base.GetMaidAndMan(tag_str); if (maidAndMan) { Vector3 vector = Vector3.zero; Vector3 vector2 = Vector3.zero; bool flag2 = tagData.IsValid("set"); if (flag2) { vector = func("set", maidAndMan); } if (tagData.IsValid("add")) { vector2 = func("add", maidAndMan); } if (flag) { vector = -vector; vector2 = -vector2; if (flag2) { maidAndMan.fullBodyIK.floorColliderY = vector.y; maidAndMan.fullBodyIK.wallColliderZ = vector.z; } maidAndMan.fullBodyIK.floorColliderY += vector2.y; maidAndMan.fullBodyIK.wallColliderZ += vector2.z; } else { if (flag2) { maidAndMan.motionOffsetGP03 = vector; } maidAndMan.motionOffsetGP03 += vector2; } } } return false; } private bool TagInverseOffset(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "inverseoffset", new string[] { "target" }); if (GameMain.Instance.CMSystem.GetTmpGenericFlag("AddAllOffset_Ignore") != 1) { return false; } string[] array = tagData.GetTagProperty("target").AsString().Split(new char[] { ',' }); Vector3 vector = Vector3.zero; if (tagData.IsValid("y")) { vector.y = tagData.GetTagProperty("y").AsReal(); } vector = -vector; foreach (string tag_str in array) { Maid maidAndMan = base.GetMaidAndMan(tag_str); if (maidAndMan) { maidAndMan.motionOffsetGP03 = vector; maidAndMan.fullBodyIK.floorColliderY = vector.y; maidAndMan.fullBodyIK.wallColliderZ = vector.z; } } return false; } private bool TagSetIKOrder(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "setikorder", new string[] { "order" }); string[] array = tagData.GetTagProperty("order").AsString().Split(new char[] { ',' }); if (array.Length <= 1) { Debug.LogError("@setikorderはキャラクターを2人以上指定してください"); return false; } for (int i = 0; i < array.Length; i++) { Maid maidAndMan = base.GetMaidAndMan(array[i]); if (maidAndMan) { maidAndMan.body0.fullBodyIK.ikExecOrder = i; } } return false; } private bool TagSetBeroMorph(KagTagSupport tagData) { base.CheckAbsolutelyNecessaryTag(tagData, "setberomorph", new string[] { "target" }); Maid maidAndMan = base.GetMaidAndMan(tagData.GetTagProperty("target").AsString()); TongueCtrl tongueCtrl = maidAndMan.body0.Face.tongueCtrl; if (tongueCtrl == null) { return false; } tongueCtrl.isEnable = true; tongueCtrl.BlendStatusReset(); if (tagData.IsValid("blend")) { tongueCtrl.blendTime = MathUtility.MillisecondToSecond(tagData.GetTagProperty("blend").AsInteger()); } foreach (TongueCtrl.FaceMorph morph in TongueCtrl.TongueUseMorph) { string morphName = tongueCtrl.GetMorphData(morph).morphName; if (tagData.IsValid(morphName)) { float value = MathUtility.PercentageToRatio(tagData.GetTagProperty(morphName).AsInteger(), false); tongueCtrl.SetTargetValue(morph, value); } } return false; } private bool TagSetMaidOffsetMultiPos2(KagTagSupport tag_data) { if (this.valid_pos) { base.TagSetMaidOffsetMultiPos(tag_data); } return false; } private bool TagMotAllProcPropSeqStart(KagTagSupport tag_data) { Maid maidAndMan = base.GetMaidAndMan(tag_data, true); if (maidAndMan == null) { return false; } if (tag_data.IsValid("fix")) { maidAndMan.AllProcProp(); } else { NDebug.Assert(!this.script_mgr_.is_motion_all_prop_seq, "MotionKagManager AllProcPropSeqStart error."); this.script_mgr_.is_motion_all_prop_seq = true; this.script_mgr_.motion_all_prop_seq_maid = maidAndMan; } return false; } private bool TagMotFace(KagTagSupport tag_data) { return !this.face_fix_ && base.TagFace(tag_data); } private bool TagMotFaceBlend(KagTagSupport tag_data) { return !this.face_fix_ && base.TagFaceBlend(tag_data); } public void SetNextMotion(bool is_next) { this.next_flag_ = is_next; } public void SetFaceFix(bool is_fix) { this.face_fix_ = is_fix; } protected override void PlayMaidMotion(Maid maid, string fn, bool additive = false, bool loop = false, bool boAddQue = false, float val = 0.5f) { if (this.next_flag_) { boAddQue = true; this.next_flag_ = false; } base.PlayMaidMotion(maid, fn, additive, loop, boAddQue, val); if (!maid.boMAN && !boAddQue && 0 <= maid.ActiveSlotNo && maid.ActiveSlotNo < this.last_maid_motion_set_log_.Length) { this.last_maid_motion_set_log_[maid.ActiveSlotNo] = fn.ToLower(); } else if (maid.boMAN && !boAddQue && 0 <= maid.ActiveSlotNo && maid.ActiveSlotNo < this.last_man_motion_set_log_.Length) { this.last_man_motion_set_log_[maid.ActiveSlotNo] = fn.ToLower(); } } public void ClearMotion() { this.exec_wait_data_.Clear(); this.wait_event_list_.Clear(); } public void SetSloatNo(int no) { this.sloat_no_ = no; } public override string GetKagClassName() { return "モーションkag : " + this.sloat_no_.ToString(); } public override Maid GetMaid(int no) { if (no == 0 && this.main_maid_ != null) { return this.main_maid_; } return base.GetMaid(no); } public override Maid GetMan(int man_no) { if (man_no == 0 && this.main_man_ != null) { return this.main_man_; } return base.GetMan(man_no); } public bool valid_pos { get { return this.valid_pos_; } set { this.valid_pos_ = value; } } public Maid main_maid { get { return this.main_maid_; } } public Maid main_man { get { return this.main_man_; } } public string[] last_maid_motion_set_log { get { return this.last_maid_motion_set_log_; } } public string[] last_man_motion_set_log { get { return this.last_man_motion_set_log_; } } private const string COMMON_SETTING_LABEL = "*共通"; private List ActiveMaidList = new List(); private List ActiveManList = new List(); public const string MOTIONSCRIPT_META_FILE = "motionscript.msmeta"; private Dictionary MotionScriptMetaDic = new Dictionary(); private MotionKagManager.MotionScriptMeta CurrentScriptMeta; public bool isBodyMixOK; private int sloat_no_; private bool next_flag_; private bool face_fix_; private Maid main_maid_; private Maid main_man_; private bool valid_pos_ = true; protected string[] last_maid_motion_set_log_ = new string[6]; protected string[] last_man_motion_set_log_ = new string[6]; [Serializable] public class MotionScriptMetaPackage { public List metaList = new List(); } [Serializable] public class MotionScriptMeta { public string scriptName; public int maidCount; public int manCount; } }