removed TryGetSound + made some SoundSpecifier datafields required

This commit is contained in:
Galactic Chimp
2021-07-31 19:52:33 +02:00
parent 8ff703c338
commit 57016d14b4
114 changed files with 519 additions and 785 deletions

View File

@@ -78,8 +78,7 @@ namespace Content.Server.Actions.Actions
if (random.Prob(_failProb))
{
if(PunchMissSound.TryGetSound(out var punchMissSound))
SoundSystem.Play(Filter.Pvs(args.Performer), punchMissSound, args.Performer, AudioHelpers.WithVariation(0.025f));
SoundSystem.Play(Filter.Pvs(args.Performer), PunchMissSound.GetSound(), args.Performer, AudioHelpers.WithVariation(0.025f));
args.Performer.PopupMessageOtherClients(Loc.GetString("disarm-action-popup-message-other-clients",
("performerName", args.Performer.Name),
@@ -90,9 +89,9 @@ namespace Content.Server.Actions.Actions
return;
}
system.SendAnimation("disarm", angle, args.Performer, args.Performer, new []{ args.Target });
system.SendAnimation("disarm", angle, args.Performer, args.Performer, new[] { args.Target });
var eventArgs = new DisarmedActEventArgs() {Target = args.Target, Source = args.Performer, PushProbability = _pushProb};
var eventArgs = new DisarmedActEventArgs() { Target = args.Target, Source = args.Performer, PushProbability = _pushProb };
// Sort by priority.
Array.Sort(disarmedActs, (a, b) => a.Priority.CompareTo(b.Priority));
@@ -103,8 +102,7 @@ namespace Content.Server.Actions.Actions
return;
}
if(DisarmSuccessSound.TryGetSound(out var disarmSuccessSound))
SoundSystem.Play(Filter.Pvs(args.Performer), disarmSuccessSound, args.Performer.Transform.Coordinates, AudioHelpers.WithVariation(0.025f));
SoundSystem.Play(Filter.Pvs(args.Performer), DisarmSuccessSound.GetSound(), args.Performer.Transform.Coordinates, AudioHelpers.WithVariation(0.025f));
}
}
}

View File

@@ -26,9 +26,9 @@ namespace Content.Server.Actions.Actions
[Dependency] private readonly IRobustRandom _random = default!;
[DataField("male")] private SoundSpecifier _male = default!;
[DataField("female")] private SoundSpecifier _female = default!;
[DataField("wilhelm")] private SoundSpecifier _wilhelm = default!;
[DataField("male", required: true)] private SoundSpecifier _male = default!;
[DataField("female", required: true)] private SoundSpecifier _female = default!;
[DataField("wilhelm", required: true)] private SoundSpecifier _wilhelm = default!;
/// seconds
[DataField("cooldown")] private float _cooldown = 10;
@@ -44,21 +44,19 @@ namespace Content.Server.Actions.Actions
if (!args.Performer.TryGetComponent<HumanoidAppearanceComponent>(out var humanoid)) return;
if (!args.Performer.TryGetComponent<SharedActionsComponent>(out var actions)) return;
if (_random.Prob(.01f) && _wilhelm.TryGetSound(out var wilhelm))
if (_random.Prob(.01f))
{
SoundSystem.Play(Filter.Pvs(args.Performer), wilhelm, args.Performer, AudioParams.Default.WithVolume(Volume));
SoundSystem.Play(Filter.Pvs(args.Performer), _wilhelm.GetSound(), args.Performer, AudioParams.Default.WithVolume(Volume));
}
else
{
switch (humanoid.Sex)
{
case Sex.Male:
if (_male.TryGetSound(out var male))
SoundSystem.Play(Filter.Pvs(args.Performer), male, args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume));
SoundSystem.Play(Filter.Pvs(args.Performer), _male.GetSound(), args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume));
break;
case Sex.Female:
if (_female.TryGetSound(out var female))
SoundSystem.Play(Filter.Pvs(args.Performer), female, args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume));
SoundSystem.Play(Filter.Pvs(args.Performer), _female.GetSound(), args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume));
break;
default:
throw new ArgumentOutOfRangeException();

View File

@@ -28,7 +28,7 @@ namespace Content.Server.Actions.Spells
[ViewVariables] [DataField("cooldown")] public float CoolDown { get; set; } = 1f;
[ViewVariables] [DataField("spellItem")] public string ItemProto { get; set; } = default!;
[ViewVariables] [DataField("castSound")] public SoundSpecifier CastSound { get; set; } = default!;
[ViewVariables] [DataField("castSound", required: true)] public SoundSpecifier CastSound { get; set; } = default!;
//Rubber-band snapping items into player's hands, originally was a workaround, later found it works quite well with stuns
//Not sure if needs fixing
@@ -69,8 +69,7 @@ namespace Content.Server.Actions.Spells
handsComponent.PutInHandOrDrop(itemComponent);
if (CastSound.TryGetSound(out var castSound))
SoundSystem.Play(Filter.Pvs(caster), castSound, caster);
SoundSystem.Play(Filter.Pvs(caster), CastSound.GetSound(), caster);
}
}
}