public static bool?CanPlayerHitNPCWithItem(Player player, Item item, NPC npc) { bool?result = null; bool ModifyResult(bool?nbool) { if (nbool.HasValue) { result = nbool.Value; } return(result != false); } if (!ModifyResult(PlayerHooks.CanHitNPC(player, item, npc))) { return(false); } if (!ModifyResult(ItemLoader.CanHitNPC(item, player, npc))) { return(false); } if (!ModifyResult(NPCLoader.CanBeHitByItem(npc, player, item))) { return(false); } return(result); }
internal static void Unload() { while (loadOrder.Count > 0) { GetMod(loadOrder.Pop()).UnloadContent(); } loadedMods.Clear(); ItemLoader.Unload(); EquipLoader.Unload(); ModDust.Unload(); TileLoader.Unload(); WallLoader.Unload(); ProjectileLoader.Unload(); NPCLoader.Unload(); NPCHeadLoader.Unload(); PlayerHooks.Unload(); BuffLoader.Unload(); MountLoader.Unload(); ModGore.Unload(); SoundLoader.Unload(); textures.Clear(); sounds.Clear(); mods.Clear(); ResizeArrays(true); MapLoader.UnloadModMap(); modHotKeys.Clear(); }
public void AddPlayer(string name, ModPlayer player) { player.Name = name; players[name] = player; player.mod = this; PlayerHooks.Add(player); }
private static void ResizeArrays(bool unloading = false) { ItemLoader.ResizeArrays(unloading); EquipLoader.ResizeAndFillArrays(); ModPrefix.ResizeArrays(); Main.InitializeItemAnimations(); ModDust.ResizeArrays(); TileLoader.ResizeArrays(unloading); WallLoader.ResizeArrays(unloading); ProjectileLoader.ResizeArrays(); NPCLoader.ResizeArrays(unloading); NPCHeadLoader.ResizeAndFillArrays(); ModGore.ResizeAndFillArrays(); SoundLoader.ResizeAndFillArrays(); MountLoader.ResizeArrays(); BuffLoader.ResizeArrays(); PlayerHooks.RebuildHooks(); BackgroundTextureLoader.ResizeAndFillArrays(); UgBgStyleLoader.ResizeAndFillArrays(); SurfaceBgStyleLoader.ResizeAndFillArrays(); GlobalBgStyleLoader.ResizeAndFillArrays(unloading); WaterStyleLoader.ResizeArrays(); WaterfallStyleLoader.ResizeArrays(); WorldHooks.ResizeArrays(); foreach (LocalizedText text in LanguageManager.Instance._localizedTexts.Values) { text.Override = null; } }
internal static void Unload() { ContentInstance.Clear(); ModTypeLookup.Clear(); ItemLoader.Unload(); EquipLoader.Unload(); ModPrefix.Unload(); ModDust.Unload(); TileLoader.Unload(); ModTileEntity.UnloadAll(); WallLoader.Unload(); ProjectileLoader.Unload(); NPCLoader.Unload(); NPCHeadLoader.Unload(); PlayerHooks.Unload(); BuffLoader.Unload(); MountLoader.Unload(); RarityLoader.Unload(); DamageClassLoader.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(); // 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(); }
internal static void Unload() { while (loadOrder.Count > 0) { GetMod(loadOrder.Pop()).UnloadContent(); } loadOrder.Clear(); loadedMods = new Mod[0]; 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(); mods.Clear(); 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(); modHotKeys.Clear(); RecipeHooks.Unload(); CommandManager.Unload(); TagSerializer.Reload(); ModNet.Unload(); GameContent.UI.CustomCurrencyManager.Initialize(); CleanupModReferences(); if (!Main.dedServ && Main.netMode != 1) //disable vanilla client compatiblity restrictions when reloading on a client { ModNet.AllowVanillaClients = false; } }
/// <summary> /// Note, not threadsafe /// </summary> public static PlayerDrawLayer[] GetDrawLayers(PlayerDrawSet drawInfo) { foreach (var layer in _drawOrder) { layer.ResetVisiblity(drawInfo); } PlayerHooks.HideDrawLayers(drawInfo); return(_drawOrder); }
internal static void Unload() { 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(); modHotKeys.Clear(); RecipeHooks.Unload(); CommandManager.Unload(); TagSerializer.Reload(); ModNet.Unload(); Config.ConfigManager.Unload(); CustomCurrencyManager.Initialize(); EffectsTracker.RemoveModEffects(); CleanupModReferences(); }
internal static void ResizeArrays() { var positions = Layers.ToDictionary(l => l, l => l.GetDefaultPosition()); PlayerHooks.ModifyDrawLayerOrdering(positions); // net core please!! //foreach (var (layer, pos) in positions.ToArray()) { foreach (var kv in positions.ToArray()) { var layer = kv.Key; switch (kv.Value) { case Between _: continue; case BeforeParent b: b.Parent.AddChildBefore(layer); break; case AfterParent a: a.Parent.AddChildAfter(layer); break; case Multiple m: int slot = 0; foreach (var(pos, cond) in m.Positions) { positions.Add(new PlayerDrawLayerSlot(layer, cond, slot++), pos); } break; default: throw new ArgumentException($"PlayerDrawLayer {layer} has unknown Position type {kv.Value}"); } positions.Remove(kv.Key); } var sort = new TopoSort <PlayerDrawLayer>(positions.Keys, l => new[] { ((Between)positions[l]).Layer1 }.Where(l => l != null), l => new[] { ((Between)positions[l]).Layer2 }.Where(l => l != null)); _drawOrder = sort.Sort().ToArray(); }
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(); 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(); if (!Main.dedServ && Main.netMode != 1) //disable vanilla client compatiblity restrictions when reloading on a client { ModNet.AllowVanillaClients = false; } }
//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 ModifyWeaponCrit(Player player, Item item, ref int crit) { ItemLoader.ModifyWeaponCrit(item, player, ref crit); PlayerHooks.ModifyWeaponCrit(player, item, ref crit); }
public static void GetManaCost(Player player, Item item, ref int mana) { ItemLoader.GetManaCost(item, player, ref mana); PlayerHooks.GetManaCost(player, item, ref mana); }
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 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 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); }
public static bool CanShoot(Player player, Item item) { return(PlayerHooks.CanShoot(player, item) & ItemLoader.CanShoot(item, player)); }
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 GetWeaponDamage(Player player, Item item, ref int damage) { ItemLoader.GetWeaponDamage(item, player, ref damage); PlayerHooks.GetWeaponDamage(player, item, ref damage); }
protected sealed override void Register() { ModTypeLookup <ModPlayer> .Register(this); PlayerHooks.Add(this); }
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); }