示例#1
0
        ////////////////

        internal LoadHelpers()
        {
            LoadHooks.AddWorldLoadEachHook(() => {
                this.WorldStartupDelay = 0;
            });
            LoadHooks.AddWorldUnloadEachHook(() => {
                this.WorldStartupDelay       = 0;
                this.IsClientPlaying_Hackish = false;
            });
            LoadHooks.AddPostWorldUnloadEachHook(() => {              // Redundant?
                this.WorldStartupDelay       = 0;
                this.IsClientPlaying_Hackish = false;
            });
        }
        ////////////////

        private void InitializeToggler()
        {
            this.IsTogglerLit = false;

            LoadHooks.AddWorldLoadEachHook(() => {
                var uiModCtrlPanel = (UIModControlPanelTab)ModHelpersMod.Instance.ControlPanel.DefaultTab;
                int modUpdateCount = uiModCtrlPanel.GetModUpdatesAvailable();

                if (modUpdateCount > 0)
                {
                    InboxMessages.SetMessage("mod_updates", modUpdateCount + " mod updates available. See mod browser.", true);
                }
            });
        }
        public static void InitializeStatic(BetterPaintMod mymod)
        {
            if (!Main.dedServ && PaintBlasterHUD.AmmoCan == null)
            {
                PaintBlasterHUD.AmmoCan = mymod.GetTexture("UI/PaintBlasterHUD/PaintAmmoContainer");
                PaintBlasterHUD.AmmoTop = mymod.GetTexture("UI/PaintBlasterHUD/PaintAmmoTop");
                PaintBlasterHUD.AmmoBot = mymod.GetTexture("UI/PaintBlasterHUD/PaintAmmoBottom");

                LoadHooks.AddModUnloadHook(() => {
                    PaintBlasterHUD.AmmoCan = null;
                    PaintBlasterHUD.AmmoTop = null;
                    PaintBlasterHUD.AmmoBot = null;
                });
            }
        }
        ////////////////

        public MenuItemManager()
        {
            if (!Main.dedServ)
            {
                Main.OnPostDraw += MenuItemManager._Draw;
            }

            LoadHooks.AddModUnloadHook(() => {
                try {
                    if (!Main.dedServ)
                    {
                        Main.OnPostDraw -= MenuItemManager._Draw;
                    }
                } catch { }
            });
        }
示例#5
0
        ////////////////

        public InventoryUI() : base()
        {
            var mymod = ExtensibleInventoryMod.Instance;

            this.ButtonBookTex      = ModContent.GetTexture("Terraria/Item_531");            // Spell Tome
            this.ButtonBookDimTex   = ModContent.GetTexture("Terraria/Item_1313");           // Book of Skulls
            this.ButtonBookLitTex   = ModContent.GetTexture("Terraria/Item_1336");           // Golden Shower
            this.ButtonPageRightTex = mymod.GetTexture("UI/ButtonRight");
            this.ButtonPageLeftTex  = mymod.GetTexture("UI/ButtonLeft");
            this.ButtonPageAddTex   = mymod.GetTexture("UI/ButtonAdd");
            this.ButtonPageSubTex   = mymod.GetTexture("UI/ButtonSub");

            LoadHooks.AddWorldUnloadEachHook(() => {
                this.ButtonBooks = null;
            });
        }
示例#6
0
        public override void Load()
        {
            LoadHooks.AddWorldLoadEachHook(delegate {
                this.CurrentNetMode = Main.netMode;
            });

            CustomLoadHooks.AddHook(ResetModeMod.WorldExitValidator, (_) => {
                this.CurrentNetMode = -1;
                return(true);
            });

            this.Session.OnModLoad();

            DataDumper.SetDumpSource("ResetMode", () => {
                return(ResetModeMod.Instance.Session.Data.ToString());
            });
        }
示例#7
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();
        }
示例#8
0
        ////////////////

        /// @private
        void ILoadable.OnModsLoad()
        {
            LoadHooks.AddPostContentLoadHook(() => {
                this.BannerItemTypesToNpcTypes = new Dictionary <int, ISet <int> >();
                this.NpcTypesToBannerItemTypes = NPCBannerLibraries.GetNpcToBannerItemTypes();

                foreach (var kv in this.NpcTypesToBannerItemTypes)
                {
                    if (!this.BannerItemTypesToNpcTypes.ContainsKey(kv.Value))
                    {
                        this.BannerItemTypesToNpcTypes[kv.Value] = new HashSet <int>();
                    }
                    this.BannerItemTypesToNpcTypes[kv.Value].Add(kv.Key);
                }

                this.BannerItemTypes = new HashSet <int>(this.BannerItemTypesToNpcTypes.Keys);
            });
        }
示例#9
0
        private void Initialize(Item item)
        {
            if (this.AwaitsInitialization || this.IsInitialized || !ElementsItem.CanHaveElements(item))
            {
                return;
            }
            this.AwaitsInitialization = true;

            LoadHooks.AddWorldLoadOnceHook(() => {
                this.AwaitsInitialization = false;
                this.IsInitialized        = true;

                if (ElementsAPI.PreItemInitialize(item))
                {
                    this.AutoInitializeElement(item);
                }
            });
        }
示例#10
0
        ////////////////

        public override void SetStaticDefaults()
        {
            this.DisplayName.SetDefault("Color Cartridge");
            this.Tooltip.SetDefault("Needs a Paint Plaster to use" + '\n' +
                                    "Make cartridges with paint at a paint mixer" + '\n' +
                                    "Blend cartidges together at a paint mixer");

            if (!Main.dedServ && ColorCartridgeItem.ColorCartridgeTex == null)
            {
                ColorCartridgeItem.ColorCartridgeTex = this.mod.GetTexture("Items/ColorCartridgeItem");
                ColorCartridgeItem.ColorOverlayTex   = this.mod.GetTexture("Items/ColorCartridgeItem_Color");

                LoadHooks.AddModUnloadHook(() => {
                    ColorCartridgeItem.ColorOverlayTex   = null;
                    ColorCartridgeItem.ColorCartridgeTex = null;
                });
            }
        }
示例#11
0
        ////////////////

        internal InboxControl()
        {
            if (Main.netMode == 2)
            {
                return;
            }

            var mymod = ModHelpersMod.Instance;

            this.Icon       = mymod.GetTexture("Internals/Inbox/MiniIcon");
            this.IconLit    = mymod.GetTexture("Internals/Inbox/MiniIconLit2");
            this.ArrowLeft  = mymod.GetTexture("Internals/Inbox/ArrowLeft");
            this.ArrowRight = mymod.GetTexture("Internals/Inbox/ArrowRight");

            this.MessageScrollPos = this.Messages.Current;

            LoadHooks.AddWorldUnloadEachHook(this.OnWorldExit);
        }
        public static void OnPostModsLoad()
        {
            if (Main.dedServ)
            {
                return;
            }

            LoadHooks.AddPostModLoadHook(() => {
                Menus.InitializeOpenConfigButton();
                Menus.InitializeDebugModeMenuInfo();
                ModTagsEditorMenuContext.Initialize(true);
                ModTagsModBrowserMenuContext.Initialize(true);
                ModUpdatesMenuContext.Initialize();
                MenuTweaksMenuContext.Initialize();
                //if( AprilFoolsMenuContext.IsAprilFools() ) {
                //	AprilFoolsMenuContext.Initialize();
                //}
            });
        }
        ////////////////

        public TileDataManager()
        {
            this.OnTickGet = Timers.MainOnTickGet();
            Main.OnTick   += TileDataManager._Update;

            if (!Main.dedServ)
            {
                Overlays.Scene["TileDamageEffects"] = new TileEffectsOverlay();
                Overlays.Scene.Activate("TileDamageEffects");
            }

            LoadHooks.AddModUnloadHook(() => {
                Main.OnTick -= TileDataManager._Update;

                if (!Main.dedServ)
                {
                    Overlays.Scene["TileDamageEffects"].Deactivate();
                }
            });
        }
        ////////////////

        public override void SetStaticDefaults()
        {
            this.DisplayName.SetDefault("Glow Cartridge");
            this.Tooltip.SetDefault("Needs a Paint Blaster to use" + '\n' +
                                    "Produces glow-in-the-dark paint" + '\n' +
                                    "Craft with cartidges and glowing spores at a paint mixer");

            if (!Main.dedServ && GlowCartridgeItem.GlowCartridgeTex == null)
            {
                GlowCartridgeItem.GlowCartridgeTex = this.mod.GetTexture("Items/GlowCartridgeItem");
                GlowCartridgeItem.ColorOverlayTex  = this.mod.GetTexture("Items/GlowCartridgeItem_Color");
                GlowCartridgeItem.GlowMaskTex      = this.mod.GetTexture("Items/GlowCartridgeItem_Glow1");

                LoadHooks.AddModUnloadHook(() => {
                    GlowCartridgeItem.GlowCartridgeTex = null;
                    GlowCartridgeItem.ColorOverlayTex  = null;
                    GlowCartridgeItem.GlowMaskTex      = null;
                });
            }
        }
        private static void InitializeDebugModeMenuInfo()
        {
            if (!ModHelpersMod.Config.DebugModeMenuInfo)
            {
                return;
            }

            Main.OnPostDraw += Menus.DebugModeMenuInfo;
            Menus.DebugModeMenuInfoLoaded = true;

            LoadHooks.AddModUnloadHook(() => {
                try {
                    if (Menus.DebugModeMenuInfoLoaded)
                    {
                        Main.OnPostDraw -= Menus.DebugModeMenuInfo;
                    }
                } catch { }

                Menus.DebugModeMenuInfoLoaded = false;
            });
        }
示例#16
0
        ////////////////

        public override void SetDefaults()
        {
            int mytype = this.Type;

            this.DisplayName.SetDefault("Encumbered");
            this.Description.SetDefault("You're weighted down" + '\n' + "More items = more burden");

            Main.debuff[mytype] = true;

            if (!Main.dedServ && EncumberedDebuff.IconTex1 == null)
            {
                EncumberedDebuff.IconTex1 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_1");
                EncumberedDebuff.IconTex2 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_2");
                EncumberedDebuff.IconTex3 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_3");
                EncumberedDebuff.IconTex4 = EncumbranceMod.Instance.GetTexture("Buffs/EncumberedDebuff_4");

                if (!EncumberedDebuff.HasSetPromise)
                {
                    EncumberedDebuff.HasSetPromise = true;

                    CustomLoadHooks.AddHook(EncumbrancePlayer.PlayerMovementPromiseValidator, (whoAmI) => {
                        Player plr = Main.player[whoAmI];

                        if (plr != null && plr.active && plr.HasBuff(mytype))
                        {
                            EncumberedDebuff.ApplyMovementHinderance(plr);
                        }
                        return(true);
                    });
                }

                LoadHooks.AddModUnloadHook(() => {
                    EncumberedDebuff.IconTex1 = null;
                    EncumberedDebuff.IconTex2 = null;
                    EncumberedDebuff.IconTex3 = null;
                    EncumberedDebuff.IconTex4 = null;
                });
            }
        }
示例#17
0
        ////////////////

        public override void Load()
        {
            BetterPaintMod.Instance = this;

            LoadHooks.AddPostWorldLoadEachHook(() => {
                string intro1    = "1 of 5 - Eager to try out better painting? You'll need a Paint Blaster, crafted via " + (this.Config.PaintBlasterRecipeClentaminator ? "Clentaminator" : "Illegal Gun Parts") + " and Paint Sprayer at a Tinkerer's Workshop.";
                string intro2    = "2 of 5 - To make paint, you'll need a Paint Mixer, crafted via Dye Vat" + (this.Config.PaintMixerRecipeBlendOMatic ? ", Blend-O-Matic, " : " ") + "and Extractinator at a Tinkerer's Workshop.";
                string intro3    = "3 of 5 - To paint, you'll need Color Cartridges, crafted via colored Paints (any " + this.Config.PaintRecipePaints + ") and Gel (" + this.Config.PaintRecipeGels + ") at a Paint Mixer.";
                string postIntro = "4 of 5 - Use the Control Panel (single player only) to configure settings, including whether the Painter NPC should sell Better Paint items, if crafting isn't your cup of tea.";
                string pander    = "5 of 5 - If you enjoy this mod and want to see more, please give your support at: https://www.patreon.com/hamstar0";

                InboxMessages.SetMessage("BetterPaintIntro1", intro1, false);
                InboxMessages.SetMessage("BetterPaintIntro2", intro2, false);
                InboxMessages.SetMessage("BetterPaintIntro3", intro3, false);
                InboxMessages.SetMessage("BetterPaintPostIntro", postIntro, false);
                InboxMessages.SetMessage("BetterPaintPander", pander, false);

                if (Main.netMode != 0)
                {
                    InboxMessages.SetMessage("BetterPaintNoMuliYet", "Better Paint (as of v1.2.0) is not yet compatible with multiplayer.", true);
                }
            });
        }
示例#18
0
        public static void InitializeStatic(BetterPaintMod mymod)
        {
            if (!Main.dedServ && PaintBlasterUI.BrushStream == null)
            {
                PaintBlasterUI.BrushStream  = mymod.GetTexture("UI/PaintBlasterUI/BrushStream");
                PaintBlasterUI.BrushSpray   = mymod.GetTexture("UI/PaintBlasterUI/BrushSpray");
                PaintBlasterUI.BrushSpatter = mymod.GetTexture("UI/PaintBlasterUI/BrushSpatter");
                PaintBlasterUI.BrushEraser  = mymod.GetTexture("UI/PaintBlasterUI/BrushEraser");

                PaintBlasterUI.LayerFgTex   = mymod.GetTexture("UI/PaintBlasterUI/LayerFg");
                PaintBlasterUI.LayerBgTex   = mymod.GetTexture("UI/PaintBlasterUI/LayerBg");
                PaintBlasterUI.LayerBothTex = mymod.GetTexture("UI/PaintBlasterUI/LayerBoth");

                PaintBlasterUI.SizeSmallTex = mymod.GetTexture("UI/PaintBlasterUI/SizeSmall");
                PaintBlasterUI.SizeLargeTex = mymod.GetTexture("UI/PaintBlasterUI/SizeLarge");

                PaintBlasterUI.PressureLowTex = mymod.GetTexture("UI/PaintBlasterUI/PressureLow");
                PaintBlasterUI.PressureMidTex = mymod.GetTexture("UI/PaintBlasterUI/PressureMid");
                PaintBlasterUI.PressureHiTex  = mymod.GetTexture("UI/PaintBlasterUI/PressureHi");

                LoadHooks.AddModUnloadHook(() => {
                    PaintBlasterUI.BrushStream    = null;
                    PaintBlasterUI.BrushSpray     = null;
                    PaintBlasterUI.BrushSpatter   = null;
                    PaintBlasterUI.BrushEraser    = null;
                    PaintBlasterUI.LayerFgTex     = null;
                    PaintBlasterUI.LayerBgTex     = null;
                    PaintBlasterUI.LayerBothTex   = null;
                    PaintBlasterUI.SizeSmallTex   = null;
                    PaintBlasterUI.SizeLargeTex   = null;
                    PaintBlasterUI.PressureLowTex = null;
                    PaintBlasterUI.PressureMidTex = null;
                    PaintBlasterUI.PressureHiTex  = null;
                });
            }
        }
示例#19
0
        public override void Load()
        {
            LoadHooks.AddPostWorldUnloadEachHook(() => {
                try {
                    var myworld   = ModContent.GetInstance <RewardsWorld>();
                    myworld.Logic = null;
                } catch { }
            });

            DataDumper.SetDumpSource("Rewards", () => {
                if (Main.netMode == 2)
                {
                    return("  No 'current player' for server");
                }
                if (Main.myPlayer < 0 || Main.myPlayer >= Main.player.Length || Main.LocalPlayer == null || !Main.LocalPlayer.active)
                {
                    return("  Invalid player data");
                }

                var myplayer = (RewardsPlayer)TmlHelpers.SafelyGetModPlayer(Main.LocalPlayer, this, "RewardsPlayer");

                return("  IsFullySynced: " + myplayer.IsFullySynced);
            });
        }
示例#20
0
        ////////////////

        internal EntityGroups()
        {
            LoadHooks.AddPostModLoadHook(() => {
                if (!this.IsEnabled)
                {
                    return;
                }

                this.GetItemPool();
                this.GetNPCPool();
                this.GetProjPool();

                ThreadPool.QueueUserWorkItem(_ => {
                    int _check = 0;

                    try {
                        IList <EntityGroupMatcherDefinition <Item> > itemMatchers;
                        IList <EntityGroupMatcherDefinition <NPC> > npcMatchers;
                        IList <EntityGroupMatcherDefinition <Projectile> > projMatchers;

                        lock (EntityGroups.MyLock) {
                            itemMatchers = EntityGroups.DefineItemGroups();
                            _check++;
                            npcMatchers = EntityGroups.DefineNPCGroups();
                            _check++;
                            projMatchers = EntityGroups.DefineProjectileGroups();
                            _check++;
                        }

                        this.ComputeGroups <Item>(itemMatchers, ref this.ItemGroups, ref this.GroupsPerItem);
                        _check++;
                        this.ComputeGroups <NPC>(npcMatchers, ref this.NPCGroups, ref this.GroupsPerNPC);
                        _check++;
                        this.ComputeGroups <Projectile>(projMatchers, ref this.ProjGroups, ref this.GroupsPerProj);
                        _check++;

                        this.ComputeGroups <Item>(this.CustomItemMatchers, ref this.ItemGroups, ref this.GroupsPerItem);
                        _check++;
                        this.ComputeGroups <NPC>(this.CustomNPCMatchers, ref this.NPCGroups, ref this.GroupsPerNPC);
                        _check++;
                        this.ComputeGroups <Projectile>(this.CustomProjMatchers, ref this.ProjGroups, ref this.GroupsPerProj);
                        _check++;

                        lock (EntityGroups.MyLock) {
                            this.CustomItemMatchers = null;
                            this.CustomNPCMatchers  = null;
                            this.CustomProjMatchers = null;
                            this.ItemPool           = null;
                            this.NPCPool            = null;
                            this.ProjPool           = null;
                        }

                        CustomLoadHooks.TriggerHook(EntityGroups.LoadedAllValidator, EntityGroups.MyValidatorKey);
                        _check++;
                    } catch (Exception e) {
                        LogHelpers.Warn("Initialization failed (at #" + _check + "): " + e.ToString());
                    }
                });
            });

            //LoadHooks.AddModUnloadHook( () => {
            //	lock( EntityGroups.MyLock ) { }
            //} );
        }
示例#21
0
        ////////////////

        internal LogHelpers()
        {
            this.Reset();

            LoadHooks.AddWorldUnloadEachHook(this.OnWorldExit);
        }
        ////////////////

        internal void OnPostModsLoad()
        {
            LoadHooks.AddPostWorldUnloadEachHook(() => {
                this.PlayerIds = new Dictionary <int, string>();
            });
        }
示例#23
0
 public HookLoadingAttribute(LoadHooks hooks)
 {
     this.hooks = hooks;
 }
 private void OnClientConnect()
 {
     LoadHooks.AddWorldLoadOnceHook(() => {
         WorldDataProtocol.QuickRequest();
     });
 }
        internal void OnModLoad()
        {
            LoadHooks.AddPostModLoadHook(() => {
                var hook = new CustomTimerAction(delegate() {
                    if (Main.netMode == 1)
                    {
                        return;
                    }
                    this.ExpireCurrentWorldInSession(ResetModeMod.Instance);
                });

                TimeLimitAPI.AddCustomAction("reset", hook);

                this.Load();
                this.LoadRewards();
            });


            LoadHooks.AddPostWorldLoadEachHook(delegate {
                var mymod = ResetModeMod.Instance;

                if (mymod.Config.AutoStartSession)
                {
                    if (Main.netMode == 0 || Main.netMode == 2)
                    {
                        this.StartSession();
                    }
                }

                this.IsWorldInPlay = true;
            });


            LoadHooks.AddWorldUnloadEachHook(() => {
                this.IsWorldInPlay = false;
            });


            LoadHooks.AddPostWorldUnloadEachHook(() => {
                var mymod = ResetModeMod.Instance;

                if (mymod.Config.DebugModeInfo)
                {
                    LogHelpers.Alert("(In promise) - Unloading world...");
                }

                this.IsExiting = false;

                if (mymod.CurrentNetMode == 0 || mymod.CurrentNetMode == 2)
                {
                    if (mymod.Config.DeleteAllWorldsBetweenGames)
                    {
                        if (this.Data.AwaitingNextWorld)
                        {
                            this.ClearAllWorlds();
                        }
                    }

                    this.Save();
                }

                CustomLoadHooks.TriggerHook(ResetModeMod.WorldExitValidator, ResetModeMod.MyValidatorKey);
            });
        }