//////////////// public WorldLogic() { var flags = NPCInvasionHelpers.GetCurrentEventTypeSet(); /*this.CurrentEvents = new ConcurrentDictionary<VanillaEventFlag, byte>( * DotNetHelpers.FlagsToList<VanillaEventFlag>( (int)flags ) * .Select( t => new KeyValuePair<VanillaEventFlag, byte>(t, 0) ) * );*/ this.CurrentEvents = new HashSet <VanillaEventFlag>( DotNetHelpers.FlagsToCollection <VanillaEventFlag>((int)flags) ); }
public static IList <string> GetCurrentVanillaEvents() { IList <VanillaInvasionType> list = NPCInvasionHelpers.GetCurrentEventTypes(); IList <string> out_list = new List <string>( list.Select(event_type => { switch (event_type) { case VanillaInvasionType.FrostLegion: return("Frost Legion"); case VanillaInvasionType.BloodMoon: return("Blood Moon"); case VanillaInvasionType.SlimeRain: return("Slime Rain"); case VanillaInvasionType.SolarEclipse: return("Solar Eclipse"); case VanillaInvasionType.PumpkinMoon: return("Pumpkin Moon"); case VanillaInvasionType.FrostMoon: return("Frost Moon"); case VanillaInvasionType.LunarApocalypse: return("Lunar Apocalypse"); default: return(event_type.ToString()); } }) ); if (out_list.Count == 0) { out_list.Add("Normal"); } return(out_list); }
public void UpdateEvents() { if (Main.netMode == 1) { return; } VanillaEventFlag currentEventFlags = NPCInvasionHelpers.GetCurrentEventTypeSet(); bool eventsChanged = false; eventsChanged = this.UpdateForEventChangesAndEndings(currentEventFlags); eventsChanged = this.UpdateForEventsBeginnings(currentEventFlags) || eventsChanged; if (eventsChanged) { if (Main.netMode == 2) { EventsSyncProtocol.QuickSend(); } } }
/// <summary> /// Gets a list of currently active (vanilla) world events. /// </summary> /// <returns></returns> public static IList <string> GetCurrentVanillaEvents() { VanillaEventFlag flags = NPCInvasionHelpers.GetCurrentEventTypeSet(); IList <string> outList = new List <string>(); if ((flags & VanillaEventFlag.Goblins) > 0) { flags -= VanillaEventFlag.Goblins; outList.Add("Goblins"); } if ((flags & VanillaEventFlag.FrostLegion) > 0) { flags -= VanillaEventFlag.FrostLegion; outList.Add("Frost Legion"); } if ((flags & VanillaEventFlag.Pirates) > 0) { flags -= VanillaEventFlag.Pirates; outList.Add("Pirates"); } if ((flags & VanillaEventFlag.Martians) > 0) { flags -= VanillaEventFlag.Martians; outList.Add("Martians"); } if ((flags & VanillaEventFlag.BloodMoon) > 0) { flags -= VanillaEventFlag.BloodMoon; outList.Add("Blood Moon"); } if ((flags & VanillaEventFlag.SlimeRain) > 0) { flags -= VanillaEventFlag.SlimeRain; outList.Add("Slime Rain"); } if ((flags & VanillaEventFlag.Sandstorm) > 0) { flags -= VanillaEventFlag.Sandstorm; outList.Add("Sandstorm"); } if ((flags & VanillaEventFlag.SolarEclipse) > 0) { flags -= VanillaEventFlag.SolarEclipse; outList.Add("Solar Eclipse"); } if ((flags & VanillaEventFlag.PumpkinMoon) > 0) { flags -= VanillaEventFlag.PumpkinMoon; outList.Add("Pumpkin Moon"); } if ((flags & VanillaEventFlag.FrostMoon) > 0) { flags -= VanillaEventFlag.FrostMoon; outList.Add("Frost Moon"); } if ((flags & VanillaEventFlag.LunarApocalypse) > 0) { flags -= VanillaEventFlag.LunarApocalypse; outList.Add("Lunar Apocalypse"); } if (outList.Count == 0) { outList.Add("Normal"); } return(outList); }