Example #1
0
        public static SlotId PlayVanillaSound(LegacySoundStyle soundId, Vector2 position, float volume = 1f, float pitchVariance = 0f)
        {
            if (Main.dedServ)
            {
                return(SlotId.Invalid);
            }

            if (position == Vector2.Zero)
            {
                return(Main.PlayTrackedSound(soundId.WithVolume(volume).WithPitchVariance(pitchVariance), position));
            }

            return(Main.PlayTrackedSound(soundId.WithVolume(volume).WithPitchVariance(pitchVariance), position));
        }
Example #2
0
        public override void SetDefaults()
        {
            item.width     = 38;
            item.height    = 38;
            item.value     = 10000;
            item.rare      = ItemRarityID.Cyan;
            item.accessory = true;

            EndSound    = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/Custom/Novabooster/NovaboosterEnd");
            EngineSound = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/Custom/Novabooster/Novabooster");
            if (!Main.dedServ && EngineSound != null && EndSound != null)
            {
                EngineSound = EngineSound.WithVolume(0.3f);
                EndSound    = EndSound.WithVolume(0.4f);
            }
        }
Example #3
0
 public override void SafeSetDefaults()
 {
     pickPower = 50;
     radius    = 20;
     projectile.tileCollide = false; //checks to see if the projectile can go through tiles
     projectile.width       = 22;    //This defines the hitbox width
     projectile.height      = 22;    //This defines the hitbox height
     projectile.aiStyle     = 16;    //How the projectile works, 16 is the aistyle Used for: Grenades, Dynamite, Bombs, Sticky Bomb.
     projectile.friendly    = true;  //Tells the game whether it is friendly to players/friendly npcs or not
     projectile.penetrate   = -1;    //Tells the game how many enemies it can hit before being destroyed
     projectile.timeLeft    = 1000;  //The amount of time the projectile is alive for
     phaseSound             = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, "Sounds/Custom/Explosives/Phase_Bomb");
     if (!Main.dedServ)
     {
         phaseSound = phaseSound.WithVolume(0.5f);
     }
     explodeSounds = new LegacySoundStyle[3];
     for (int num = 1; num <= explodeSounds.Length; num++)
     {
         explodeSounds[num - 1] = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, explodeSoundsLoc + num);
     }
 }
Example #4
0
 public override void SafeSetDefaults()
 {
     pickPower = 70;
     radius    = 80;
     projectile.tileCollide = true;
     projectile.width       = 40;
     projectile.height      = 40;
     projectile.aiStyle     = 16;
     projectile.friendly    = true;
     projectile.penetrate   = -1;
     projectile.timeLeft    = 800;
     //projectile.scale = 1.5f;
     fuseSound = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, explodeSoundsLoc + "Wick");
     if (!Main.dedServ)
     {
         fuseSound = fuseSound.WithVolume(0.5f);
     }
     explodeSounds = new LegacySoundStyle[2];
     for (int num = 1; num <= explodeSounds.Length; num++)
     {
         explodeSounds[num - 1] = mod.GetLegacySoundSlot(Terraria.ModLoader.SoundType.Custom, explodeSoundsLoc + num);
     }
 }
Example #5
0
        /// <summary>
        /// A more flexible variant of `Main.PlaySound` to allow adjusting volume and position.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sound"></param>
        /// <param name="position"></param>
        /// <param name="volume"></param>
        public static void PlaySound(string name, LegacySoundStyle sound, Vector2 position, float volume = 1f)
        {
            if (Main.netMode == NetmodeID.Server)
            {
                return;
            }

            var sndHelp = ModContent.GetInstance <SoundLibraries>();

            if (sndHelp.Sounds.ContainsKey(name))
            {
                sound = sndHelp.Sounds[name];
            }

            try {
                sound = sound.WithVolume(volume);
                sndHelp.Sounds[name] = sound;
            } catch (Exception e) {
                throw new ModLibsException("Sound load issue.", e);
            }

            Main.PlaySound(sound, position);
        }