internal static bool TryGetPrefabFilename_Prefix(string classId, ref string filename, ref bool __result)
        {
            if (!ModPrefab.TryGetFromClassId(classId, out ModPrefab prefab))
            {
                return(true);
            }

            filename = prefab.PrefabFileName;
            __result = true;
            return(false);
        }
Exemple #2
0
        internal static bool GetPrefabAsync_Prefix(ref IPrefabRequest __result, string classId)
        {
            if (ModPrefab.TryGetFromClassId(classId, out ModPrefab prefab))
            {
                GameObject go = prefab.GetGameObjectInternal();
                __result = new LoadedPrefabRequest(go);

                return(false);
            }

            return(true);
        }
        private static IPrefabRequest GetModPrefabAsync(string classId)
        {
            if (!ModPrefab.TryGetFromClassId(classId, out ModPrefab prefab))
            {
                return(null);
            }

            try
            {
                // trying sync method first
                if (prefab.GetGameObjectInternal() is GameObject go)
                {
                    return(new LoadedPrefabRequest(go));
                }
            }
            catch (Exception e)
            {
                Logger.Debug($"Caught exception while calling GetGameObject for {classId}, trying GetGameObjectAsync now. {Environment.NewLine}{e}");
            }

            return(new ModPrefabRequest(prefab));
        }