Преглед на файлове

Call Activate on manager instantiation

habeebweeb преди 4 години
родител
ревизия
cb66adf1cd

+ 3 - 16
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/EffectManager.cs

@@ -8,24 +8,15 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public const string header = "EFFECT";
         public const string footer = "END_EFFECT";
         private readonly Dictionary<Type, IEffectManager> EffectManagers = new Dictionary<Type, IEffectManager>();
-        private readonly BloomEffectManager bloomEffectManager;
-
-        public EffectManager()
-        {
-            // Not going to add more effects because SceneCapture does it better anyway
-            bloomEffectManager = AddManager<BloomEffectManager>();
-            AddManager<DepthOfFieldEffectManager>();
-            AddManager<VignetteEffectManager>();
-            AddManager<FogEffectManager>();
-        }
 
         public T Get<T>() where T : IEffectManager
             => EffectManagers.ContainsKey(typeof(T)) ? (T)EffectManagers[typeof(T)] : default;
 
-        private T AddManager<T>() where T : IEffectManager, new()
+        public T AddManager<T>() where T : IEffectManager, new()
         {
             T manager = new T();
             EffectManagers[typeof(T)] = manager;
+            manager.Activate();
             return manager;
         }
 
@@ -69,10 +60,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             foreach (IEffectManager effectManager in EffectManagers.Values) effectManager.Deactivate();
         }
 
-        public void Update()
-        {
-            // Bloom is the only effect that needs to update because I'm dumb/lazy
-            bloomEffectManager.Update();
-        }
+        public void Update() { }
     }
 }

+ 7 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/EnvironmentManager.cs

@@ -56,8 +56,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         }
         private float defaultCameraMoveSpeed;
         private float defaultCameraZoomSpeed;
-        private float cameraFastMoveSpeed = 0.1f;
-        private float cameraFastZoomSpeed = 2f;
+        private const float cameraFastMoveSpeed = 0.1f;
+        private const float cameraFastZoomSpeed = 2f;
 
         static EnvironmentManager()
         {
@@ -67,7 +67,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             Input.Register(MpsKey.CameraReset, KeyCode.R, "Reset camera transform");
         }
 
-        public EnvironmentManager() => DragPointLight.EnvironmentManager = this;
+        public EnvironmentManager()
+        {
+            DragPointLight.EnvironmentManager = this;
+            Activate();
+        }
 
         public void Serialize(System.IO.BinaryWriter binaryWriter) => Serialize(binaryWriter, false);
 

+ 2 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/LightManager.cs

@@ -41,6 +41,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public event EventHandler ListModified;
         public event EventHandler Select;
 
+        public LightManager() => Activate();
+
         public void Serialize(System.IO.BinaryWriter binaryWriter)
         {
             binaryWriter.Write(header);

+ 2 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/MeidoManager.cs

@@ -49,6 +49,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         static MeidoManager() => InputManager.Register(MpsKey.MeidoUndressing, KeyCode.H, "All maid undressing");
 
+        public MeidoManager() => Activate();
+
         public void ChangeMaid(int index) => OnUpdateMeido(null, new MeidoUpdateEventArgs(index));
 
         public void Activate()

+ 1 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/MessageWindowManager.cs

@@ -33,6 +33,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 .GetComponent<UILabel>();
             Utility.SetFieldValue(msgClass, "message_label_", msgLabel);
             Utility.SetFieldValue(msgClass, "name_label_", nameLabel);
+            Activate();
         }
 
         public void Activate() => SetPhotoMessageWindowActive(true);

+ 6 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/PropManager.cs

@@ -68,6 +68,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             this.meidoManager = meidoManager;
             this.meidoManager.BeginCallMeidos += DetachProps;
             this.meidoManager.EndCallMeidos += OnEndCall;
+            Activate();
         }
 
         public void Serialize(BinaryWriter binaryWriter)
@@ -253,6 +254,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
                 Vector3 localPosition = new Vector3(0f, 0.96f, 0f);
                 dogu.transform.Rotate(dogu.transform.right, 90f);
+                dogu.transform.localPosition = localPosition;
 
                 switch (assetName)
                 {
@@ -266,8 +268,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                         localPosition.y = 0.85f;
                         dogu.transform.localScale = new Vector3(0.03f, 0.18f, 0.124f);
                         break;
+                    default:
+                        GameObject.Destroy(dogu);
+                        dogu = null;
+                        break;
                 }
-                dogu.transform.localPosition = localPosition;
             }
             else if (assetName.IndexOf(':') >= 0)
             {

+ 5 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/SceneManager.cs

@@ -62,7 +62,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             Input.Register(MpsKey.LoadScene, KeyCode.A, "Load quick saved scene");
         }
 
-        public SceneManager(MeidoPhotoStudio meidoPhotoStudio) => this.meidoPhotoStudio = meidoPhotoStudio;
+        public SceneManager(MeidoPhotoStudio meidoPhotoStudio)
+        {
+            this.meidoPhotoStudio = meidoPhotoStudio;
+            Activate();
+        }
 
         public void Activate() { }
 

+ 5 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/WindowManager.cs

@@ -10,7 +10,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public BaseWindow this[Window id]
         {
             get => Windows[id];
-            set => Windows[id] = value;
+            set
+            {
+                Windows[id] = value;
+                Windows[id].Activate();
+            }
         }
 
         public WindowManager() => InputManager.Register(MpsKey.ToggleUI, KeyCode.Tab, "Show/hide all UI");

+ 19 - 12
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MeidoPhotoStudio.cs

@@ -350,9 +350,17 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             messageWindowManager = new MessageWindowManager();
             lightManager = new LightManager();
             propManager = new PropManager(meidoManager);
-            effectManager = new EffectManager();
             sceneManager = new SceneManager(this);
 
+            effectManager = new EffectManager();
+            effectManager.AddManager<BloomEffectManager>();
+            effectManager.AddManager<DepthOfFieldEffectManager>();
+            effectManager.AddManager<FogEffectManager>();
+            effectManager.AddManager<VignetteEffectManager>();
+
+            meidoManager.BeginCallMeidos += (s, a) => uiActive = false;
+            meidoManager.EndCallMeidos += (s, a) => uiActive = true;
+
             MaidSwitcherPane maidSwitcherPane = new MaidSwitcherPane(meidoManager);
 
             SceneWindow sceneWindow = new SceneWindow(sceneManager);
@@ -373,9 +381,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 [Constants.Window.Message] = new MessageWindow(messageWindowManager),
                 [Constants.Window.Save] = sceneWindow
             };
-
-            meidoManager.BeginCallMeidos += (s, a) => uiActive = false;
-            meidoManager.EndCallMeidos += (s, a) => uiActive = true;
         }
 
         private void Activate()
@@ -383,20 +388,22 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             if (!GameMain.Instance.SysDlg.IsDecided) return;
 
             if (!initialized) Initialize();
+            else
+            {
+                meidoManager.Activate();
+                environmentManager.Activate();
+                propManager.Activate();
+                lightManager.Activate();
+                effectManager.Activate();
+                messageWindowManager.Activate();
+                windowManager.Activate();
+            }
 
             SetNearClipPlane();
 
             uiActive = true;
             active = true;
 
-            meidoManager.Activate();
-            environmentManager.Activate();
-            propManager.Activate();
-            lightManager.Activate();
-            effectManager.Activate();
-            windowManager.Activate();
-            messageWindowManager.Activate();
-
             GameObject dailyPanel = GameObject.Find("UI Root").transform.Find("DailyPanel").gameObject;
             dailyPanel.SetActive(false);
         }