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); }
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); } }
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(); }
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); }
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(); }
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; } }
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); }
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); } }
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); }
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(); }
//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; } }
public static void OnMissingMana(Player player, Item item, int neededMana) { ItemLoader.OnMissingMana(item, player, neededMana); PlayerHooks.OnMissingMana(player, item, neededMana); }
public static void OnConsumeMana(Player player, Item item, int manaConsumed) { ItemLoader.OnConsumeMana(item, player, manaConsumed); PlayerHooks.OnConsumeMana(player, item, manaConsumed); }
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); }
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); }
public static void ModifyWeaponCrit(Player player, Item item, ref int crit) { ItemLoader.ModifyWeaponCrit(item, player, ref crit); PlayerHooks.ModifyWeaponCrit(player, item, ref crit); }
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); } }
//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(); }
public static float TotalMeleeSpeedMultiplier(Player player, Item item) { return(TotalUseTimeMultiplier(player, item) * MeleeSpeedMultiplier(player, item) * ItemLoader.MeleeSpeedMultiplier(item, player)); }
public static float TotalUseTimeMultiplier(Player player, Item item) { return(UseTimeMultiplier(player, item) * ItemLoader.UseTimeMultiplier(item, player)); }
/// <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; }
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)); }
public static bool CanShoot(Player player, Item item) { return(PlayerHooks.CanShoot(player, item) & ItemLoader.CanShoot(item, player)); }
public static void GetWeaponDamage(Player player, Item item, ref int damage) { ItemLoader.GetWeaponDamage(item, player, ref damage); PlayerHooks.GetWeaponDamage(player, item, ref damage); }
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); }
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); }
/// <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);
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); }
public static void GetManaCost(Player player, Item item, ref int mana) { ItemLoader.GetManaCost(item, player, ref mana); PlayerHooks.GetManaCost(player, item, ref mana); }