Esempio n. 1
0
        public Color GetTintColor()
        {
            var   mymod     = TheLunaticMod.Instance;
            Color color     = Color.Black;
            float tintScale = MathHelper.Clamp(this.TintScale, 0f, 1f);
            float daySpike  = (float)Math.Abs(WorldStateHelpers.GetDayOrNightPercentDone() - 0.5d);

            if (Main.dayTime)
            {
                tintScale *= 1f - daySpike;
            }
            else
            {
                tintScale *= (daySpike * 0.6f) + 0.2f;
            }

            color.R = (byte)(255f * tintScale);
            color.G = (byte)(128f * tintScale);
            color.A = (byte)(255f * tintScale);

            if (mymod.Config.DebugModeInfo)
            {
                DebugHelpers.Print("Sky", color.ToString(), 20);
            }
            return(color);
        }
Esempio n. 2
0
        ////////////////

        protected override void InitializeServerSendData(int fromWho)
        {
            var myworld = ModContent.GetInstance <ModHelpersWorld>();

            this.HalfDays            = WorldStateHelpers.GetElapsedHalfDays();
            this.HasObsoletedWorldId = myworld.HasObsoleteId;
            this.ObsoletedWorldId    = myworld.ObsoleteId;
        }
Esempio n. 3
0
        public void UnloadModules()
        {
            this.Loadables.OnModsUnload();

            this.Loadables                  = null;
            this.ReflectionHelpers          = null;
            this.PacketProtocolMngr         = null;
            this.ExceptionMngr              = null;
            this.Timers                     = null;
            this.LogHelpers                 = null;
            this.ModFeaturesHelpers         = null;
            this.BuffHelpers                = null;
            this.NetHelpers                 = null;
            this.NPCAttributeHelpers        = null;
            this.ProjectileAttributeHelpers = null;
            this.BuffIdentityHelpers        = null;
            this.NPCBannerHelpers           = null;
            this.RecipeFinderHelpers        = null;
            this.RecipeGroupHelpers         = null;
            this.PlayerHooks                = null;
            this.LoadHelpers                = null;
            this.GetModInfo                 = null;
            this.GetModTags                 = null;
            this.WorldStateHelpers          = null;
            this.ModLock                    = null;
            this.EntityGroups               = null;
            this.AnimatedColors             = null;
            this.AnimatedTextures           = null;
            this.PlayerMessages             = null;
            this.Inbox                 = null;
            this.ControlPanel          = null;
            this.MenuItemMngr          = null;
            this.MenuContextMngr       = null;
            this.MusicHelpers          = null;
            this.PlayerIdentityHelpers = null;
            this.LoadHooks             = null;
            this.CustomLoadHooks       = null;
            this.DataStore             = null;
            this.CustomHotkeys         = null;
            this.XnaHelpers            = null;
            this.Server                = null;
            //this.PlayerDataMngr = null;
            this.SupportInfo          = null;
            this.RecipeHack           = null;
            this.ModListHelpers       = null;
            this.ItemAttributeHelpers = null;
            this.WorldTimeHooks       = null;

            this.ControlPanelHotkey = null;
            this.DataDumpHotkey     = null;
        }
        public void UnloadOuter()
        {
            this.ReflectionHelpers         = null;
            this.PacketProtocolMngr        = null;
            this.ExceptionMngr             = null;
            this.Timers                    = null;
            this.ConfigJson                = null;
            this.LogHelpers                = null;
            this.ModFeaturesHelpers        = null;
            this.BuffHelpers               = null;
            this.NetHelpers                = null;
            this.ItemIdentityHelpers       = null;
            this.NPCIdentityHelpers        = null;
            this.ProjectileIdentityHelpers = null;
            this.BuffIdentityHelpers       = null;
            this.NPCBannerHelpers          = null;
            this.RecipeIdentityHelpers     = null;
            this.RecipeGroupHelpers        = null;
            this.PlayerHooks               = null;
            this.LoadHelpers               = null;
            this.GetModInfo                = null;
            this.GetModTags                = null;
            this.WorldStateHelpers         = null;
            this.ModLock                   = null;
            this.EntityGroups              = null;
            this.AnimatedColors            = null;
            this.PlayerMessages            = null;
            this.Inbox                 = null;
            this.ControlPanel          = null;
            this.MenuItemMngr          = null;
            this.MenuContextMngr       = null;
            this.MusicHelpers          = null;
            this.PlayerIdentityHelpers = null;
            this.CustomEntMngr         = null;
            this.Promises              = null;
            this.DataStore             = null;
            this.CustomHotkeys         = null;
            this.XnaHelpers            = null;
            this.ServerInfo            = null;
            //this.PlayerDataMngr = null;
            this.SupportInfo    = null;
            this.RecipeHack     = null;
            this.ModListHelpers = null;

            this.ControlPanelHotkey = null;
            this.DataDumpHotkey     = null;
        }
Esempio n. 5
0
        private void LoadModules()
        {
            this.Loadables.OnModsLoad();

            this.ReflectionHelpers = new ReflectionHelpers();
            this.DataStore         = new DataStore();
            this.LoadHooks         = new LoadHooks();
            this.CustomLoadHooks   = new CustomLoadHooks();
            this.LoadHelpers       = new LoadHelpers();

            this.Timers             = new Timers();
            this.LogHelpers         = new LogHelpers();
            this.ModFeaturesHelpers = new ModFeaturesHelpers();
            this.PacketProtocolMngr = new PacketProtocolManager();

            this.BuffHelpers                = new BuffHelpers();
            this.NetHelpers                 = new NetPlayHelpers();
            this.NPCAttributeHelpers        = new NPCAttributeHelpers();
            this.ProjectileAttributeHelpers = new ProjectileAttributeHelpers();
            this.BuffIdentityHelpers        = new BuffAttributesHelpers();
            this.NPCBannerHelpers           = new NPCBannerHelpers();
            this.RecipeFinderHelpers        = new RecipeFinderHelpers();
            this.RecipeGroupHelpers         = new RecipeGroupHelpers();
            this.PlayerHooks                = new ExtendedPlayerHooks();
            this.WorldTimeHooks             = new WorldTimeHooks();
            this.WorldStateHelpers          = new WorldStateHelpers();
            this.ControlPanel               = new UIControlPanel();
            this.ModLock               = new ModLockService();
            this.EntityGroups          = new EntityGroups();
            this.PlayerMessages        = new PlayerMessages();
            this.Inbox                 = new InboxControl();
            this.GetModInfo            = new GetModInfo();
            this.GetModTags            = new GetModTags();
            this.MenuItemMngr          = new MenuItemManager();
            this.MenuContextMngr       = new MenuContextServiceManager();
            this.MusicHelpers          = new MusicHelpers();
            this.PlayerIdentityHelpers = new PlayerIdentityHelpers();
            this.CustomHotkeys         = new CustomHotkeys();
            this.XnaHelpers            = new XNAHelpers();
            this.Server                = new Server();
            //this.PlayerDataMngr = new PlayerDataManager();
            this.SupportInfo          = new SupportInfoDisplay();
            this.RecipeHack           = new RecipeHack();
            this.ModListHelpers       = new ModListHelpers();
            this.ItemAttributeHelpers = new ItemAttributeHelpers();
        }
Esempio n. 6
0
        private void UpdateEndSigns()
        {
            var mymod = TheLunaticMod.Instance;

            if (this.HaveWeEndSigns())
            {
                int halfDaysLeft = (mymod.Config.DaysUntil * 2) - this.HalfDaysElapsed;
                int rand         = Main.rand.Next(halfDaysLeft * 60 * 54);

                if (Main.netMode != 1 && rand == 0)                     // Not client
                {
                    int duration = (int)(120 + (60 * 4 * Main.rand.NextFloat()));

                    if (Main.netMode == 2)                              // Server
                    {
                        ServerPacketHandlers.BroadcastEndSignFromServer(duration);
                    }
                    else if (Main.netMode == 0)                                 // Single-player
                    {
                        this.ApplyEndSignForMe(duration);
                    }
                }

                if (Main.netMode != 2)                      // Not server
                {
                    if (halfDaysLeft != 0)
                    {
                        double days = (double)this.HalfDaysElapsed + WorldStateHelpers.GetDayOrNightPercentDone();
                        days -= mymod.Config.DaysUntil;
                        mymod.Sky.TintScale = (float)days / (float)mymod.Config.DaysUntil;
                    }
                    else
                    {
                        mymod.Sky.TintScale = 0;
                    }
                }
            }
            else if (Main.netMode != 2)                         // Not server
            {
                mymod.Sky.TintScale = 0;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Gets a list of assorted game data statistics, formatted for (markdown) output.
        /// </summary>
        /// <param name="mods">Mods to display in this list. Typically only the set of loaded mods (ModLoader.Mods`).</param>
        /// <returns></returns>
        public static IList <string> GetFormattedGameInfo(IEnumerable <Mod> mods)
        {
            var list = new List <string>();

            var modsList = mods.OrderBy(m => m.Name)
                           .SafeSelect(m => StringFormattingHelpers.SanitizeMarkdown(m.DisplayName) + " " + m.Version.ToString())
                           .ToArray();
            bool   isDay     = Main.dayTime;
            double timeOfDay = Main.time;
            int    halfDays  = WorldStateHelpers.GetElapsedHalfDays();
            string worldSize = WorldHelpers.GetSize().ToString();

            string[] worldProg   = GameInfoHelpers.GetVanillaProgressList().ToArray();
            int      activeItems = ItemHelpers.GetActive().Count;
            int      activeNpcs  = NPCHelpers.GetActive().Count;
            //string[] playerInfos = InfoHelpers.GetCurrentPlayerInfo().ToArray();
            //string[] playerEquips = InfoHelpers.GetCurrentPlayerEquipment().ToArray();
            int    activePlayers   = Main.ActivePlayersCount;
            string netmode         = Main.netMode == 0 ? "single-player" : "multiplayer";
            bool   autopause       = Main.autoPause;
            bool   autosave        = Main.autoSave;
            int    lighting        = Lighting.lightMode;
            int    lightingThreads = Lighting.LightingThreads;
            int    frameSkipMode   = Main.FrameSkipMode;
            bool   isMaximized     = Main.screenMaximized;
            int    windowWid       = Main.screenWidth;
            int    windowHei       = Main.screenHeight;
            int    qualityStyle    = Main.qaStyle;
            bool   bgOn            = Main.BackgroundEnabled;
            bool   childSafe       = !ChildSafety.Disabled;
            float  gameZoom        = Main.GameZoomTarget;
            float  uiZoom          = Main.UIScale;

            list.Add("tModLoader version: " + ModLoader.version.ToString());
            list.Add(FormattedGameInfoHelpers.RenderMarkdownModTable(modsList));
            list.Add(FormattedGameInfoHelpers.RenderMarkdownPlayersTable());

            for (int i = 0; i < Main.player.Length; i++)
            {
                Player plr = Main.player[i];
                if (plr == null || !plr.active)
                {
                    continue;
                }

                list.Add(FormattedGameInfoHelpers.RenderMarkdownPlayerEquipsTable(plr));
            }

            list.Add("Is day: " + isDay + ", Time of day/night: " + timeOfDay + ", Elapsed half days: " + halfDays);                //+ ", Total time (seconds): " + Main._drawInterfaceGameTime.TotalGameTime.Seconds;
            list.Add("World name: " + StringFormattingHelpers.SanitizeMarkdown(Main.worldName) + ", world size: " + worldSize);
            list.Add("World progress: " + (worldProg.Length > 0 ? string.Join(", ", worldProg) : "none"));
            list.Add("Items on ground: " + activeItems + ", Npcs active: " + activeNpcs);
            //list.Add( "Player info: " + string.Join( ", ", playerInfos ) );
            //list.Add( "Player equips: " + (playerEquips.Length > 0 ? string.Join(", ", playerEquips) : "none" ) );
            list.Add("Player count: " + activePlayers + " (" + netmode + ")");
            list.Add("Autopause: " + autopause);
            list.Add("Autosave: " + autosave);
            list.Add("Lighting mode: " + lighting);
            list.Add("Lighting threads: " + lightingThreads);
            list.Add("Frame skip mode: " + frameSkipMode);
            list.Add("Is screen maximized: " + isMaximized);
            list.Add("Screen resolution: " + windowWid + " " + windowHei);
            list.Add("Quality style: " + qualityStyle);
            list.Add("Background on: " + bgOn);
            list.Add("Child safety: " + childSafe);
            list.Add("Game zoom: " + gameZoom);
            list.Add("UI zoom: " + uiZoom);
            list.Add("FrameworkVersion.Framework: " + Enum.GetName(typeof(FrameworkVersion), FrameworkVersion.Framework));
            list.Add("FrameworkVersion.Version: " + FrameworkVersion.Version.ToString());

            return(list);
        }
Esempio n. 8
0
        ////////////////

        public void RegisterReceiptOfMask(Player givingPlayer, int maskType, int bossNpcType)
        {
            var mymod = TheLunaticMod.Instance;

            if (maskType == ModContent.ItemType <CustomBossMaskItem>() && bossNpcType != 0 && bossNpcType != -1)                // -1 for legacy support
            {
                NPC npc = new NPC();
                npc.SetDefaults(bossNpcType);

                this.GivenCustomMasksByBossUid.Add(NPCID.GetUniqueKey(npc));
            }
            else
            {
                this.GivenVanillaMasksByType.Add(maskType);
            }

            if (mymod.Config.DebugModeInfo)
            {
                LogHelpers.Log("DEBUG Registering mask. " + givingPlayer.name + ", " + maskType);
            }

            // Buy time before the end comes
            if (this.GivenVanillaMasksByType.Count < (MaskLogic.AvailableMaskCount))
            {
                var modworld  = ModContent.GetInstance <TheLunaticWorld>();
                int recovered = mymod.Config.HalfDaysRecoveredPerMask;

                switch (maskType)
                {
                case ItemID.FleshMask:
                    recovered = (int)((float)recovered * mymod.Config.WallOfFleshMultiplier);
                    break;

                case ItemID.DestroyerMask:
                case ItemID.TwinMask:
                case ItemID.SkeletronPrimeMask:
                case ItemID.PlanteraMask:
                case ItemID.GolemMask:
                case ItemID.DukeFishronMask:
                case ItemID.BossMaskBetsy:
                case ItemID.BossMaskCultist:
                case ItemID.BossMaskMoonlord:
                    if (maskType == ItemID.BossMaskMoonlord && mymod.Config.MoonLordMaskWins)
                    {
                        this.GiveAllVanillaMasks();
                    }
                    recovered = (int)((float)recovered * mymod.Config.HardModeMultiplier);
                    break;
                }

                if (WorldStateHelpers.GetDayOrNightPercentDone() > 0.5f)
                {
                    recovered += 1;
                }

                modworld.GameLogic.SetTime(modworld.GameLogic.HalfDaysElapsed - recovered);
            }

            // Sky flash for all
            if (!Main.dedServ && Main.netMode != 2)                 // Not server
            {
                Player currentPlayer = Main.player[Main.myPlayer];
                var    modplayer     = currentPlayer.GetModPlayer <TheLunaticPlayer>();
                modplayer.FlashMe();
            }
        }