示例#1
0
 internal static void ResizeAndFillArrays()
 {
     customSounds         = new SoundEffect[nextSound[SoundType.Custom]];
     customSoundInstances = new SoundEffectInstance[nextSound[SoundType.Custom]];
     Array.Resize(ref Main.soundItem, nextSound[SoundType.Item]);
     Array.Resize(ref Main.soundInstanceItem, nextSound[SoundType.Item]);
     Array.Resize(ref Main.soundNPCHit, nextSound[SoundType.NPCHit]);
     Array.Resize(ref Main.soundInstanceNPCHit, nextSound[SoundType.NPCHit]);
     Array.Resize(ref Main.soundNPCKilled, nextSound[SoundType.NPCKilled]);
     Array.Resize(ref Main.soundInstanceNPCKilled, nextSound[SoundType.NPCKilled]);
     Array.Resize(ref Main.music, nextSound[SoundType.Music]);
     Array.Resize(ref Main.musicFade, nextSound[SoundType.Music]);
     foreach (SoundType type in Enum.GetValues(typeof(SoundType)))
     {
         foreach (string sound in sounds[type].Keys)
         {
             int slot = GetSoundSlot(type, sound);
             if (type != SoundType.Music)
             {
                 GetSoundArray(type)[slot]         = ModLoader.GetSound(sound);
                 GetSoundInstanceArray(type)[slot] = GetSoundArray(type)[slot]?.CreateInstance() ?? null;
             }
             else
             {
                 if (Main.music[slot] == null)
                 {
                     Main.music[slot] = new MusicWrapper();
                 }
                 Main.music[slot].ModMusic = ModLoader.GetSound(sound)?.CreateInstance() ?? null;
             }
         }
     }
 }
示例#2
0
        public void AddSound(SoundType type, string soundPath, ModSound modSound = null)
        {
            int id = SoundLoader.ReserveSoundID(type);

            SoundLoader.sounds[type][soundPath] = id;
            if (modSound != null)
            {
                SoundLoader.modSounds[type][id] = modSound;
                modSound.sound = ModLoader.GetSound(soundPath);
            }
        }
示例#3
0
        internal void SetupContent()
        {
            foreach (ModItem item in items.Values)
            {
                Main.itemTexture[item.item.type] = ModLoader.GetTexture(item.texture);
                Main.itemName[item.item.type]    = item.item.name;
                EquipLoader.SetSlot(item.item);
                item.SetDefaults();
                DrawAnimation animation = item.GetAnimation();
                if (animation != null)
                {
                    Main.RegisterItemAnimation(item.item.type, animation);
                    ItemLoader.animations.Add(item.item.type);
                }
            }
            foreach (ModTile tile in tiles.Values)
            {
                Main.tileTexture[tile.Type] = ModLoader.GetTexture(tile.texture);
                TileLoader.SetDefaults(tile);
            }
            foreach (GlobalTile globalTile in globalTiles.Values)
            {
                globalTile.SetDefaults();
            }
            foreach (ModWall wall in walls.Values)
            {
                Main.wallTexture[wall.Type] = ModLoader.GetTexture(wall.texture);
                wall.SetDefaults();
            }
            foreach (GlobalWall globalWall in globalWalls.Values)
            {
                globalWall.SetDefaults();
            }
            foreach (ModProjectile projectile in projectiles.Values)
            {
                Main.projectileTexture[projectile.projectile.type] = ModLoader.GetTexture(projectile.texture);
                Main.projFrames[projectile.projectile.type]        = 1;
                projectile.SetDefaults();
                if (projectile.projectile.hostile)
                {
                    Main.projHostile[projectile.projectile.type] = true;
                }
                if (projectile.projectile.aiStyle == 7)
                {
                    Main.projHook[projectile.projectile.type] = true;
                }
            }
            foreach (ModNPC npc in npcs.Values)
            {
                Main.npcTexture[npc.npc.type] = ModLoader.GetTexture(npc.texture);
                Main.npcName[npc.npc.type]    = npc.npc.name;
                npc.SetDefaults();
                if (npc.npc.lifeMax > 32767 || npc.npc.boss)
                {
                    Main.npcLifeBytes[npc.npc.type] = 4;
                }
                else if (npc.npc.lifeMax > 127)
                {
                    Main.npcLifeBytes[npc.npc.type] = 2;
                }
                else
                {
                    Main.npcLifeBytes[npc.npc.type] = 1;
                }
            }
            foreach (ModGore gore in gores.Values)
            {
                Main.goreTexture[gore.Type] = ModLoader.GetTexture(gore.texture);
            }


            foreach (ModSound sound in sounds.Values)
            {
                Main.soundItem[sound.Type]         = ModLoader.GetSound(sound.audioFilename);
                Main.soundInstanceItem[sound.Type] = Main.soundItem[sound.Type].CreateInstance();
            }
            foreach (ModMount mount in mounts.Values)
            {
                mount.SetDefaults();
            }
        }
示例#4
0
 public SoundEffect GetSound(string name)
 {
     return(ModLoader.GetSound(FileName(name)));
 }