Ver código fonte

Tweak prop spawning to work with PartsEdit

PartsEdit finds MultipleMaids objects by searching the scene root for
gameobjects that have an Animation component and has a name that ends
with ".menu".
habeebweeb 4 anos atrás
pai
commit
8541b21edc

+ 1 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/CustomGizmo.cs

@@ -60,7 +60,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public static CustomGizmo Make(Transform target, float scale = 0.25f, GizmoMode mode = GizmoMode.Local)
         {
-            GameObject gizmoGo = new GameObject();
+            GameObject gizmoGo = new GameObject("[MPS Gizmo]");
             gizmoGo.transform.SetParent(target);
 
             CustomGizmo gizmo = gizmoGo.AddComponent<CustomGizmo>();

+ 6 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragPoint/DragPoint.cs

@@ -99,6 +99,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             ApplyDragType();
         }
 
+        private static GameObject DragPointParent() => GameObject.Find("[MPS DragPoint Parent]")
+            ?? new GameObject("[MPS DragPoint Parent]");
+
         public static T Make<T>(PrimitiveType primitiveType, Vector3 scale, Material material) where T : DragPoint
         {
             GameObject dragPoint = GameObject.CreatePrimitive(primitiveType);
@@ -106,6 +109,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             dragPoint.GetComponent<Renderer>().material = material;
             dragPoint.layer = 8;
 
+            dragPoint.transform.SetParent(DragPointParent().transform, true);
+
             return dragPoint.AddComponent<T>();
         }
 
@@ -118,6 +123,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public virtual void Set(Transform myObject)
         {
             this.MyObject = myObject;
+            this.gameObject.name = $"[MPS DragPoint: {this.MyObject.name}]";
         }
 
         public virtual void AddGizmo(float scale = 0.25f, GizmoMode mode = GizmoMode.Local)

+ 1 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/LightManager.cs

@@ -97,7 +97,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public void AddLight(GameObject lightGo = null, bool isMain = false)
         {
-            GameObject go = lightGo ?? new GameObject();
+            GameObject go = lightGo ?? new GameObject("MPS Light");
             DragPointLight light = DragPoint.Make<DragPointLight>(
                 PrimitiveType.Cube, Vector3.one * 0.12f, DragPoint.LightBlue
             );

+ 16 - 15
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/PropManager.cs

@@ -185,7 +185,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             GameObject dogu = MenuFileUtility.LoadModel(modItem);
             string name = modItem.MenuFile;
-            if (modItem.IsOfficialMod) name = Path.GetFileNameWithoutExtension(name);
+            if (modItem.IsOfficialMod) name = Path.GetFileName(name);
             if (dogu != null) AttachDragPoint(dogu, modItem.ToString(), name, new Vector3(0f, 0f, 0.5f));
             return dogu != null;
         }
@@ -195,7 +195,13 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             MyRoomCustom.PlacementData.Data data = MyRoomCustom.PlacementData.GetData(item.ID);
             GameObject dogu = GameObject.Instantiate(data.GetPrefab());
             string name = Translation.Get("myRoomPropNames", item.PrefabName);
-            if (dogu != null) AttachDragPoint(dogu, item.ToString(), name, new Vector3(0f, 0f, 0.5f));
+            if (dogu != null)
+            {
+                GameObject finalDogu = new GameObject();
+                dogu.transform.SetParent(finalDogu.transform, true);
+                finalDogu.transform.SetParent(GetDeploymentObject().transform, false);
+                AttachDragPoint(finalDogu, item.ToString(), name, new Vector3(0f, 0f, 0.5f));
+            }
             else Utility.LogInfo($"Could not load MyRoomCreative prop '{item.PrefabName}'");
             return dogu != null;
         }
@@ -212,7 +218,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 GameObject dogu = GameObject.Instantiate(obj);
                 string name = Translation.Get("bgNames", assetName);
                 dogu.transform.localScale = Vector3.one * 0.1f;
-                AttachDragPoint(dogu, $"BG_{assetName}", name, Vector3.zero);
+                AttachDragPoint(dogu, $"BG_{assetName}", name, new Vector3(0f, 0f, 0.5f));
             }
             return obj != null;
         }
@@ -386,19 +392,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             // TODO: Figure out why some props aren't centred properly
             // Doesn't happen in MM but even after copy pasting the code, it doesn't work :/
-            GameObject deploymentObject = GetDeploymentObject();
-            GameObject finalDogu = new GameObject(name);
-
-            dogu.transform.SetParent(finalDogu.transform, true);
-            finalDogu.transform.SetParent(deploymentObject.transform, false);
-
-            finalDogu.transform.position = position;
+            dogu.name = name;
+            dogu.transform.position = position;
 
             DragPointDogu dragDogu = DragPoint.Make<DragPointDogu>(
                 PrimitiveType.Cube, Vector3.one * 0.12f, DragPoint.LightBlue
             );
-            dragDogu.Initialize(() => finalDogu.transform.position, () => Vector3.zero);
-            dragDogu.Set(finalDogu.transform);
+            dragDogu.Initialize(() => dogu.transform.position, () => Vector3.zero);
+            dragDogu.Set(dogu.transform);
             dragDogu.AddGizmo(scale: 0.45f, mode: CustomGizmo.GizmoMode.World);
             dragDogu.ConstantScale = true;
             dragDogu.Delete += DeleteDogu;
@@ -452,8 +453,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             GameObject dogu = dragDogu.MyGameObject;
 
-            Transform attachPointTransform = meido?.IKManager.GetAttachPointTransform(attachPoint)
-                ?? GetDeploymentObject().transform;
+            Transform attachPointTransform = meido?.IKManager.GetAttachPointTransform(attachPoint);
+            // ?? GetDeploymentObject().transform;
 
             dragDogu.attachPointInfo = new AttachPointInfo(
                 attachPoint: meido == null ? AttachPoint.None : attachPoint,
@@ -489,7 +490,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (dogu.attachPointInfo.AttachPoint != AttachPoint.None)
                 {
-                    dogu.MyObject.SetParent(GetDeploymentObject().transform, true);
+                    dogu.MyObject.SetParent(null, /*GetDeploymentObject().transform*/ true);
                 }
             }
         }

+ 1 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MenuFileUtility.cs

@@ -450,6 +450,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                     array11[num23] = material;
                 }
                 skinnedMeshRenderer.materials = array11;
+                gameObject.AddComponent<Animation>();
                 return gameObject;
             }
         }