Client LuaCsForBarotrauma
BarotraumaClient/ClientSource/Characters/Attack.cs
2 using Microsoft.Xna.Framework;
3 using System.Xml.Linq;
4 
5 namespace Barotrauma
6 {
7  partial class Attack
8  {
9  [Serialize("StructureBlunt", IsPropertySaveable.Yes, description: "Name of the sound effect the attack makes when it hits a structure."), Editable()]
10  public string StructureSoundType { get; private set; }
11 
15  private RoundSound sound;
16 
20  private ParticleEmitter particleEmitter;
21 
22  partial void InitProjSpecific(ContentXElement element)
23  {
24  if (element.GetAttribute("sound") != null)
25  {
26  DebugConsole.ThrowError("Error in attack ("+element+") - sounds should be defined as child elements, not as attributes.");
27  return;
28  }
29 
30  foreach (var subElement in element.Elements())
31  {
32  switch (subElement.Name.ToString().ToLowerInvariant())
33  {
34  case "particleemitter":
35  particleEmitter = new ParticleEmitter(subElement);
36  break;
37  case "sound":
38  sound = RoundSound.Load(subElement);
39  break;
40  }
41 
42  }
43  }
44 
45  partial void DamageParticles(float deltaTime, Vector2 worldPosition)
46  {
47  particleEmitter?.Emit(deltaTime, worldPosition);
48 
49  if (sound != null)
50  {
51  SoundPlayer.PlaySound(sound.Sound, worldPosition, sound.Volume, sound.Range, ignoreMuffling: sound.IgnoreMuffling, freqMult: sound.GetRandomFrequencyMultiplier());
52  }
53  }
54  }
55 }
IEnumerable< ContentXElement > Elements()
XAttribute? GetAttribute(string name)
void Emit(float deltaTime, Vector2 position, Hull? hullGuess=null, float angle=0.0f, float particleRotation=0.0f, float velocityMultiplier=1.0f, float sizeMultiplier=1.0f, float amountMultiplier=1.0f, Color? colorMultiplier=null, ParticlePrefab? overrideParticle=null, bool mirrorAngle=false, Tuple< Vector2, Vector2 >? tracerPoints=null)
static ? RoundSound Load(ContentXElement element, bool stream=false)
Definition: RoundSound.cs:61
readonly float Range
Definition: RoundSound.cs:14
float GetRandomFrequencyMultiplier()
Definition: RoundSound.cs:54
readonly float Volume
Definition: RoundSound.cs:13
readonly bool IgnoreMuffling
Definition: RoundSound.cs:17