Inheritance: PBLoader.Mod
Ejemplo n.º 1
0
        public override void Unload()
        {
            // All code below runs only if we're not loading on a server
            if (!Main.dedServ)
            {
                // Main.music[MusicID.Dungeon] = Main.soundBank.GetCue("Music_" + MusicID.Dungeon);
                Main.tileFrame[TileID.Loom]      = 0;            // Reset the frame of the loom tile
                Main.tileSetsLoaded[TileID.Loom] = false;        // Causes the loom tile to reload its vanilla texture
                GameShaders.Misc.Remove("ExampleMod:DeathAnimation");

                Filters.Scene.Remove("ExampleMod:PuritySpirit");
                SkyManager.Instance.Remove("ExampleMod:PuritySpirit");
                Filters.Scene.Remove("ExampleMod:MonolithVoid");
                SkyManager.Instance.Remove("ExampleMod:MonolithVoid");

                GameShaders.Armor.Remove(ItemType <Items.ExampleDye>());
            }

            // Unload static references
            // You need to clear static references to assets (Texture2D, SoundEffects, Effects).
            exampleEffect = null;

            // In addition to that, if you want your mod to completely unload during unload, you need to clear static references to anything referencing your Mod class
            instance         = null;
            RandomBuffHotKey = null;
        }
Ejemplo n.º 2
0
        // Your mod instance has a Logger field, use it.
        // OPTIONAL: You can create your own logger this way, recommended is a custom logging class if you do a lot of logging
        // You need to reference the log4net library to do this, this can be found in the tModLoader repository
        // inside the references folder. You do not have to add this to build.txt as tML has it natively.
        // internal ILog Logging = LogManager.GetLogger("ExampleMod");

        public ExampleMod()
        {
            Instance = this;
            // By default, all Autoload properties are True. You only need to change this if you know what you are doing.
            //Properties = new ModProperties()
            //{
            //	Autoload = true,
            //	AutoloadGores = true,
            //	AutoloadSounds = true,
            //	AutoloadBackgrounds = true
            //};
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Awake is called when the script instance is being loaded.
        /// </summary>
        private void Awake()
        {
            Instance = this;

            Log.Init(Logger);

            Hooks.Showcase.Init();

            Pieces.Example.Init();

            Mobs.Example.Init();
        }
Ejemplo n.º 4
0
        public override void Unload()
        {
            // All code below runs only if we're not loading on a server
            if (!Main.dedServ)
            {
                Main.tileFrame[TileID.Loom]      = 0;            // Reset the frame of the loom tile
                Main.tileSetsLoaded[TileID.Loom] = false;        // Causes the loom tile to reload its vanilla texture
            }

            // Unload static references
            // You need to clear static references to assets (Texture2D, SoundEffects, Effects).
            // In addition to that, if you want your mod to completely unload during unload, you need to clear static references to anything referencing your Mod class
            Instance         = null;
            RandomBuffHotKey = null;
        }
Ejemplo n.º 5
0
        public override void Load()
        {
            instance = this;

            // Adds boss head textures for the Abomination boss
            for (int k = 1; k <= 4; k++)
            {
                AddBossHeadTexture(captiveElementHead + k);
                AddBossHeadTexture(captiveElement2Head + k);
            }

            // Registers a new hotkey
            RandomBuffHotKey = RegisterHotKey("Random Buff", "P");

            // Registers a new custom currency
            FaceCustomCurrencyID = CustomCurrencyManager.RegisterCurrency(new ExampleCustomCurrency(ItemType <Items.Face>(), 999L));

            // All code below runs only if we're not loading on a server
            if (!Main.dedServ)
            {
                // Add certain equip textures
                AddEquipTexture(null, EquipType.Legs, "ExampleRobe_Legs", "ExampleMod/Items/Armor/ExampleRobe_Legs");
                AddEquipTexture(new Items.Armor.BlockyHead(), null, EquipType.Head, "BlockyHead", "ExampleMod/Items/Armor/ExampleCostume_Head");
                AddEquipTexture(new Items.Armor.BlockyBody(), null, EquipType.Body, "BlockyBody", "ExampleMod/Items/Armor/ExampleCostume_Body", "ExampleMod/Items/Armor/ExampleCostume_Arms");
                AddEquipTexture(new Items.Armor.BlockyLegs(), null, EquipType.Legs, "BlockyLeg", "ExampleMod/Items/Armor/ExampleCostume_Legs");

                // Change the vanilla dungeon track
                // Main.music[MusicID.Dungeon] = GetMusic("Sounds/Music/DriveMusic");

                // Register a new music box
                AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/DriveMusic"), ItemType("ExampleMusicBox"), TileType("ExampleMusicBox"));

                // Change the vailla loom texture
                Main.instance.LoadTiles(TileID.Loom);                             // First load the tile texture
                Main.tileTexture[TileID.Loom] = GetTexture("Tiles/AnimatedLoom"); // Now we change it

                //What if....Replace a vanilla item texture and equip texture.
                //Main.itemTexture[ItemID.CopperHelmet] = GetTexture("Resprite/CopperHelmet_Item");
                //Item copperHelmet = new Item();
                //copperHelmet.SetDefaults(ItemID.CopperHelmet);
                //Main.armorHeadLoaded[copperHelmet.headSlot] = true;
                //Main.armorHeadTexture[copperHelmet.headSlot] = GetTexture("Resprite/CopperHelmet_Head");

                // Create new skies and screen filters
                Filters.Scene["ExampleMod:PuritySpirit"]       = new Filter(new PuritySpiritScreenShaderData("FilterMiniTower").UseColor(0.4f, 0.9f, 0.4f).UseOpacity(0.7f), EffectPriority.VeryHigh);
                SkyManager.Instance["ExampleMod:PuritySpirit"] = new PuritySpiritSky();
                Filters.Scene["ExampleMod:MonolithVoid"]       = new Filter(new ScreenShaderData("FilterMoonLord"), EffectPriority.Medium);
                SkyManager.Instance["ExampleMod:MonolithVoid"] = new VoidSky();
                // exampleFont = GetFont("Fonts/ExampleFont");
                exampleEffect = GetEffect("Effects/ExampleEffect");
                Ref <Effect> exampleEffectRef = new Ref <Effect>();
                exampleEffectRef.Value = exampleEffect;
                GameShaders.Armor.BindShader <ArmorShaderData>(ItemType <Items.ExampleDye>(), new ArmorShaderData(exampleEffectRef, "ExampleDyePass"));

                // Custom UI
                exampleUI = new ExampleUI();
                exampleUI.Activate();
                exampleUserInterface = new UserInterface();
                exampleUserInterface.SetState(exampleUI);
            }

            // Register custom mod translations, lives left is for Spirit of Purity
            ModTranslation text = CreateTranslation("LivesLeft");

            text.SetDefault("{0} has {1} lives left!");
            AddTranslation(text);
            text = CreateTranslation("LifeLeft");
            text.SetDefault("{0} has 1 life left!");
            AddTranslation(text);
            text = CreateTranslation("NPCTalk");
            text.SetDefault("<{0}> {1}");
            AddTranslation(text);

            // Volcano warning is for the random vulcano tremor
            text = CreateTranslation("VolcanoWarning");
            text.SetDefault("Did you hear something....A Volcano! Find Cover!");
            AddTranslation(text);
        }
Ejemplo n.º 6
0
        public override void Load()
        {
            instance = this;
            // Will show up in client.log under the ExampleMod name
            Logger.InfoFormat("{0} example logging", this.Name);
            // ErrorLogger.Log("blabla"); REPLACE THIS WITH ABOVE

            // Adds boss head textures for the Abomination boss
            for (int k = 1; k <= 4; k++)
            {
                AddBossHeadTexture(captiveElementHead + k);
                AddBossHeadTexture(captiveElement2Head + k);
            }

            // Registers a new hotkey
            RandomBuffHotKey = RegisterHotKey("Random Buff", "P");             // See https://docs.microsoft.com/en-us/previous-versions/windows/xna/bb197781(v%3dxnagamestudio.41) for special keys

            // Registers a new custom currency
            FaceCustomCurrencyID = CustomCurrencyManager.RegisterCurrency(new ExampleCustomCurrency(ItemType <Items.Face>(), 999L));

            // All code below runs only if we're not loading on a server
            if (!Main.dedServ)
            {
                // Add certain equip textures
                AddEquipTexture(null, EquipType.Legs, "ExampleRobe_Legs", "ExampleMod/Items/Armor/ExampleRobe_Legs");
                AddEquipTexture(new Items.Armor.BlockyHead(), null, EquipType.Head, "BlockyHead", "ExampleMod/Items/Armor/ExampleCostume_Head");
                AddEquipTexture(new Items.Armor.BlockyBody(), null, EquipType.Body, "BlockyBody", "ExampleMod/Items/Armor/ExampleCostume_Body", "ExampleMod/Items/Armor/ExampleCostume_Arms");
                AddEquipTexture(new Items.Armor.BlockyLegs(), null, EquipType.Legs, "BlockyLeg", "ExampleMod/Items/Armor/ExampleCostume_Legs");

                // Change the vanilla dungeon track
                // Main.music[MusicID.Dungeon] = GetMusic("Sounds/Music/DriveMusic");

                // Register a new music box
                AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/DriveMusic"), ItemType("ExampleMusicBox"), TileType("ExampleMusicBox"));

                // Change the vanilla loom texture
                Main.instance.LoadTiles(TileID.Loom);                             // First load the tile texture
                Main.tileTexture[TileID.Loom] = GetTexture("Tiles/AnimatedLoom"); // Now we change it

                //What if....Replace a vanilla item texture and equip texture.
                //Main.itemTexture[ItemID.CopperHelmet] = GetTexture("Resprite/CopperHelmet_Item");
                //Item copperHelmet = new Item();
                //copperHelmet.SetDefaults(ItemID.CopperHelmet);
                //Main.armorHeadLoaded[copperHelmet.headSlot] = true;
                //Main.armorHeadTexture[copperHelmet.headSlot] = GetTexture("Resprite/CopperHelmet_Head");

                // Create new skies and screen filters
                Filters.Scene["ExampleMod:PuritySpirit"]       = new Filter(new PuritySpiritScreenShaderData("FilterMiniTower").UseColor(0.4f, 0.9f, 0.4f).UseOpacity(0.7f), EffectPriority.VeryHigh);
                SkyManager.Instance["ExampleMod:PuritySpirit"] = new PuritySpiritSky();
                Filters.Scene["ExampleMod:MonolithVoid"]       = new Filter(new ScreenShaderData("FilterMoonLord"), EffectPriority.Medium);
                SkyManager.Instance["ExampleMod:MonolithVoid"] = new VoidSky();
                // exampleFont = GetFont("Fonts/ExampleFont");
                GameShaders.Armor.BindShader(ItemType <Items.ExampleDye>(), new ArmorShaderData(new Ref <Effect>(GetEffect("Effects/ExampleEffect")), "ExampleDyePass"));
                GameShaders.Misc["ExampleMod:DeathAnimation"] = new MiscShaderData(new Ref <Effect>(GetEffect("Effects/ExampleEffectDeath")), "DeathAnimation").UseImage("Images/Misc/Perlin");

                // Custom UI
                exampleUI = new ExampleUI();
                exampleUI.Activate();
                exampleUserInterface = new UserInterface();
                exampleUserInterface.SetState(exampleUI);

                // UserInterface can only show 1 UIState at a time. If you want different "pages" for a UI, switch between UIStates on the same UserInterface instance.
                // We want both the Coin counter and the Example Person UI to be independent and coexist simultaneously, so we have them each in their own UserInterface.
                examplePersonUserInterface = new UserInterface();
                // We will call .SetState later in ExamplePerson.OnChatButtonClicked
            }

            // Register custom mod translations, lives left is for Spirit of Purity
            ModTranslation text = CreateTranslation("LivesLeft");

            text.SetDefault("{0} has {1} lives left!");
            AddTranslation(text);
            text = CreateTranslation("LifeLeft");
            text.SetDefault("{0} has 1 life left!");
            AddTranslation(text);
            text = CreateTranslation("NPCTalk");
            text.SetDefault("<{0}> {1}");
            AddTranslation(text);

            // Volcano warning is for the random volcano tremor
            text = CreateTranslation("VolcanoWarning");
            text.SetDefault("Did you hear something....A Volcano! Find Cover!");
            AddTranslation(text);
        }