コード例 #1
0
        /// <summary>
        /// Assigns a head texture to the given town NPC type.
        /// </summary>
        /// <param name="npcType">Type of the NPC.</param>
        /// <param name="texture">The texture.</param>
        /// <returns>The boss head txture slot</returns>
        /// <exception cref="MissingResourceException"></exception>
        public int AddNPCHeadTexture(int npcType, string texture)
        {
            if (!loading)
            {
                throw new Exception("AddNPCHeadTexture can only be called from Mod.Load or Mod.Autoload");
            }

            int slot = NPCHeadLoader.ReserveHeadSlot();

            NPCHeadLoader.heads[texture] = slot;

            if (!Main.dedServ)
            {
                ModContent.GetTexture(texture);
            }

            /*else if (Main.dedServ && !(ModLoader.FileExists(texture + ".png") || ModLoader.FileExists(texture + ".rawimg")))
             * {
             *      throw new MissingResourceException(texture);
             * }*/

            NPCHeadLoader.npcToHead[npcType] = slot;
            NPCHeadLoader.headToNPC[slot]    = npcType;
            return(slot);
        }
コード例 #2
0
        public void AddNPCHeadTexture(int npcType, string texture)
        {
            int slot = NPCHeadLoader.ReserveHeadSlot();

            NPCHeadLoader.heads[texture] = slot;
            ModLoader.GetTexture(texture);
            NPCHeadLoader.npcToHead[npcType] = slot;
            NPCHeadLoader.headToNPC[slot]    = npcType;
        }