MeidoPhotoStudio.cs 5.7 KB

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