コード例 #1
0
ファイル: CombinedHooks.cs プロジェクト: vSLG/tModLoader
        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);
        }
コード例 #2
0
ファイル: ModLoader.cs プロジェクト: saeym/tModLoader
 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();
 }
コード例 #3
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;
     }
 }
コード例 #4
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();
        }
コード例 #5
0
ファイル: ModNPC.cs プロジェクト: tStandalone/tStandalone
        public override void SetupContent()
        {
            NPCLoader.SetDefaults(npc, false);
            AutoStaticDefaults();
            SetStaticDefaults();

            NPCID.Search.Add(FullName, Type);
        }
コード例 #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;
            }
        }
コード例 #7
0
        protected sealed override void Register()
        {
            NPCLoader.VerifyGlobalNPC(this);

            ModTypeLookup <GlobalNPC> .Register(this);

            index = NPCLoader.globalNPCs.Count;

            NPCLoader.globalNPCs.Add(this);
        }
コード例 #8
0
        public void AddNPC(string name, ModNPC npc, string texture)
        {
            int id = NPCLoader.ReserveNPCID();

            npc.npc.name       = name;
            npc.npc.type       = id;
            npcs[name]         = npc;
            NPCLoader.npcs[id] = npc;
            npc.texture        = texture;
            npc.mod            = this;
        }
コード例 #9
0
 private static void ResizeArrays(bool unloading = false)
 {
     ItemLoader.ResizeArrays();
     EquipLoader.ResizeAndFillArrays();
     Main.InitializeItemAnimations();
     TileLoader.ResizeArrays(unloading);
     WallLoader.ResizeArrays(unloading);
     ProjectileLoader.ResizeArrays();
     NPCLoader.ResizeArrays();
     ModGore.ResizeArrays();
     NPCHeadLoader.ResizeAndFillArrays();
     ModSound.ResizeArrays();
 }
コード例 #10
0
ファイル: ModContent.cs プロジェクト: PhilBill44/tModLoader
        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();
        }
コード例 #11
0
ファイル: ModLoader.cs プロジェクト: nilfisk/tModLoader
        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;
            }
        }
コード例 #12
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);
 }
コード例 #13
0
ファイル: ModLoader.cs プロジェクト: nilfisk/tModLoader
 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();
 }
コード例 #14
0
        public static bool DrawHealthBar(NPC npc, ref float scale)
        {
            Vector2 position = new Vector2(npc.position.X + npc.width / 2, npc.position.Y + npc.gfxOffY);

            if (Main.HealthBarDrawSettings == 1)
            {
                position.Y += npc.height + 10f + Main.NPCAddHeight(npc.whoAmI);
            }
            else if (Main.HealthBarDrawSettings == 2)
            {
                position.Y -= 24f + Main.NPCAddHeight(npc.whoAmI) / 2f;
            }
            foreach (GlobalNPC g in HookDrawHealthBar.arr)
            {
                bool?result = g.Instance(npc).DrawHealthBar(npc, Main.HealthBarDrawSettings, ref scale, ref position);
                if (result.HasValue)
                {
                    if (result.Value)
                    {
                        DrawHealthBar(npc, position, scale);
                    }
                    return(false);
                }
            }
            if (NPCLoader.IsModNPC(npc))
            {
                bool?result = npc.modNPC.DrawHealthBar(Main.HealthBarDrawSettings, ref scale, ref position);
                if (result.HasValue)
                {
                    if (result.Value)
                    {
                        DrawHealthBar(npc, position, scale);
                    }
                    return(false);
                }
            }
            return(true);
        }
コード例 #15
0
ファイル: ModNPC.cs プロジェクト: tStandalone/tStandalone
        protected sealed override void Register()
        {
            ModTypeLookup <ModNPC> .Register(this);

            npc.type    = NPCLoader.ReserveNPCID();
            DisplayName = Mod.GetOrCreateTranslation($"Mods.{Mod.Name}.NPCName.{Name}");

            NPCLoader.npcs.Add(this);

            Type type         = GetType();
            var  autoloadHead = type.GetAttribute <AutoloadHead>();

            if (autoloadHead != null)
            {
                Mod.AddNPCHeadTexture(npc.type, HeadTexture);
            }
            var autoloadBossHead = type.GetAttribute <AutoloadBossHead>();

            if (autoloadBossHead != null)
            {
                Mod.AddBossHeadTexture(BossHeadTexture, npc.type);
            }
        }
コード例 #16
0
ファイル: ModContent.cs プロジェクト: vSLG/tModLoader
        //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;
            }
        }
コード例 #17
0
ファイル: ModInternals.cs プロジェクト: re4prr/tModLoader
 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);
     }
 }
コード例 #18
0
ファイル: ModContent.cs プロジェクト: yuguan36/tModLoader
 /// <summary>
 /// Gets the ModNPC instance corresponding to the specified type.
 /// </summary>
 /// <param name="type">The type of the npc</param>
 /// <returns>The ModNPC instance in the npcs array, null if not found.</returns>
 public static ModNPC GetModNPC(int type) => NPCLoader.GetNPC(type);