Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
 public void AddPlayer(string name, ModPlayer player)
 {
     player.Name   = name;
     players[name] = player;
     player.mod    = this;
     PlayerHooks.Add(player);
 }
Exemplo n.º 4
0
 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;
     }
 }
Exemplo n.º 5
0
        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();
        }
Exemplo 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();
            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;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Note, not threadsafe
        /// </summary>
        public static PlayerDrawLayer[] GetDrawLayers(PlayerDrawSet drawInfo)
        {
            foreach (var layer in _drawOrder)
            {
                layer.ResetVisiblity(drawInfo);
            }

            PlayerHooks.HideDrawLayers(drawInfo);

            return(_drawOrder);
        }
Exemplo n.º 8
0
        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();
        }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
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();
            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;
            }
        }
Exemplo 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;
            }
        }
Exemplo n.º 12
0
 public static void ModifyWeaponCrit(Player player, Item item, ref int crit)
 {
     ItemLoader.ModifyWeaponCrit(item, player, ref crit);
     PlayerHooks.ModifyWeaponCrit(player, item, ref crit);
 }
Exemplo n.º 13
0
 public static void GetManaCost(Player player, Item item, ref int mana)
 {
     ItemLoader.GetManaCost(item, player, ref mana);
     PlayerHooks.GetManaCost(player, item, ref mana);
 }
Exemplo n.º 14
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);
 }
Exemplo n.º 15
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));
 }
Exemplo n.º 16
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);
 }
Exemplo n.º 17
0
 public static bool CanShoot(Player player, Item item)
 {
     return(PlayerHooks.CanShoot(player, item) & ItemLoader.CanShoot(item, player));
 }
Exemplo n.º 18
0
 public static void OnMissingMana(Player player, Item item, int neededMana)
 {
     ItemLoader.OnMissingMana(item, player, neededMana);
     PlayerHooks.OnMissingMana(player, item, neededMana);
 }
Exemplo n.º 19
0
 public static void OnConsumeMana(Player player, Item item, int manaConsumed)
 {
     ItemLoader.OnConsumeMana(item, player, manaConsumed);
     PlayerHooks.OnConsumeMana(player, item, manaConsumed);
 }
Exemplo n.º 20
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);
 }
Exemplo n.º 21
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);
 }
Exemplo n.º 22
0
 public static void GetWeaponDamage(Player player, Item item, ref int damage)
 {
     ItemLoader.GetWeaponDamage(item, player, ref damage);
     PlayerHooks.GetWeaponDamage(player, item, ref damage);
 }
Exemplo n.º 23
0
        protected sealed override void Register()
        {
            ModTypeLookup <ModPlayer> .Register(this);

            PlayerHooks.Add(this);
        }
Exemplo n.º 24
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);
 }