فهرست منبع

Prevent maids from reactivating when called again

When recalling maids that are already in the scene, they are reset as if
they were called into the scene for the first time. This change skips
unloading maids that persist in the call list.

Closes #47
habeebweeb 3 سال پیش
والد
کامیت
66464740ea
2فایلهای تغییر یافته به همراه17 افزوده شده و 1 حذف شده
  1. 9 1
      src/MeidoPhotoStudio.Plugin/Managers/MeidoManager.cs
  2. 8 0
      src/MeidoPhotoStudio.Plugin/Meido/Meido.cs

+ 9 - 1
src/MeidoPhotoStudio.Plugin/Managers/MeidoManager.cs

@@ -143,12 +143,20 @@ namespace MeidoPhotoStudio.Plugin
         private void UnloadMeidos()
         {
             SelectedMeido = 0;
+
+            var commonMeidoIDs = new HashSet<int>(
+                ActiveMeidoList.Where(meido => SelectedMeidoSet.Contains(meido.StockNo)).Select(meido => meido.StockNo)
+            );
+
             foreach (Meido meido in ActiveMeidoList)
             {
                 meido.UpdateMeido -= OnUpdateMeido;
                 meido.GravityMove -= OnGravityMove;
-                meido.Unload();
+                
+                if (!commonMeidoIDs.Contains(meido.StockNo))
+                    meido.Unload();
             }
+
             ActiveMeidoList.Clear();
         }
 

+ 8 - 0
src/MeidoPhotoStudio.Plugin/Meido/Meido.cs

@@ -66,6 +66,7 @@ namespace MeidoPhotoStudio.Plugin
         public string FirstName => Maid.status.firstName;
         public string LastName => Maid.status.lastName;
         public bool Busy => Maid.IsBusy || Loading;
+        public bool Active { get; private set; }
         public bool CurlingFront => Maid.IsItemChange("skirt", "めくれスカート")
             || Maid.IsItemChange("onepiece", "めくれスカート");
         public bool CurlingBack => Maid.IsItemChange("skirt", "めくれスカート後ろ")
@@ -163,6 +164,9 @@ namespace MeidoPhotoStudio.Plugin
 
             Slot = slot;
 
+            if (Active) 
+                return;
+
             FreeLook = false;
             Maid.Visible = true;
             Body.boHeadToCam = true;
@@ -218,6 +222,8 @@ namespace MeidoPhotoStudio.Plugin
             IK = true;
             Stop = false;
             Bone = false;
+
+            Active = true;
         }
 
         private void ReinitializeBody(object sender, ProcStartEventArgs args)
@@ -324,6 +330,8 @@ namespace MeidoPhotoStudio.Plugin
             Maid.Visible = false;
 
             IKManager.Destroy();
+            
+            Active = false;
         }
 
         public void Deactivate()