MeidoPhotoStudio.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityInjector;
  6. using UnityInjector.Attributes;
  7. namespace COM3D2.MeidoPhotoStudio.Plugin
  8. {
  9. [PluginName("Meido Photo Studio"), PluginVersion("0.0.0")]
  10. public class MeidoPhotoStudio : PluginBase
  11. {
  12. private static MonoBehaviour instance;
  13. private WindowManager windowManager;
  14. private MeidoManager meidoManager;
  15. private EnvironmentManager environmentManager;
  16. private MessageWindowManager messageWindowManager;
  17. private Constants.Scene currentScene;
  18. private bool initialized = false;
  19. private bool isActive = false;
  20. private bool uiActive = false;
  21. private MeidoPhotoStudio()
  22. {
  23. MeidoPhotoStudio.instance = this;
  24. }
  25. private void Awake()
  26. {
  27. DontDestroyOnLoad(this);
  28. Translation.Initialize("en");
  29. Constants.Initialize();
  30. }
  31. private void Start()
  32. {
  33. SceneManager.sceneLoaded += OnSceneLoaded;
  34. }
  35. private void Update()
  36. {
  37. if (currentScene == Constants.Scene.Daily)
  38. {
  39. if (Input.GetKeyDown(KeyCode.F6))
  40. {
  41. if (!initialized)
  42. {
  43. Initialize();
  44. windowManager.MainWindowVisible = true;
  45. }
  46. else
  47. {
  48. ReturnToMenu();
  49. }
  50. }
  51. if (isActive)
  52. {
  53. meidoManager.Update();
  54. windowManager.Update();
  55. }
  56. }
  57. }
  58. private void OnGUI()
  59. {
  60. if (uiActive)
  61. {
  62. windowManager.OnGUI();
  63. }
  64. }
  65. private void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
  66. {
  67. currentScene = (Constants.Scene)scene.buildIndex;
  68. // if (currentScene == Constants.Scene.Daily)
  69. // {
  70. // if (initialized)
  71. // {
  72. // }
  73. // }
  74. // else
  75. // {
  76. // if (initialized)
  77. // {
  78. // initialized = false;
  79. // }
  80. // }
  81. }
  82. private void ReturnToMenu()
  83. {
  84. if (meidoManager.IsBusy) return;
  85. meidoManager.DeactivateMeidos();
  86. environmentManager.Deactivate();
  87. messageWindowManager.Deactivate();
  88. isActive = false;
  89. uiActive = false;
  90. initialized = false;
  91. windowManager.MainWindowVisible = false;
  92. GameMain.Instance.SoundMgr.PlayBGM("bgm009.ogg", 1f, true);
  93. GameObject go = GameObject.Find("UI Root").transform.Find("DailyPanel").gameObject;
  94. go.SetActive(true);
  95. bool isNight = GameMain.Instance.CharacterMgr.status.GetFlag("時間帯") == 3;
  96. if (isNight)
  97. {
  98. GameMain.Instance.BgMgr.ChangeBg("ShinShitsumu_ChairRot_Night");
  99. }
  100. else
  101. {
  102. GameMain.Instance.BgMgr.ChangeBg("ShinShitsumu_ChairRot");
  103. }
  104. GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
  105. GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0.5609447f, 1.380762f, -1.382336f), true);
  106. GameMain.Instance.MainCamera.SetDistance(1.6f, true);
  107. GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(245.5691f, 6.273283f), true);
  108. }
  109. private void Initialize()
  110. {
  111. initialized = true;
  112. meidoManager = new MeidoManager();
  113. meidoManager.BeginCallMeidos += (s, a) => this.uiActive = false;
  114. meidoManager.EndCallMeidos += (s, a) => this.uiActive = true;
  115. environmentManager = new EnvironmentManager();
  116. messageWindowManager = new MessageWindowManager();
  117. windowManager = new WindowManager(meidoManager, environmentManager, messageWindowManager);
  118. environmentManager.Initialize();
  119. isActive = true;
  120. uiActive = true;
  121. #region maid stuff
  122. // if (maid)
  123. // {
  124. // maid.StopKuchipakuPattern();
  125. // maid.body0.trsLookTarget = GameMain.Instance.MainCamera.transform;
  126. // if (maid.Visible && maid.body0.isLoadedBody)
  127. // {
  128. // maid.CrossFade("pose_taiki_f.anm", false, true, false, 0f);
  129. // maid.SetAutoTwistAll(true);
  130. // maid.body0.MuneYureL(1f);
  131. // maid.body0.MuneYureR(1f);
  132. // maid.body0.jbMuneL.enabled = true;
  133. // maid.body0.jbMuneR.enabled = true;
  134. // }
  135. // maid.body0.SetMask(TBody.SlotID.wear, true);
  136. // maid.body0.SetMask(TBody.SlotID.skirt, true);
  137. // maid.body0.SetMask(TBody.SlotID.bra, true);
  138. // maid.body0.SetMask(TBody.SlotID.panz, true);
  139. // maid.body0.SetMask(TBody.SlotID.mizugi, true);
  140. // maid.body0.SetMask(TBody.SlotID.onepiece, true);
  141. // if (maid.body0.isLoadedBody)
  142. // {
  143. // for (int i = 0; i < maid.body0.goSlot.Count; i++)
  144. // {
  145. // List<THair1> fieldValue = Utility.GetFieldValue<TBoneHair_, List<THair1>>(maid.body0.goSlot[i].bonehair, "hair1list");
  146. // for (int j = 0; j < fieldValue.Count; ++j)
  147. // {
  148. // fieldValue[j].SoftG = new Vector3(0.0f, -3f / 1000f, 0.0f);
  149. // }
  150. // }
  151. // }
  152. // }
  153. #endregion
  154. GameObject dailyPanel = GameObject.Find("UI Root").transform.Find("DailyPanel").gameObject;
  155. dailyPanel.SetActive(false);
  156. }
  157. }
  158. }