public override void PostSetupContent() { Mod bossChecklist = ModLoader.GetMod("BossChecklist"); if (bossChecklist != null) { bossChecklist.Call("AddBossWithInfo", "Ultra Eye of Cthulhu", 16.0f, (Func <bool>)(() => TUAWorld.EoCDeathCount >= 1), "Use a [i:" + ItemID.SuspiciousLookingEye + "] at night after Moon lord has been defeated"); bossChecklist.Call("AddBossWithInfo", "Eye of EoADowned - God of Destruction", 16.1f, (Func <bool>)(() => ModContent.GetInstance <TUAWorld>().UltraMode), "Use a [i:" + ItemType("Spawner") + "] after --1sing Ay. 0F C1^lh> in ^1tra and murder it, if you can..."); } Mod achievementLibs = ModLoader.GetMod("AchievementLibs"); if (achievementLibs != null) { Func <bool> c = () => TUAWorld.EoADowned; achievementLibs.Call("AddAchievementWithoutReward", this, "Once there was an eye that was a god...", "Kill the Eye of Apocalypse - God of Destruction!", "Achievement/EoAKill", c); achievementLibs.Call("AddAchievementWithoutReward", this, "The terrible moon tried to kill us", "Use [i:" + ModContent.ItemType <EyeOfPerception>() + "] and succesfully survive all 8 wave of the Apocalypse Moon", "Achievement/EoAKill", (Func <bool>)(() => TUAWorld.ApoMoonDowned)); achievementLibs.Call("AddAchievementWithoutAction", this, "Once there was the Eye of Cthulhu... the ultra one", "Kill the Ultra EoC succesfully.", "Achievement/UltraEoC", new int[] { ModContent.ItemType <EyeOfPerception>() }, new int[] { 1 }, (Func <bool>)(() => TUAWorld.EoCDeathCount >= 1)); } RecipeUtils.SetAllFurnaceRecipeSystem(); ReflManager <Type> .RemoveItem("TMain"); ReflManager <Type> .AddItem("TMain", typeof(Main)); }
public override void Unload() { //DrawMapInjection.revert(); UpdateBiomesInjection.InjectMe(); Main.SavePath = SAVE_PATH; Main.PlayerPath = Main.SavePath + "/Player"; Main.WorldPath = Main.SavePath + "/World"; instance = null; quote.Clear(); FieldInfo info2 = typeof(ModLoader).GetField("versionedName", BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.Public); info2.SetValue(null, string.Format("tModLoader v{0}", (object)ModLoader.version) + (ModLoader.branchName.Length == 0 ? "" : " " + ModLoader.branchName) + (ModLoader.beta == 0 ? "" : string.Format(" Beta {0}", (object)ModLoader.beta))); MoonEventManagerWorld.moonEventList.Clear(); if (!Main.dedServ) { DRPSystem.Kill(); Main.OnTick -= DRPSystem.Update; } ReflManager <Type> .Clear(); RaidsManager.Clear(); }
public override void OnChatButtonClicked(NPC npc, bool firstButton) { if (npc.type == NPCID.Guide) { if (firstButton) { if (!RaidsWorld.hasTalkedToGuide.Contains(Main.player[Main.myPlayer].GetModPlayer <TUAPlayer>().ID.ToString())) { Main.npcChatText = GetGuideStartText(); currentGuideText++; } else { switch (guideFocusText) { case 2: UIManager.OpenRaidsUI(); giveRaidsDialog = true; break; case 1: Main.playerInventory = true; Main.npcChatText = ""; Main.PlaySound(12, -1, -1, 1, 1f, 0f); Main.InGuideCraftMenu = true; UILinkPointNavigator.GoToDefaultPage(0); break; default: Main.PlaySound(12, -1, -1, 1, 1f, 0f); // If someone can find a better way to do this, do it immediately ReflManager <Type> .GetItem("TMain").GetMethod("HelpText", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null); break; } } } else { if (guideFocusText == 2) { guideFocusText = 0; } else { guideFocusText++; } } } }
static TUA() { version = "0.1 dev";; tModLoaderVersion2 = ""; SAVE_PATH = Main.SavePath; raidsUI = new RaidsUI(); #if DEBUG devMode = true; #else devMode = false; #endif quote = new List <string>(); animate = GetAnimatedTitle(); gameTime = new GameTime(); ReflManager <Type> .AddItem("TMain", typeof(Main)); RaidsManager.Fill(); }
public static void PopulateModBrowser(CustomMMHooker.orig_populatebrowser orig, object instance) { Object modBrowserInstance = ReflManager <Type> .GetItem("TMain").Assembly.GetType("Terraria.ModLoader.Interface") .GetField("modBrowser", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); ErrorLogger.Log(modBrowserInstance); ReflManager <Type> .GetItem("TMain").Assembly.GetType("Terraria.ModLoader.UI.UIModBrowser").GetField("loading").SetValue(modBrowserInstance, true); ReflManager <Type> .GetItem("TMain").Assembly.GetType("Terraria.ModLoader.UI.UIModBrowser").GetField("_specialModPackFilterTitle", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(modBrowserInstance, ""); //StaticManager<Type>.GetItem("TMain").Assembly.GetType("Terraria.ModLoader.UI.UIModBrowser").GetField("_specialModPackFilterTitle", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(modBrowserInstance, null ); UITextPanel <String> reloadButton = (UITextPanel <String>) ReflManager <Type> .GetItem("TMain").Assembly.GetType("Terraria.ModLoader.UI.UIModBrowser") .GetField("reloadButton", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(modBrowserInstance); reloadButton.SetText(Language.GetTextValue("tModLoader.MBGettingData")); MethodInfo SetHeading = ReflManager <Type> .GetItem("TMain").Assembly.GetType("Terraria.ModLoader.UI.UIModBrowser") .GetMethod("SetHeading", BindingFlags.Instance | BindingFlags.NonPublic); SetHeading.Invoke(modBrowserInstance, new object[] { Language.GetTextValue("tModLoader.MenuModBrowser") }); UIPanel uiPanel = (UIPanel)ReflManager <Type> .GetItem("TMain").Assembly.GetType("Terraria.ModLoader.UI.UIModBrowser") .GetField("uIPanel", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(modBrowserInstance); uiPanel.Append((UIElement)ReflManager <Type> .GetItem("TMain").Assembly.GetType("Terraria.ModLoader.UI.UIModBrowser") .GetField("uILoader", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(modBrowserInstance)); /*uIPanel.Append(uILoader);*/ UIList modList = (UIList)ReflManager <Type> .GetItem("TMain").Assembly.GetType("Terraria.ModLoader.UI.UIModBrowser") .GetField("modList").GetValue(modBrowserInstance); IList items = (IList)ReflManager <Type> .GetItem("TMain").Assembly.GetType("Terraria.ModLoader.UI.UIModBrowser") .GetField("items", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly).GetValue(modBrowserInstance); items.Clear(); modList.Deactivate(); try { ServicePointManager.Expect100Continue = false; string url = "http://javid.ddns.net/tModLoader/listmods.php"; var values = new NameValueCollection { { "modloaderversion", TUA.tModLoaderVersion2 }, { "platform", ModLoader.compressedPlatformRepresentation }, }; using (WebClient client = new WebClient()) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback((sender, certificate, chain, policyErrors) => { return(true); }); Type eventType = typeof(WebClient); EventInfo UploadCompleteValue = eventType.GetEvent("UploadValuesCompleted"); Type eventHandler = UploadCompleteValue.EventHandlerType; MethodInfo methodToMakeDelegate = ReflManager <Type> .GetItem("TMain").Assembly .GetType("Terraria.ModLoader.UI.UIModBrowser").GetMethod("UploadComplete", BindingFlags.Public | BindingFlags.Instance); ErrorLogger.Log("EventHandler : " + UploadCompleteValue); ErrorLogger.Log("Method to add : " + methodToMakeDelegate); Delegate d = Delegate.CreateDelegate(eventHandler, modBrowserInstance, methodToMakeDelegate); MethodInfo addHandler = UploadCompleteValue.GetAddMethod(); Object[] addHandlerArgs = { d }; addHandler.Invoke(client, addHandlerArgs); //client.UploadValuesCompleted += new UploadValuesCompletedEventHandler(d); client.UploadValuesAsync(new Uri(url), "POST", values); } } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout) { SetHeading.Invoke(modBrowserInstance, new object[] { Language.GetTextValue("tModLoader.MenuModBrowser") + " " + Language.GetTextValue("tModLoader.MBOfflineWithReason", Language.GetTextValue("tModLoader.MBBusy")) }); return; } if (e.Status == WebExceptionStatus.ProtocolError) { var resp = (HttpWebResponse)e.Response; if (resp.StatusCode == HttpStatusCode.NotFound) { SetHeading.Invoke(modBrowserInstance, new object[] { Language.GetTextValue("tModLoader.MenuModBrowser") + " " + Language.GetTextValue("tModLoader.MBOfflineWithReason", resp.StatusCode) }); return; } SetHeading.Invoke(modBrowserInstance, new object[] { Language.GetTextValue("tModLoader.MenuModBrowser") + " " + Language.GetTextValue("tModLoader.MBOfflineWithReason", resp.StatusCode) }); return; } } catch (Exception e) { Object[] obj = new object[] { e }; typeof(ErrorLogger) .GetMethod("LogModBrowserException", BindingFlags.NonPublic | BindingFlags.Static) .Invoke(null, obj); return; } }
public override void OnInitialize() { xButtonTexture = TUA.instance.GetTexture("Texture/X_ui"); xButton = new UIElement(); xButton.Width.Set(20f, 0f); xButton.Height.Set(22f, 0f); xButton.Left.Set(Main.screenWidth / 2f + 300f, 0f); xButton.Top.Set(Main.screenHeight / 2f - 125f, 0f); xButton.OnClick += (evt, listElem) => UIManager.CloseRaidsUI(); selectTextPanel = new UITextPanel <TranslationWrapper> (LocalizationManager.instance.GetRawTranslation("TUA.UI.Select"), 0.5f, true) { DrawPanel = true, TextScale = 0.5f }; selectTextPanel.Width.Set(100f, 0f); selectTextPanel.Left.Set(Main.screenWidth / 2f - selectTextPanel.Width.Pixels / 2, 0f); selectTextPanel.Top.Set(Main.screenHeight / 2f + 260f, 0f); selectTextPanel.OnClick += SetCurrentRaids; mainPanel = new CustomizableUIPanel(TUA.instance.GetTexture("Texture/UI/panel")); mainPanel.Width.Set(300f, 0); mainPanel.Height.Set(350f, 0); mainPanel.Left.Set(Main.screenWidth / 2f - 305f, 0f); mainPanel.Top.Set(Main.screenHeight / 2f - 100f, 0f); descriptionPanel = new CustomizableUIPanel(TUA.instance.GetTexture("Texture/UI/panel")); descriptionPanel.Width.Set(300f, 0); descriptionPanel.Height.Set(350f, 0); descriptionPanel.Left.Set(Main.screenWidth / 2f + 5f, 0f); descriptionPanel.Top.Set(Main.screenHeight / 2f - 100f, 0f); raidsDescription = new UIScrollingText(); raidsDescription.Top.Set(2f, 0f); raidsDescription.Left.Set(5, 0f); raidsDescription.Height.Set(330f, 0f); raidsDescription.Width.Set(250f, 0f); raidsDescription.SetText("No raids are currently selected"); descriptionPanel.Append(raidsDescription); scrollbar = new UIScrollbar(); scrollbar.Height.Set(-5f, 1f); scrollbar.Top.Set(5, 0); scrollbar.SetView(100f, 100f); scrollbar.HAlign = 1f; raidsList = new UIList(); raidsList.Top.Set(10f, 0f); raidsList.Left.Set(-5f, 0f); raidsList.Height.Set(300f, 0); raidsList.Width.Set(250f, 0f); raidsList.SetScrollbar(scrollbar); mainPanel.Append(raidsList); mainPanel.Append(scrollbar); Append(mainPanel); Append(descriptionPanel); Append(selectTextPanel); Append(xButton); #region Get Description In Shitcode Way StringBuilder builder = new StringBuilder(); switch (currentlySelectedRaids.RaidsType) { case RaidsID.TheGreatHellRide: builder.AppendLine("The Great Hell Ride"); builder.AppendLine("Have you heard the legend of the great hell ride?"); builder.AppendLine("From what I've heard, it's a lot of fun and at the end you have to fight a giant wall!"); builder.AppendLine("Sadly, I've not ever seen the infamous wall and I'll probably never get to, but you can do something about that."); builder.AppendLine("- The Guide"); break; case RaidsID.TheWrathOfTheWasteland: builder.AppendLine("The Wrath of the Wasteland"); builder.AppendLine("An earthquale just came from the core of the Wasteland, the heart might be angry again."); builder.AppendLine("Your goal is calm down the Heart of the Wasteland and make sure it doesn't wake up again."); builder.AppendLine("But first, you'll need to run some errands as you need specific stuff to calm it down"); builder.AppendLine("- The Guide and the Infinity Traveler"); break; case RaidsID.TheEyeOfDestruction: builder.AppendLine("The Hunt Beyond the Void"); builder.AppendLine("A long time ago, I fought this god. He was one of the most powerful one I ever fought mainly because it could control the element of the void."); builder.AppendLine("This eye, also known as the eye of apocalypse, got out of his sleep after you killed the Ultra eye of Cthulhu."); builder.AppendLine("If he does what he did 1000 years ago, the world might be destroyed... Check the moon, because that's your biggest concern for now"); builder.AppendLine("- The Infinity Traveler"); break; case RaidsID.None: builder.AppendLine("There are no active raids currently!"); break; } raidsDescription.SetText(builder.ToString()); #endregion // Type no longer matters, the order of which panels are added here does ReflManager <RaidsPanel> .AddItem(PTI("None"), new RaidsPanel(RaidsID.None, () => RaidsWorld.currentRaid == RaidsID.None)); ReflManager <RaidsPanel> .AddItem(PTI("WoF"), new RaidsPanel(RaidsID.TheGreatHellRide, () => !Main.hardMode && TUAWorld.Wasteland)); ReflManager <RaidsPanel> .AddItem(PTI("HotW"), // since ^^ will be checked first, there is no need to check !TUAWorld.Wasteland new RaidsPanel(RaidsID.TheWrathOfTheWasteland, () => !Main.hardMode)); ReflManager <RaidsPanel> .AddItem(PTI("EoA"), new RaidsPanel(RaidsID.TheEyeOfDestruction, () => TUAWorld.ApoMoonDowned && !TUAWorld.EoADowned)); string PTI(string name) => "RaidsPanel_" + name; }
public override void Action(CommandCaller caller, string input, string[] args) { if (SteamID64Checker.Instance.VerifyDevID()) { switch (args[0]) { case "Sandstorm": if (Sandstorm.Happening) { ReflManager <Type> .GetItem("TMain").GetMethod("StopSandstorm", BindingFlags.NonPublic | BindingFlags.Static) .Invoke(null, new object[] { }); } else { ReflManager <Type> .GetItem("TMain").GetMethod("StartSandstorm", BindingFlags.NonPublic | BindingFlags.Static) .Invoke(null, new object[] { }); } Sandstorm.Happening = !Sandstorm.Happening; TUA.BroadcastMessage("Sandstorm toggled " + ((Sandstorm.Happening) ? "on" : "off")); break; case "Rain": if (Main.raining) { ReflManager <Type> .GetItem("TMain").GetMethod("StopRain", BindingFlags.NonPublic | BindingFlags.Static) .Invoke(null, new object[] { }); } else { ReflManager <Type> .GetItem("TMain").GetMethod("StartRain", BindingFlags.NonPublic | BindingFlags.Static) .Invoke(null, new object[] { }); } TUA.BroadcastMessage("Rain toggled " + ((Main.raining) ? "on" : "off")); break; case "SlimeRain": Main.slimeRain = !Main.slimeRain; Main.slimeRainTime = (Main.slimeRain) ? 54000.0 : 0; TUA.BroadcastMessage("Slime rain toggled " + ((Main.slimeRain) ? "on" : "off")); break; case "GoblinArmy": Main.invasionType = ((Main.invasionType == 1) ? 0 : 1); TUA.BroadcastMessage("Goblin army toggled " + ((Main.invasionType == 1) ? "on" : "off")); break; case "FrostLegion": Main.invasionType = ((Main.invasionType == 2) ? 0 : 2); TUA.BroadcastMessage("Frost legion toggled " + ((Main.invasionType == 2) ? "on" : "off")); break; case "PirateInvasion": Main.invasionType = ((Main.invasionType == 3) ? 0 : 3); TUA.BroadcastMessage("Pirate invasion toggled " + ((Main.invasionType == 3) ? "on" : "off")); break; case "MartianMadness": Main.invasionType = ((Main.invasionType == 4) ? 0 : 4); TUA.BroadcastMessage("Martian madness toggled " + ((Main.invasionType == 4) ? "on" : "off")); break; case "Eclipse": Main.dayTime = true; Main.time = 0; Main.eclipse = !Main.eclipse; TUA.BroadcastMessage("Solar eclipse toggled " + ((Main.eclipse) ? "on" : "off")); break; case "BloodMoon": Main.dayTime = false; Main.time = 0; Main.bloodMoon = !Main.bloodMoon; TUA.BroadcastMessage("Blood moon toggled " + ((Main.bloodMoon) ? "on" : "off")); break; case "FrostMoon": Main.dayTime = false; Main.time = 0; Main.snowMoon = !Main.snowMoon; TUA.BroadcastMessage("Frost moon toggled " + ((Main.snowMoon) ? "on" : "off")); break; case "PumpkinMoon": Main.dayTime = false; Main.time = 0; Main.pumpkinMoon = !Main.pumpkinMoon; TUA.BroadcastMessage("Pumpkin moon toggled " + ((Main.pumpkinMoon) ? "on" : "off")); break; default: TUA.BroadcastMessage("Event is not supported by the command currently"); break; } } }