public static void Load() { if (Directory.Exists(OldConfigFolderPath)) { if (File.Exists(OldConfigPath)) { GoldensMisc.Log("Found config file in old folder! Moving config..."); File.Move(OldConfigPath, ConfigPath); } if (File.Exists(OldConfigVersionPath)) { File.Delete(OldConfigVersionPath); } if (Directory.GetFiles(OldConfigFolderPath).Length == 0 && Directory.GetDirectories(OldConfigFolderPath).Length == 0) { Directory.Delete(OldConfigFolderPath); } else { GoldensMisc.Log("Old config folder still cotains some files/directories. They will not get deleted."); } } SetDefaults(); if (!ReadConfig()) { GoldensMisc.Log("Failed to read config file!"); } SaveConfig(); }
public override void Unload() { Instance = null; MiscGlowMasks.Unload(); if (CellPhoneTexture != null) { Main.itemTexture[ItemID.CellPhone] = CellPhoneTexture; CellPhoneTexture = null; } AutofisherHooks.Unload(); }
public override void Load() { Instance = this; //apparently you get some problems with Mod Reloading if you put this in the constructor AutofisherHooks.Initialize(); FKtModSettingsLoaded = ModLoader.GetMod("FKTModSettings") != null; VanillaTweaksLoaded = ModLoader.GetMod("VanillaTweaks") != null; if (!Main.dedServ) { if (FKtModSettingsLoaded) { Config.LoadFKConfig(); } MiscGlowMasks.Load(); if (Config.CellPhoneResprite) { CellPhoneTexture = Main.itemTexture[ItemID.CellPhone]; Main.itemTexture[ItemID.CellPhone] = GetTexture("Items/Tools/CellPhone_Resprite"); } // SkyManager.Instance["GoldensMisc:Laputa"] = new LaputaSky(); if (Config.ExtraDyes) { GameShaders.Armor.BindShader(ItemType <MatrixDye>(), new ArmorShaderData(Main.PixelShaderRef, "ArmorPhase")).UseImage("Images/Misc/noise").UseColor(0f, 1.0f, 0.2f); GameShaders.Armor.BindShader(ItemType <VirtualDye>(), new ArmorShaderData(Main.PixelShaderRef, "ArmorPhase")).UseImage("Images/Misc/noise").UseColor(1f, 0.1f, 0.1f); GameShaders.Armor.BindShader(ItemType <CobaltDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.4f, 0.7f, 1.2f); GameShaders.Armor.BindShader(ItemType <PalladiumDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(1.2f, 0.5f, 0.3f); GameShaders.Armor.BindShader(ItemType <MythrilDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.3f, 0.8f, 0.8f); GameShaders.Armor.BindShader(ItemType <OrichalcumDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(1.1f, 0.3f, 1.1f); GameShaders.Armor.BindShader(ItemType <AdamantiteDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(1.1f, 0.4f, 0.6f); GameShaders.Armor.BindShader(ItemType <TitaniumDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.5f, 0.7f, 0.7f); GameShaders.Armor.BindShader(ItemType <ChlorophyteDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.5f, 1.1f, 0.1f); } WormholeUI = new UIWormhole(); WormholeUI.Activate(); MiscUserInterface = new UserInterface(); MiscUserInterface.SetState(WormholeUI); } if (Config.SpearofJustice) { AddProjectile("MagicSpearMiniAlt", new MagicSpearMini()); } }
static void AddFurniture(GenerationProgress progress, string name, int type, int rarity, int minY, int maxY, params int[] wallIDs) { try { if (progress != null) { progress.Message = "Adding " + name; } else { Main.NewText("Adding " + name); } int generated = 0; float toGenerate = Main.maxTilesX / rarity; // var watch = Stopwatch.StartNew(); for (int i = 0; i < toGenerate; i++) { progress.Set(i / toGenerate); bool success = false; int attempts = 0; while (!success) { // if(watch.Elapsed.Seconds >= 10) // { // GoldensMisc.Log("SUCC FOR TOO LONG IMMA NUT"); // GoldensMisc.Log("Generated {0}/{1} {2}", generated, toGenerate, name); // watch.Stop(); // return; // } int x = WorldGen.genRand.Next(1, Main.maxTilesX); int y = WorldGen.genRand.Next(minY, maxY); foreach (int wallID in wallIDs) { if (Main.tile[x, y].wall == wallID) { // GoldensMisc.Log("READY FOR THE SUCC {0} {1}", num, attempts); while (!Main.tile[x, y].active()) { y++; } y--; WorldGen.PlaceObject(x, y, (ushort)type, true); if (Main.tile[x, y].type == (ushort)type) { generated++; success = true; // GoldensMisc.Log("SUCCESS"); } else { attempts++; if (attempts >= 1000) { // GoldensMisc.Log("OH NO"); success = true; } } } } } } if (progress != null) { GoldensMisc.Log("Generated {0}/{1} {2}", generated, toGenerate, name); } else { Main.NewText(String.Format("Generated {0}/{1} {2}", generated, toGenerate, name)); } } //Vanilla Terraria does this, so I guess this is OK...? catch (Exception e) { ErrorLogger.Log(e.ToString()); } }
static void AddFurniture(GenerationProgress progress, string name, int type, int rarity, int minY, int maxY, params int[] wallIDs) { try { if (progress != null) { progress.Message = name; } else { Main.NewText(name); } int generated = 0; int toGenerate = Main.maxTilesX / rarity; for (int i = 0; i < toGenerate; i++) { if (progress != null) { progress.Set(i / toGenerate); } bool success = false; int attempts = 0; while (!success) { int x = WorldGen.genRand.Next(1, Main.maxTilesX); int y = WorldGen.genRand.Next(minY, maxY); foreach (int wallID in wallIDs) { if (Main.tile[x, y].wall == wallID) { while (!Main.tile[x, y].active()) { y++; } y--; WorldGen.PlaceObject(x, y, (ushort)type, true); if (Main.tile[x, y].type == (ushort)type) { generated++; success = true; } else { attempts++; if (attempts >= 1000) { success = true; } } } } } } if (progress != null) { GoldensMisc.Log(name + ' ' + Language.GetTextValue("Mods.GoldensMisc.WorldGen.FurnitureGeneratorResults"), generated, toGenerate); } else { Main.NewText(Language.GetTextValue("Mods.GoldensMisc.WorldGen.FurnitureGeneratorResults", generated, toGenerate)); } } //Vanilla Terraria does this, so I guess this is OK...? catch (Exception e) { GoldensMisc.Error("Error during worldgen", e); } }