MeidoPhotoStudio.cs 5.6 KB

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