Esempio n. 1
0
        ////////////////

        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 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();
                }
            }
        }
Esempio n. 3
0
        /// <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);
        }