Esempio n. 1
0
 private static IEnumerable <string> GetZipmodsFromDirectory(string modDirectory)
 {
     Logger.LogInfo("Loading mods from directory: " + modDirectory);
     return(Directory.GetFiles(modDirectory, "*", SearchOption.AllDirectories)
            .Where(x => x.EndsWith(".zip", StringComparison.OrdinalIgnoreCase) ||
                   x.EndsWith(".zipmod", StringComparison.OrdinalIgnoreCase)));
 }
Esempio n. 2
0
        private void AddAdvancedIron()
        {
            Logger.LogInfo("AddAdvancedIron Start");
            RecipeProto advIron = orgRecipe.Copy();

            advIron.ID           = 620;
            advIron.Name         = "铁锭(高效)";
            advIron.name         = advIron.Name.Translate();
            advIron.Description  = "您可以通过加水生成更多的铸锭。";
            advIron.description  = advIron.Description.Translate();
            advIron.Items        = new int[] { 1001, 1000 };
            advIron.ItemCounts   = new int[] { 6, 4 };
            advIron.Results      = new int[] { 1101 };
            advIron.ResultCounts = new int[] { 15 };
            advIron.Explicit     = true;
            advIron.TimeSpend    = (60 * 12);
            advIron.GridIndex    = 1708;
            advIron.SID          = advIron.GridIndex.ToString();
            advIron.sid          = advIron.GridIndex.ToString().Translate();
            Traverse.Create(advIron).Field("_iconSprite").SetValue(this.ironIcon);
            var ironIngotItem = LDB.items.Select(1101);

            ironIngotItem.recipes.Add(advIron);
            LDBTool.PostAddProto(ProtoType.Recipe, advIron);
            Logger.LogInfo("AddAdvancedIron End");
        }
Esempio n. 3
0
 public static void Verbose(string str, params object[] args)
 {
     if (IsGlobalEnabled && IsVerboseEnabled)
     {
         LogInstance?.LogInfo(string.Format($"[Verbose] {str}", args));
     }
 }
Esempio n. 4
0
        private static void InitHardcoreLabel()
        {
            GameObject selectScreen = FejdStartup.instance.m_characterSelectScreen;

            Text characterName = selectScreen.transform.Find("SelectCharacter").Find("CharacterName").GetComponentInChildren <Text>();

            GameObject    hardcoreLabelGO = new GameObject("HardcoreLabel");
            RectTransform rect            = hardcoreLabelGO.AddComponent <RectTransform>();

            rect.position  = (characterName.transform as RectTransform).position + new Vector3(0, 60);
            rect.sizeDelta = new Vector2((characterName.transform as RectTransform).rect.width, 40);

            Text text = hardcoreLabelGO.AddComponent <Text>();

            text.font      = characterName.font;
            text.color     = Color.red;
            text.fontSize  = characterName.fontSize - 12;
            text.alignment = TextAnchor.MiddleCenter;
            text.text      = Localization.instance.Localize("($hardcore_hardcore)");

            Outline outline = hardcoreLabelGO.AddComponent <Outline>();

            outline.effectColor    = Color.black;
            outline.effectDistance = new Vector2(2, -2);

            hardcoreLabelGO.transform.SetParent(characterName.transform);

            hardcoreLabel = hardcoreLabelGO;

            Log.LogInfo($"{hardcoreLabel} Initialized.");
        }
Esempio n. 5
0
        public void Awake()
        {
            SpreadsheetGenMod.Logger = base.Logger;  // "C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\BepInEx\LogOutput.log"
            SpreadsheetGenMod.Config = base.Config;

            // Determine the default spreadsheet path and configured spreadsheet path.
            spreadsheetFileNameTemplate = "DSP_Star_Sector_Resources_${seed}-${starCount}.csv";
            if (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) != "")
            {
                spreadsheetFileNameTemplate = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + Path.DirectorySeparatorChar + spreadsheetFileNameTemplate;
            }
            spreadsheetFileNameTemplate = Config.Bind <string>("Output", "SpreadsheetFileName", spreadsheetFileNameTemplate, "Path to the output spreadsheet.  You can use ${seed} and ${starCount} as placeholders and the mod will insert them into the filename.").Value;
            spreadsheetColumnSeparator  = Config.Bind <string>("Output", "SpreadsheetColumnSeparator", spreadsheetColumnSeparator, "Character to use as Separator in the generated file.").Value;
            spreadsheetFloatPrecision   = Config.Bind <int>("Output", "SpreadsheetFloatPrecision", spreadsheetFloatPrecision, "Decimals to use when exporting floating point numbers. Use -1 to disable rounding.").Value;
            spreadsheetLocale           = new CultureInfo(Config.Bind <string>("Output", "SpreadsheetLocale", spreadsheetLocale.Name, "Locale to use for exporting numbers.").Value, false);

            enablePlanetLoadingFlag   = Config.Bind <bool>("Enable", "LoadAllPlanets", enablePlanetLoadingFlag, "Planet loading is needed to get all resource data, but you can skip this step for memory efficiency.").Value;
            enablePlanetUnloadingFlag = Config.Bind <bool>("Enable", "UnloadPlanets", enablePlanetUnloadingFlag, "Once planets are loaded to obtain their resource data, unload them to conserve memory.  (This setting is only used if LoadAllPlanets is true.)").Value;
            enableOnStartTrigger      = Config.Bind <bool>("Enable", "SaveOnStart", enableOnStartTrigger, "Whether or not spreadsheet generation should be triggered by starting a game.").Value;
            enableOnPauseTrigger      = Config.Bind <bool>("Enable", "SaveOnPause", enableOnPauseTrigger, "Whether or not spreadsheet generation should be triggered by pausing the game.").Value;

            Logger.LogInfo("Will use spreadsheet path \"" + spreadsheetFileNameTemplate + "\"");

            Harmony harmony = new Harmony(pluginGuid);

            harmony.PatchAll(typeof(SpreadsheetGenMod));

            Logger.LogInfo("Initialization complete.");
        }
Esempio n. 6
0
        IEnumerator LoadAssetBundles(Action callback = null)
        {
            foreach (var bundleName in fileLoader.GetResourceFilenames("AssetBundle"))
            {
                var path = Path.Combine(m_bundleLoadDir, bundleName);

                m_bundleCreateRequest = AssetBundle.LoadFromFileAsync(path);
                yield return(m_bundleCreateRequest);

                AssetBundle bundle = m_bundleCreateRequest.assetBundle;
                if (bundle == null)
                {
                    Logger.LogWarning("Failed to load AssetBundle: " + bundleName);
                    yield return(bundle);
                }
                else
                {
                    Logger.LogInfo("Successfully loaded additional bundle named: " + bundle.name);
                    Bundles.Add(bundle);
                }
            }

            BundlesLoaded = true;
            StartCoroutine(LoadAllAssetsInBundle(callback));
        }
Esempio n. 7
0
        public static void AddDropInformation(ItemDropLocation dropLocation,
                                              params PickupSelection[] pickupSelections)
        {
            Logger.LogInfo(
                $"Adding drop information for {dropLocation.ToString()}: {pickupSelections.Sum(x => x.Pickups.Count)} items");

            Selection[dropLocation] = pickupSelections.ToList();
        }
Esempio n. 8
0
        public void OnPeerConnected(NetPeer rawPeer)
        {
            var peer = new Peer(rawPeer, _messages.Definitions);

            _log.LogInfo($"{peer} connected");

            _peers.Add(rawPeer, peer);

            _events.OnPeerConnected(peer);
        }
Esempio n. 9
0
 /// <summary>
 /// 設定CurrentUICulture
 /// </summary>
 /// <param name="culture">Culture Name (Ex: "en-US"),傳入Null則設定為系統語言</param>
 /// <returns>以Culture Name建立的CultureInfo</returns>
 internal static CultureInfo SetUICulture(string culture = null)
 {
     try {
         return(null == culture
             ? (UICulture = Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultures(CultureTypes.AllCultures).FirstOrDefault(x => x.EnglishName.Equals(Application.systemLanguage.ToString())))
             : (UICulture = Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(culture)));
     } catch (Exception) {
         Logger.LogInfo($"Language not found. Keep {UICulture.Name}");
         return(Thread.CurrentThread.CurrentUICulture = UICulture);
     }
 }
        static void EquipLastItems(TombStone __instance)
        {
            if (__instance.GetOwner() != player.GetPlayerID())
            {
                return;
            }

            LogSource.LogInfo(string.Format("{0} has picked up all from TOMBSTONE", player.GetPlayerName()));
            if (player)
            {
                EquipLastItemsToRespownedPlayer(equipedItems, player);
            }
        }
Esempio n. 11
0
        public static async Task <GameObject> GetItemInventoryDisplayAsync()
        {
            GameObject IID;

            do
            {
                Logger.LogInfo("Waiting for client to spawn ItemInventoryDisplay...");
                await Task.Delay(150);

                IID = GameObject.Find("ItemInventoryDisplay");
            } while (IID == null);
            return(IID);
        }
 /// <summary>
 /// Enable Unity Audio. Should only be called when UnityPlayer is not loaded.
 /// </summary>
 public static void EnableUnityAudio()
 {
     try
     {
         Logger.LogInfo("Attempting to enable Unity audio...");
         ChangeDisableUnityAudio(Path.Combine(ManagedPath, "../globalgamemanagers"), false, Game);
         Logger.LogInfo("Unity audio enabled.");
     }
     catch (Exception ex)
     {
         Logger.LogError($"An exception was encountered while attempting to enable Unity audio: {ex.Message}");
     }
 }
Esempio n. 13
0
 public void ReadPluginData(PluginData data)
 {
     if (data == null)
     {
         Logger.LogInfo("No PluginData Existed");
     }
     else
     {
         if ((!data.data.TryGetValue("AllCharaOverlayTable", out object tmpOverlayTable) || tmpOverlayTable == null) ||
             (!data.data.TryGetValue("AllCharaResources", out object tmpResources) || null == tmpResources))
         {
             Logger.LogInfo("Wrong PluginData Existed");
         }
Esempio n. 14
0
 static void SetEnemyLevel(ref Character __instance)
 {
     if (__instance.m_name.StartsWith("$enemy_"))
     {
         string enemyName = __instance.m_name.Substring(7, __instance.m_name.Length - 7);
         int    level     = GetLevelForEnemy(enemyName);
         if (level > 0)
         {
             __instance.SetLevel(level);
             logger.LogInfo(enemyName + " Loaded. Setting to level " + level + " (" + (level - 1) + " stars)");
         }
     }
 }
Esempio n. 15
0
        public void Awake()
        {
            Logger = base.Logger;
            Settings.InitConfig(Config);
            harmony.PatchAll(Assembly.GetExecutingAssembly());
            int patchedMethods = 0;

            foreach (MethodBase method in harmony.GetPatchedMethods())
            {
                Logger.LogInfo("Patched " + method.DeclaringType.Name + "." + method.Name);
                patchedMethods++;
            }
            Logger.LogInfo(patchedMethods + " patches applied\n");
        }
Esempio n. 16
0
        public static IEnumerator PrintResults()
        {
            yield return(null);

            logger.LogInfo($"Chainloader total: {chainTimer.ElapsedMilliseconds} ms");
            logger.LogInfo($"Plugins total: {timers.Sum(x => x.Value.Value.ElapsedMilliseconds)} ms");

            foreach (var timer in timers.OrderByDescending(x => x.Value.Value.ElapsedMilliseconds))
            {
                logger.LogInfo($"{timer.Value.Key.GUID}: {timer.Value.Value.ElapsedMilliseconds} ms");
            }

            harmony.UnpatchAll(harmony.Id);
        }
Esempio n. 17
0
 public static void Log(string log, LogType type)
 {
     if (AllowLogging)
     {
         if (type == LogType.General)
         {
             BepLog.LogInfo(log);
         }
         else if (type == LogType.Loading && LogLoading)
         {
             BepLog.LogInfo(log);
         }
     }
 }
Esempio n. 18
0
 public static void SetActivity(Activity activity)
 {
     _activityManager.UpdateActivity(activity, (result =>
     {
         if (result == Result.Ok)
         {
             log.LogInfo("Success");
         }
         else
         {
             log.LogInfo("Failed: " + result);
         }
     }));
 }
Esempio n. 19
0
        public void Awake()
        {
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ExtraItems.extraitem_assets"))
            {
                MainAssets = AssetBundle.LoadFromStream(stream);
                var provider = new AssetBundleResourcesProvider($"@{ModName}", MainAssets);
                ResourcesAPI.AddProvider(provider);
            }

            //Item initialization
            var ItemTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(ItemBase)));

            foreach (var itemType in ItemTypes)
            {
                ItemBase item = (ItemBase)System.Activator.CreateInstance(itemType);
                if (ValidateItem(item, Items))
                {
                    item.Init(Config);
                    ModLogger.LogInfo("Item: " + item.ItemName + " Initialized!");
                }
            }

            //Material Shader Conversion
            var materialAssets = MainAssets.LoadAllAssets <Material>();

            ModLogger.LogInfo("Intersection Shader is: " + IntersectionShader);

            foreach (Material material in materialAssets)
            {
                if (!material.shader.name.StartsWith("Fake"))
                {
                    continue;
                }
                switch (material.shader.name.ToLower())
                {
                case ("fake ror/hopoo games/deferred/hgstandard"):
                    material.shader = HopooShader;
                    break;

                case ("fake ror/hopoo games/fx/hgcloud intersection remap"):
                    material.shader = IntersectionShader;
                    break;

                case ("fake ror/hopoo games/fx/hgcloud remap"):
                    material.shader = CloudRemapShader;
                    break;
                }
            }
        }
Esempio n. 20
0
        private void LoadMods()
        {
            Logger.LogInfo("Loading mods...");
            var mods     = new List <Mod>();
            var modsPath = Path.Combine(Paths.GameRootPath, H3VR.Sideloader.Shared.Info.MODS_DIR);

            Directory.CreateDirectory(modsPath);
            var modIds = new HashSet <string>(); // TODO: Make more elaborate (check version, etc)

            void LoadMods(IEnumerable <string> paths, Func <string, Mod> loader)
            {
                foreach (var path in paths)
                {
                    try
                    {
                        var mod = loader(path);
                        if (modIds.Contains(mod.Manifest.Guid))
                        {
                            Logger.LogWarning(
                                $"Skipping [{mod.Name}] because a mod with same GUID ({mod.Manifest.Guid}) was already loaded (check logs)");
                            continue;
                        }

                        Logger.LogDebug($"Loading {mod.Name}");
                        modIds.Add(mod.Manifest.Guid);
                        mods.Add(mod);
                    }
                    catch (Exception e)
                    {
                        Logger.LogWarning($"Skipping {path} because: ({e.GetType()}) {e.Message}");
                    }
                }
            }

            LoadMods(Directory.GetDirectories(modsPath, "*", SearchOption.TopDirectoryOnly), Mod.LoadFromDir);
            LoadMods(Extensions.GetAllFiles(modsPath, H3VR.Sideloader.Shared.Info.ModExts.Select(s => $"*.{s}").ToArray()),
                     Mod.LoadFromZip);

            // TODO: Sanity checking etc

            foreach (var loader in loaders)
            {
                Logger.LogDebug($"Loading {loader}");
                loader.Initialize(mods);
            }


            Logger.LogInfo($"Loaded {mods.Count} mods!");
        }
Esempio n. 21
0
        private static bool LoadAssetPatch(AssetBundleController __instance, ref string assetName, ref object __result)
        {
            if (__instance.assetBundleName.Contains("thumnbnail/thumbnail_") || __instance.assetBundleName.Contains("thumnbnail/thumnbs_"))
            {
                string text = __instance.directory + "/thumnbnail_R/" + assetName + ".png";
                if (File.Exists(text))
                {
                    Logger.LogInfo("Load thumb:" + text);
                    __result = LoadPNG(text);
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 22
0
 void Awake()
 {
     logger = Logger;
     logger.LogInfo("Hello, world!");
     _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
     //portal_name_hash = StringExtensionMethods.GetStableHashCode(portal_name);
 }
Esempio n. 23
0
        private void Awake()
        {
            Logger = base.Logger;

            // Add missing head type selection if the game supports it (ui for it was added in darkness for some reason)
            var missingDarkness = typeof(ChaInfo).GetProperty("exType", BindingFlags.Public | BindingFlags.Instance) == null;

            if (missingDarkness)
            {
                Logger.LogInfo("Darkness/Yoyaku expansion is missing!");

                // Make sure this setting is supported // todo is this necessary?
                if (Enum.IsDefined(typeof(ChaListDefine.CategoryNo), 100))
                {
                    MakerAPI.RegisterCustomSubCategories += MakerAPI_RegisterCustomSubCategories;
                }
            }

            var h = new Harmony(GUID);

            h.PatchAll(typeof(CalendarIconHooks));

            // Fixes only needed for party
            if (Paths.ProcessName == Constants.GameProcessNameSteam)
            {
                h.Patch(AccessTools.Method(typeof(ConfigScene), "Start"),
                        postfix: new HarmonyMethod(typeof(RestoreMissingFunctions), nameof(ConfigAddFix)));
                h.Patch(AccessTools.Method("Localize.Translate.Manager:SetLanguage", new[] { typeof(int) }),
                        transpiler: new HarmonyMethod(typeof(RestoreMissingFunctions), nameof(LanguageUnlock)));
            }
        }
Esempio n. 24
0
        public override void Load()
        {
            _logger = Log;
            _logger.LogInfo($"{PluginName} v{PluginVersion} created by Cheep loaded");

            GameMode = new TeleportationGameMode();
        }
Esempio n. 25
0
        void Awake()
        {
            logger = Logger;
            logger.LogInfo("Hello, world!");

            _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
        }
        public static void Patch(AssemblyDefinition newtonsoftAssemblyDef)
        {
            if (newtonsoftAssemblyDef.MainModule.Types.Any(t => t.Namespace.StartsWith("Oculus")))
            {
                Logger.LogInfo("Newtonsoft.Json.dll already uses Oculus.Newtonsoft.Json namespace, skipping shim.");
                return;
            }

            var oculusNewtonsoftAssemblyDef = AssemblyDefinition.ReadAssembly(OculusNewtonsoftJsonPath);

            var oculusAssemblyNameRef = new AssemblyNameReference(
                oculusNewtonsoftAssemblyDef.Name.Name, oculusNewtonsoftAssemblyDef.Name.Version);

            newtonsoftAssemblyDef.MainModule.AssemblyReferences.Add(oculusAssemblyNameRef);

            foreach (var type in oculusNewtonsoftAssemblyDef.MainModule.Types)
            {
                if (!type.IsPublic)
                {
                    continue;
                }

                var exportedType = new ExportedType(
                    type.Namespace, type.Name,
                    newtonsoftAssemblyDef.MainModule, oculusAssemblyNameRef);

                newtonsoftAssemblyDef.MainModule.ExportedTypes.Add(exportedType);
            }
        }
Esempio n. 27
0
        private void Init()
        {
            foreach (string curDir in SupportedFolders)
            {
                // Make sure we have the key initialized
                if (!resourceFilenames.ContainsKey(curDir))
                {
                    resourceFilenames.Add(curDir, new List <string>());
                }

                string curPath = m_loadDir + @"\" + curDir;

                if (!Directory.Exists(curPath))
                {
                    continue;
                }

                string[] files = Directory.GetFiles(curPath);

                // Get the names of the files without having to parse stuff
                foreach (string s in files)
                {
                    FileInfo f = new FileInfo(s);
                    Logger.LogInfo("Loading: " + f.Name);
                    resourceFilenames[curDir].Add(f.Name);
                }
            }
        }
Esempio n. 28
0
 public static void LogDebug(string message)
 {
     if (ConfigurationManager.GeneralConfig?.EnableDebugLogging?.Value == true)
     {
         Logger?.LogInfo($"{message}");
     }
 }
Esempio n. 29
0
 public static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     try
     {
         parentLogger.LogInfo("On Scene Loaded" + scene.name);
         UnityEngine.Debug.Log("Loading Scene: " + scene.name);
         if (scene.name == "UI")
         {
             TextMeshProUGUI betaText = GetUITextByName("BETA");
             if (betaText)
             {
                 betaText.text = "INJECTED BUILD - unstable mods";
             }
         }
         else
         {
             TextMeshProUGUI modListText = GetUITextByName("TextMeshPro Text");
             if (modListText)
             {
                 BepInPlugin bepInPlugin = (BepInPlugin)Attribute.GetCustomAttribute(ModdingUtils.parentPlugin.GetType(), typeof(BepInPlugin));
                 if (modListText.text.EndsWith("</size>"))
                 {
                     modListText.text += "\n\nMods Currently Installed:\n";
                 }
                 modListText.text += "\n" + bepInPlugin.Name + " - " + bepInPlugin.Version;
             }
         }
     }
     catch (Exception ex)
     {
         parentLogger.LogFatal(ex);
     }
 }
Esempio n. 30
0
        //Post register fixups
        private static void onPostAdd()
        {
            foreach (var kv in models)
            {
                kv.Value.Preload();
                PrefabDesc pdesc = kv.Value.prefabDesc;

                Material[] mats = pdesc.materials;
                for (int i = 0; i < pdesc.lodMaterials[0].Length; i++)
                {
                    pdesc.lodMaterials[0][i] = mats[i];
                }

                LDB.models.modelArray[kv.Value.ID] = kv.Value;
            }

            foreach (var kv in items)
            {
                kv.Value.Preload(kv.Value.index);
            }

            foreach (var kv in recipes)
            {
                kv.Value.Preload(kv.Value.index);
            }

            onLoadingFinished?.Invoke();

            LogSource.LogInfo("Post loading is complete!");
        }