private static void NotifyOfObjLoad(ref BgMgr __instance)
        {
            if (__instance.BgObject == null)
            {
                return;
            }

#if (DEBUG)
            Debug.Log($"Picked up a BG load: {__instance.BgObject.name}");
#endif

            AddToObjectDictionary(__instance.BgObject, Bg);

            @this.StartCoroutine(ModifySingle(__instance.BgObject));
        }
 static void BgMgr_ChangeBg_Prefix(string f_strPrefubName, BgMgr __instance)
 {
     UnityEngine.Object original = __instance.CreateAssetBundle(f_strPrefubName);
     if (original == (UnityEngine.Object)null)
     {
         original = Resources.Load("BG/" + f_strPrefubName);
         if (original == (UnityEngine.Object)null)
         {
             original = Resources.Load("BG/2_0/" + f_strPrefubName);
         }
     }
     if (original == null)
     {
         UnityEngine.Debug.Log("YotogiAnywhere: The following error message MAY be nothing to worry about if you use MyRooms for YotogiAnywhere.");
     }
 }
Ejemplo n.º 3
0
        // create prefab override in  BgMgr.AddPrefabToBg which is for background prefabs loaded
        // via scripts, such as dildobox

        public static UnityEngine.GameObject BgMgr_prefab_override(BgMgr self, string src, string name)
        {
            GameObject gameObject3 = null;

            if (!self.m_dicAttachObj.TryGetValue(name, out gameObject3))
            {
                UnityEngine.Object @object = self.CreateAssetBundle(src);
                if (@object == null)
                {
                    @object = Resources.Load("Prefab/" + src);
                }
                if (@object == null)
                {
                    return(null);
                }
                gameObject3      = (UnityEngine.Object.Instantiate(@object) as GameObject);
                gameObject3.name = name;
                self.m_dicAttachObj.Add(name, gameObject3);
            }
            return(gameObject3);
        }
Ejemplo n.º 4
0
        // the method is hooked into BgMgr.ChangeBg and unloads previously loded asset bundle used for BG prefab
        public static void Bundle_Cleaner(BgMgr self)
        {
            if (self.current_bg_object != null)
            {
                // check if prefab was loaded from asset bundle by checking cache dictionary

                string bundle_name = self.GetBGName() + ".asset_bg";

                if (self.asset_bundle_dic.ContainsKey(bundle_name))
                {
                    //if it's cahced, unload the bundle and all object loaded from it and clear chache key
                    self.asset_bundle_dic[bundle_name].ab.Unload(true);
                    self.asset_bundle_dic.Remove(bundle_name);
                }
            }



            // it appears that KISS does unload bundles uses for BG objects, when all objects loaded from it are destroyed
            // so those are do no cause VRAM&RAM leakage
            // chances are, this patcher will become redundant when KISS decided to bother fixing this issue
        }
        static void BgMgr_ChangeBg_Postfix(string f_strPrefubName, BgMgr __instance)
        {
            YotogiAnywhere.roomBGName = null;

            UnityEngine.Object original = __instance.CreateAssetBundle(f_strPrefubName);
            if (original == (UnityEngine.Object)null)
            {
                original = Resources.Load("BG/" + f_strPrefubName);
                if (original == (UnityEngine.Object)null)
                {
                    original = Resources.Load("BG/2_0/" + f_strPrefubName);
                }
            }
            if (original == null)
            {
                UnityEngine.Debug.Log("YotogiAnywhere: Attempting.Room load.");

                //Get the path to NewStages
                string path = UTY.gameProjectPath + "\\Mod\\[YotogiAnywhere]\\[NewStages]";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                //Search for .room files, unfortunately we have to check all stages
                string[] files = Directory.GetFiles(path, f_strPrefubName + ".room", SearchOption.AllDirectories);
                if (files.Length == 0)
                {
                    //Not found
                    UnityEngine.Debug.Log("YotogiAnywhere: No " + f_strPrefubName + ".Room file found.");
                }
                else
                {
                    //Found something
                    if (files.Length > 1)
                    {
                        UnityEngine.Debug.Log("YotogiAnywhere: Multiple .Room files named the same, please fix if there are Day/Night differences.");
                    }

                    //Load the Room file instead using the file's guid
                    object[] parameters = new object[] { files[0], null };

                    MethodInfo deserializeHeader = typeof(MyRoomCustom.CreativeRoomManager).GetMethod("DeserializeHeader", BindingFlags.NonPublic | BindingFlags.Static, null, new Type[] { typeof(string), typeof(MyRoomCustom.CreativeRoomManager.CreativeRoomHeader).MakeByRefType() }, null);

                    if (deserializeHeader != null)
                    {
                        object result = deserializeHeader.Invoke(null, parameters);
                        MyRoomCustom.CreativeRoomManager.CreativeRoomHeader header = (MyRoomCustom.CreativeRoomManager.CreativeRoomHeader)parameters[1];
                        if (header.guid != null)
                        {
                            __instance.ChangeBgMyRoom(header.guid);
                            YotogiAnywhere.roomBGName = new FileInfo(files[0]).Directory.Parent.Name;//header.comment;
                        }
                        else
                        {
                            UnityEngine.Debug.Log("YotogiAnywhere: .Room GUID could not be found.");
                        }
                    }
                    else
                    {
                        UnityEngine.Debug.Log("YotogiAnywhere: DeserializeHeader could not be found.");
                    }
                }
            }
        }