Ejemplo n.º 1
0
        internal static void SendNetIDs(int toClient)
        {
            var p = new ModPacket(MessageID.ModPacket);

            p.Write(netMods.Length);
            foreach (var mod in netMods)
            {
                p.Write(mod.Name);
            }

            ItemLoader.WriteNetGlobalOrder(p);
            WorldHooks.WriteNetWorldOrder(p);

            p.Send(toClient);
        }
Ejemplo n.º 2
0
        public void AddItem(string name, ModItem item, string texture)
        {
            int id = ItemLoader.ReserveItemID();

            item.item.name = name;
            item.item.ResetStats(id);
            items[name]          = item;
            ItemLoader.items[id] = item;
            item.texture         = texture;
            item.mod             = this;
            if (item.IsQuestFish())
            {
                ItemLoader.questFish.Add(id);
            }
        }
Ejemplo n.º 3
0
 private static void ResizeArrays(bool unloading = false)
 {
     ItemLoader.ResizeArrays();
     EquipLoader.ResizeAndFillArrays();
     Main.InitializeItemAnimations();
     ModDust.ResizeArrays();
     TileLoader.ResizeArrays(unloading);
     WallLoader.ResizeArrays(unloading);
     ProjectileLoader.ResizeArrays();
     NPCLoader.ResizeArrays();
     NPCHeadLoader.ResizeAndFillArrays();
     ModGore.ResizeAndFillArrays();
     SoundLoader.ResizeAndFillArrays();
     MountLoader.ResizeArrays();
     BuffLoader.ResizeArrays();
 }
Ejemplo n.º 4
0
        internal static void SendNetIDs(int toClient)
        {
            var p = new ModPacket(MessageID.ModPacket);

            p.Write(netMods.Length);
            foreach (Mod mod in netMods)
            {
                p.Write(mod.Name);
            }

            ItemLoader.WriteNetGlobalOrder(p);
            SystemHooks.WriteNetSystemOrder(p);
            p.Write(Player.MaxBuffs);

            p.Send(toClient);
        }
Ejemplo n.º 5
0
        internal static void Unload()
        {
            ContentInstance.Clear();
            ItemLoader.Unload();
            EquipLoader.Unload();
            ModPrefix.Unload();
            ModDust.Unload();
            TileLoader.Unload();
            ModTileEntity.Unload();
            WallLoader.Unload();
            ProjectileLoader.Unload();
            NPCLoader.Unload();
            NPCHeadLoader.Unload();
            PlayerHooks.Unload();
            BuffLoader.Unload();
            MountLoader.Unload();
            ModGore.Unload();
            SoundLoader.Unload();
            DisposeMusic();
            BackgroundTextureLoader.Unload();
            UgBgStyleLoader.Unload();
            SurfaceBgStyleLoader.Unload();
            GlobalBgStyleLoader.Unload();
            WaterStyleLoader.Unload();
            WaterfallStyleLoader.Unload();
            WorldHooks.Unload();
            ResizeArrays(true);
            for (int k = 0; k < Recipe.maxRecipes; k++)
            {
                Main.recipe[k] = new Recipe();
            }
            Recipe.numRecipes = 0;
            RecipeGroupHelper.ResetRecipeGroups();
            Recipe.SetupRecipes();
            MapLoader.UnloadModMap();
            ItemSorting.SetupWhiteLists();
            HotKeyLoader.Unload();
            RecipeHooks.Unload();
            CommandManager.Unload();
            TagSerializer.Reload();
            ModNet.Unload();
            Config.ConfigManager.Unload();
            CustomCurrencyManager.Initialize();
            EffectsTracker.RemoveModEffects();

            CleanupModReferences();
        }
Ejemplo n.º 6
0
        internal static void Unload()
        {
            while (loadOrder.Count > 0)
            {
                GetMod(loadOrder.Pop()).UnloadContent();
            }

            loadOrder.Clear();
            loadedMods = new Mod[0];

            ItemLoader.Unload();
            EquipLoader.Unload();
            ModDust.Unload();
            TileLoader.Unload();
            ModTileEntity.Unload();
            WallLoader.Unload();
            ProjectileLoader.Unload();
            NPCLoader.Unload();
            NPCHeadLoader.Unload();
            PlayerHooks.Unload();
            BuffLoader.Unload();
            MountLoader.Unload();
            ModGore.Unload();
            SoundLoader.Unload();
            BackgroundTextureLoader.Unload();
            UgBgStyleLoader.Unload();
            SurfaceBgStyleLoader.Unload();
            GlobalBgStyleLoader.Unload();
            WaterStyleLoader.Unload();
            WaterfallStyleLoader.Unload();
            mods.Clear();
            ResizeArrays(true);
            MapLoader.UnloadModMap();
            ItemSorting.SetupWhiteLists();
            modHotKeys.Clear();
            WorldHooks.Unload();
            RecipeHooks.Unload();
            CommandManager.Unload();
            TagSerializer.Reload();
            GameContent.UI.CustomCurrencyManager.Initialize();

            if (!Main.dedServ && Main.netMode != 1)             //disable vanilla client compatiblity restrictions when reloading on a client
            {
                ModNet.AllowVanillaClients = false;
            }
        }
Ejemplo n.º 7
0
 internal static void Unload()
 {
     foreach (Mod mod in mods.Values)
     {
         mod.Unload();
     }
     loadedMods.Clear();
     ItemLoader.Unload();
     EquipLoader.Unload();
     TileLoader.Unload();
     WallLoader.Unload();
     ProjectileLoader.Unload();
     NPCLoader.Unload();
     ModGore.Unload();
     NPCHeadLoader.Unload();
     ModSound.Unload();
     textures.Clear();
     sounds.Clear();
     mods.Clear();
     ResizeArrays(true);
 }
Ejemplo n.º 8
0
        public void AddItem(string name, ModItem item, string texture)
        {
            Type type = item.GetType();

            if (type.GetMethod("UpdateAccessory", new Type[] { typeof(Player) }) != null)
            {
                throw new Exception("Item " + name + " uses an old UpdateAccessory hook");
            }
            int id = ItemLoader.ReserveItemID();

            item.item.name = name;
            item.item.ResetStats(id);
            items[name]          = item;
            ItemLoader.items[id] = item;
            item.texture         = texture;
            item.mod             = this;
            if (item.IsQuestFish())
            {
                ItemLoader.questFish.Add(id);
            }
        }
Ejemplo n.º 9
0
        private static void ReadNetIDs(BinaryReader reader)
        {
            var mods = ModLoader.Mods;
            var list = new List <Mod>();
            var n    = reader.ReadInt32();

            for (short i = 0; i < n; i++)
            {
                var name = reader.ReadString();
                var mod  = mods.SingleOrDefault(m => m.Name == name);
                list.Add(mod);
                if (mod != null)                 //nosync mod that doesn't exist on the client
                {
                    mod.netID = i;
                }
            }
            netMods = list.ToArray();

            ItemLoader.ReadNetGlobalOrder(reader);
            WorldHooks.ReadNetWorldOrder(reader);
        }
Ejemplo n.º 10
0
 private static void ResizeArrays(bool unloading = false)
 {
     ItemLoader.ResizeArrays();
     EquipLoader.ResizeAndFillArrays();
     Main.InitializeItemAnimations();
     ModDust.ResizeArrays();
     TileLoader.ResizeArrays(unloading);
     WallLoader.ResizeArrays(unloading);
     ProjectileLoader.ResizeArrays();
     NPCLoader.ResizeArrays();
     NPCHeadLoader.ResizeAndFillArrays();
     ModGore.ResizeAndFillArrays();
     SoundLoader.ResizeAndFillArrays();
     MountLoader.ResizeArrays();
     BuffLoader.ResizeArrays();
     BackgroundTextureLoader.ResizeAndFillArrays();
     UgBgStyleLoader.ResizeAndFillArrays();
     SurfaceBgStyleLoader.ResizeAndFillArrays();
     GlobalBgStyleLoader.ResizeAndFillArrays(unloading);
     WaterStyleLoader.ResizeArrays();
     WaterfallStyleLoader.ResizeArrays();
 }
Ejemplo n.º 11
0
        //TODO: Unhardcode ALL of this.
        private static void ResizeArrays(bool unloading = false)
        {
            DamageClassLoader.ResizeArrays();
            ItemLoader.ResizeArrays(unloading);
            EquipLoader.ResizeAndFillArrays();
            PrefixLoader.ResizeArrays();
            DustLoader.ResizeArrays();
            TileLoader.ResizeArrays(unloading);
            WallLoader.ResizeArrays(unloading);
            TileIO.ResizeArrays();
            ProjectileLoader.ResizeArrays();
            NPCLoader.ResizeArrays(unloading);
            NPCHeadLoader.ResizeAndFillArrays();
            MountLoader.ResizeArrays();
            BuffLoader.ResizeArrays();
            PlayerHooks.RebuildHooks();
            PlayerDrawLayerLoader.ResizeArrays();
            SystemHooks.ResizeArrays();

            if (!Main.dedServ)
            {
                SoundLoader.ResizeAndFillArrays();
                BackgroundTextureLoader.ResizeAndFillArrays();
                UgBgStyleLoader.ResizeAndFillArrays();
                SurfaceBgStyleLoader.ResizeAndFillArrays();
                GlobalBgStyleLoader.ResizeAndFillArrays(unloading);
                GoreLoader.ResizeAndFillArrays();
                WaterStyleLoader.ResizeArrays();
                WaterfallStyleLoader.ResizeArrays();
            }

            foreach (LocalizedText text in LanguageManager.Instance._localizedTexts.Values)
            {
                text.Override = null;
            }
        }
Ejemplo n.º 12
0
 public static void OnMissingMana(Player player, Item item, int neededMana)
 {
     ItemLoader.OnMissingMana(item, player, neededMana);
     PlayerHooks.OnMissingMana(player, item, neededMana);
 }
Ejemplo n.º 13
0
 public static void OnConsumeMana(Player player, Item item, int manaConsumed)
 {
     ItemLoader.OnConsumeMana(item, player, manaConsumed);
     PlayerHooks.OnConsumeMana(player, item, manaConsumed);
 }
Ejemplo n.º 14
0
 public static void ModifyManaCost(Player player, Item item, ref float reduce, ref float mult)
 {
     ItemLoader.ModifyManaCost(item, player, ref reduce, ref mult);
     PlayerHooks.ModifyManaCost(player, item, ref reduce, ref mult);
 }
Ejemplo n.º 15
0
 public static void ModifyWeaponKnockback(Player player, Item item, ref StatModifier knockback, ref float flat)
 {
     ItemLoader.ModifyWeaponKnockback(item, player, ref knockback, ref flat);
     PlayerHooks.ModifyWeaponKnockback(player, item, ref knockback, ref flat);
 }
Ejemplo n.º 16
0
 public static void ModifyWeaponCrit(Player player, Item item, ref int crit)
 {
     ItemLoader.ModifyWeaponCrit(item, player, ref crit);
     PlayerHooks.ModifyWeaponCrit(player, item, ref crit);
 }
Ejemplo n.º 17
0
 internal void SetupContent()
 {
     foreach (ModItem item in items.Values)
     {
         ItemLoader.SetDefaults(item.item, false);
         item.AutoStaticDefaults();
         item.SetStaticDefaults();
     }
     foreach (ModPrefix prefix in prefixes.Values)
     {
         prefix.AutoDefaults();
         prefix.SetDefaults();
     }
     foreach (ModDust dust in dusts.Values)
     {
         dust.SetDefaults();
     }
     foreach (ModTile tile in tiles.Values)
     {
         Main.tileTexture[tile.Type] = ModContent.GetTexture(tile.texture);
         TileLoader.SetDefaults(tile);
         if (TileID.Sets.HasOutlines[tile.Type])
         {
             Main.highlightMaskTexture[tile.Type] = ModContent.GetTexture(tile.HighlightTexture);
         }
         if (!string.IsNullOrEmpty(tile.chest))
         {
             TileID.Sets.BasicChest[tile.Type] = true;
         }
     }
     foreach (GlobalTile globalTile in globalTiles.Values)
     {
         globalTile.SetDefaults();
     }
     foreach (ModWall wall in walls.Values)
     {
         Main.wallTexture[wall.Type] = ModContent.GetTexture(wall.texture);
         wall.SetDefaults();
     }
     foreach (GlobalWall globalWall in globalWalls.Values)
     {
         globalWall.SetDefaults();
     }
     foreach (ModProjectile projectile in projectiles.Values)
     {
         ProjectileLoader.SetDefaults(projectile.projectile, false);
         projectile.AutoStaticDefaults();
         projectile.SetStaticDefaults();
     }
     foreach (ModNPC npc in npcs.Values)
     {
         NPCLoader.SetDefaults(npc.npc, false);
         npc.AutoStaticDefaults();
         npc.SetStaticDefaults();
     }
     foreach (ModMountData modMountData in mountDatas.Values)
     {
         var mountData = modMountData.mountData;
         mountData.modMountData = modMountData;
         MountLoader.SetupMount(mountData);
         Mount.mounts[modMountData.Type] = mountData;
     }
     foreach (ModBuff buff in buffs.Values)
     {
         Main.buffTexture[buff.Type] = ModContent.GetTexture(buff.texture);
         buff.SetDefaults();
     }
     foreach (ModWaterStyle waterStyle in waterStyles.Values)
     {
         LiquidRenderer.Instance._liquidTextures[waterStyle.Type] = ModContent.GetTexture(waterStyle.texture);
         Main.liquidTexture[waterStyle.Type] = ModContent.GetTexture(waterStyle.blockTexture);
     }
     foreach (ModWaterfallStyle waterfallStyle in waterfallStyles.Values)
     {
         Main.instance.waterfallManager.waterfallTexture[waterfallStyle.Type]
             = ModContent.GetTexture(waterfallStyle.texture);
     }
 }
Ejemplo n.º 18
0
        //TODO: Unhardcode ALL of this.
        internal static void Unload()
        {
            ContentInstance.Clear();
            ModTypeLookup.Clear();
            ItemLoader.Unload();
            EquipLoader.Unload();
            PrefixLoader.Unload();
            DustLoader.Unload();
            TileLoader.Unload();
            TileEntity.manager.Reset();
            WallLoader.Unload();
            ProjectileLoader.Unload();
            NPCLoader.Unload();
            NPCHeadLoader.Unload();
            BossBarLoader.Unload();
            PlayerHooks.Unload();
            BuffLoader.Unload();
            MountLoader.Unload();
            RarityLoader.Unload();
            DamageClassLoader.Unload();
            InfoDisplayLoader.Unload();
            GoreLoader.Unload();
            SoundLoader.Unload();
            DisposeMusic();
            BackgroundTextureLoader.Unload();
            UgBgStyleLoader.Unload();
            SurfaceBgStyleLoader.Unload();
            GlobalBgStyleLoader.Unload();
            WaterStyleLoader.Unload();
            WaterfallStyleLoader.Unload();
            PlayerDrawLayerLoader.Unload();
            SystemHooks.Unload();
            ResizeArrays(true);
            for (int k = 0; k < Recipe.maxRecipes; k++)
            {
                Main.recipe[k] = new Recipe();
            }
            Recipe.numRecipes = 0;
            RecipeGroupHelper.ResetRecipeGroups();
            Recipe.SetupRecipes();
            MapLoader.UnloadModMap();
            ItemSorting.SetupWhiteLists();
            HotKeyLoader.Unload();
            RecipeLoader.Unload();
            CommandLoader.Unload();
            TagSerializer.Reload();
            ModNet.Unload();
            Config.ConfigManager.Unload();
            CustomCurrencyManager.Initialize();
            EffectsTracker.RemoveModEffects();

            // ItemID.Search = IdDictionary.Create<ItemID, short>();
            // NPCID.Search = IdDictionary.Create<NPCID, short>();
            // ProjectileID.Search = IdDictionary.Create<ProjectileID, short>();
            // TileID.Search = IdDictionary.Create<TileID, ushort>();
            // WallID.Search = IdDictionary.Create<WallID, ushort>();
            // BuffID.Search = IdDictionary.Create<BuffID, int>();

            ContentSamples.Initialize();

            CleanupModReferences();
        }
Ejemplo n.º 19
0
 public static float TotalMeleeSpeedMultiplier(Player player, Item item)
 {
     return(TotalUseTimeMultiplier(player, item) * MeleeSpeedMultiplier(player, item)
            * ItemLoader.MeleeSpeedMultiplier(item, player));
 }
Ejemplo n.º 20
0
 public static float TotalUseTimeMultiplier(Player player, Item item)
 {
     return(UseTimeMultiplier(player, item) * ItemLoader.UseTimeMultiplier(item, player));
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Allows you to tie a music ID, and item ID, and a tile ID together to form a music box. When music with the given ID is playing, equipped music boxes have a chance to change their ID to the given item type. When an item with the given item type is equipped, it will play the music that has musicSlot as its ID. When a tile with the given type and Y-frame is nearby, if its X-frame is >= 36, it will play the music that has musicSlot as its ID.
        /// </summary>
        /// <param name="musicSlot">The music slot.</param>
        /// <param name="itemType">Type of the item.</param>
        /// <param name="tileType">Type of the tile.</param>
        /// <param name="tileFrameY">The tile frame y.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Cannot assign music box to vanilla music ID " + musicSlot
        /// or
        /// Music ID " + musicSlot + " does not exist
        /// or
        /// Cannot assign music box to vanilla item ID " + itemType
        /// or
        /// Item ID " + itemType + " does not exist
        /// or
        /// Cannot assign music box to vanilla tile ID " + tileType
        /// or
        /// Tile ID " + tileType + " does not exist
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// Music ID " + musicSlot + " has already been assigned a music box
        /// or
        /// Item ID " + itemType + " has already been assigned a music
        /// or
        /// or
        /// Y-frame must be divisible by 36
        /// </exception>
        public void AddMusicBox(int musicSlot, int itemType, int tileType, int tileFrameY = 0)
        {
            if (!loading)
            {
                throw new Exception("AddMusicBox can only be called from Mod.Load or Mod.Autoload");
            }

            if (Main.audioSystem == null)
            {
                return;
            }

            if (musicSlot < Main.maxMusic)
            {
                throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla music ID " + musicSlot);
            }
            if (musicSlot >= SoundLoader.SoundCount(SoundType.Music))
            {
                throw new ArgumentOutOfRangeException("Music ID " + musicSlot + " does not exist");
            }
            if (itemType < ItemID.Count)
            {
                throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla item ID " + itemType);
            }
            if (ItemLoader.GetItem(itemType) == null)
            {
                throw new ArgumentOutOfRangeException("Item ID " + itemType + " does not exist");
            }
            if (tileType < TileID.Count)
            {
                throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla tile ID " + tileType);
            }
            if (TileLoader.GetTile(tileType) == null)
            {
                throw new ArgumentOutOfRangeException("Tile ID " + tileType + " does not exist");
            }
            if (SoundLoader.musicToItem.ContainsKey(musicSlot))
            {
                throw new ArgumentException("Music ID " + musicSlot + " has already been assigned a music box");
            }
            if (SoundLoader.itemToMusic.ContainsKey(itemType))
            {
                throw new ArgumentException("Item ID " + itemType + " has already been assigned a music");
            }
            if (!SoundLoader.tileToMusic.ContainsKey(tileType))
            {
                SoundLoader.tileToMusic[tileType] = new Dictionary <int, int>();
            }
            if (SoundLoader.tileToMusic[tileType].ContainsKey(tileFrameY))
            {
                string message = "Y-frame " + tileFrameY + " of tile type " + tileType + " has already been assigned a music";
                throw new ArgumentException(message);
            }
            if (tileFrameY % 36 != 0)
            {
                throw new ArgumentException("Y-frame must be divisible by 36");
            }
            SoundLoader.musicToItem[musicSlot]            = itemType;
            SoundLoader.itemToMusic[itemType]             = musicSlot;
            SoundLoader.tileToMusic[tileType][tileFrameY] = musicSlot;
        }
Ejemplo n.º 22
0
 public static bool Shoot(Player player, Item item, ProjectileSource_Item_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
 {
     PlayerHooks.Shoot(player, item, source, position, velocity, type, damage, knockback);
     return(ItemLoader.Shoot(item, player, source, position, velocity, type, damage, knockback));
 }
Ejemplo n.º 23
0
 public static bool CanShoot(Player player, Item item)
 {
     return(PlayerHooks.CanShoot(player, item) & ItemLoader.CanShoot(item, player));
 }
Ejemplo n.º 24
0
 public static void GetWeaponDamage(Player player, Item item, ref int damage)
 {
     ItemLoader.GetWeaponDamage(item, player, ref damage);
     PlayerHooks.GetWeaponDamage(player, item, ref damage);
 }
Ejemplo n.º 25
0
 public static void ModifyWeaponDamage(Player player, Item item, ref float add, ref float mult)
 {
     ItemLoader.ModifyWeaponDamage(item, player, ref add, ref mult);
     PlayerHooks.ModifyWeaponDamage(player, item, ref add, ref mult);
 }
Ejemplo n.º 26
0
 public static void ModifyShootStats(Player player, Item item, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback)
 {
     ItemLoader.ModifyShootStats(item, player, ref position, ref velocity, ref type, ref damage, ref knockback);
     PlayerHooks.ModifyShootStats(player, item, ref position, ref velocity, ref type, ref damage, ref knockback);
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Gets the ModItem instance corresponding to the specified type. Returns null if no modded item has the given type.
 /// </summary>
 public static ModItem GetModItem(int type) => ItemLoader.GetItem(type);
Ejemplo n.º 28
0
 public static void ModifyWeaponDamage(Player player, Item item, ref StatModifier damage, ref float flat)
 {
     ItemLoader.ModifyWeaponDamage(item, player, ref damage, ref flat);
     PlayerHooks.ModifyWeaponDamage(player, item, ref damage, ref flat);
 }
Ejemplo n.º 29
0
 public static void GetManaCost(Player player, Item item, ref int mana)
 {
     ItemLoader.GetManaCost(item, player, ref mana);
     PlayerHooks.GetManaCost(player, item, ref mana);
 }