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

@@ -25,8 +25,7 @@ namespace Content.Server.Nutrition.Components
public void PlaySound()
{
if(_sound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner, AudioHelpers.WithVariation(0.125f));
SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner, AudioHelpers.WithVariation(0.125f));
}
void IThrowCollide.DoHit(ThrowCollideEventArgs eventArgs)

View File

@@ -127,8 +127,7 @@ namespace Content.Server.Nutrition.Components
if (!Opened)
{
//Do the opening stuff like playing the sounds.
if(_openSounds.TryGetSound(out var openSound))
SoundSystem.Play(Filter.Pvs(args.User), openSound, args.User, AudioParams.Default);
SoundSystem.Play(Filter.Pvs(args.User), _openSounds.GetSound(), args.User, AudioParams.Default);
Opened = true;
return false;
@@ -137,7 +136,7 @@ namespace Content.Server.Nutrition.Components
if (!Owner.TryGetComponent(out ISolutionInteractionsComponent? contents) ||
contents.DrainAvailable <= 0)
{
args.User.PopupMessage(Loc.GetString("drink-component-on-use-is-empty",("owner", Owner)));
args.User.PopupMessage(Loc.GetString("drink-component-on-use-is-empty", ("owner", Owner)));
return true;
}
@@ -163,14 +162,14 @@ namespace Content.Server.Nutrition.Components
}
var color = Empty ? "gray" : "yellow";
var openedText = Loc.GetString(Empty ? "drink-component-on-examine-is-empty" : "drink-component-on-examine-is-opened");
message.AddMarkup(Loc.GetString("drink-component-on-examine-details-text",("colorName", color),("text", openedText)));
message.AddMarkup(Loc.GetString("drink-component-on-examine-details-text", ("colorName", color), ("text", openedText)));
}
private bool TryUseDrink(IEntity user, IEntity target, bool forced = false)
{
if (!Opened)
{
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-not-open",("owner", Owner)));
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-not-open", ("owner", Owner)));
return false;
}
@@ -180,7 +179,7 @@ namespace Content.Server.Nutrition.Components
{
if (!forced)
{
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-is-empty", ("entity",Owner)));
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-is-empty", ("entity", Owner)));
}
return false;
@@ -189,7 +188,7 @@ namespace Content.Server.Nutrition.Components
if (!target.TryGetComponent(out SharedBodyComponent? body) ||
!body.TryGetMechanismBehaviors<StomachBehavior>(out var stomachs))
{
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-cannot-drink",("owner", Owner)));
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-cannot-drink", ("owner", Owner)));
return false;
}
@@ -207,7 +206,7 @@ namespace Content.Server.Nutrition.Components
// All stomach are full or can't handle whatever solution we have.
if (firstStomach == null)
{
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-had-enough",("owner", Owner)));
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-had-enough", ("owner", Owner)));
if (!interactions.CanRefill)
{
@@ -219,10 +218,7 @@ namespace Content.Server.Nutrition.Components
return false;
}
if (_useSound.TryGetSound(out var useSound))
{
SoundSystem.Play(Filter.Pvs(target), useSound, target, AudioParams.Default.WithVolume(-2f));
}
SoundSystem.Play(Filter.Pvs(target), _useSound.GetSound(), target, AudioParams.Default.WithVolume(-2f));
target.PopupMessage(Loc.GetString("drink-component-try-use-drink-success-slurp"));
UpdateAppearance();
@@ -253,8 +249,7 @@ namespace Content.Server.Nutrition.Components
var solution = interactions.Drain(interactions.DrainAvailable);
solution.SpillAt(Owner, "PuddleSmear");
if(_burstSound.TryGetSound(out var burstSound))
SoundSystem.Play(Filter.Pvs(Owner), burstSound, Owner, AudioParams.Default.WithVolume(-4));
SoundSystem.Play(Filter.Pvs(Owner), _burstSound.GetSound(), Owner, AudioParams.Default.WithVolume(-4));
}
}
}

View File

@@ -50,7 +50,7 @@ namespace Content.Server.Nutrition.Components
return solution.CurrentVolume == 0
? 0
: Math.Max(1, (int)Math.Ceiling((solution.CurrentVolume / TransferAmount).Float()));
: Math.Max(1, (int) Math.Ceiling((solution.CurrentVolume / TransferAmount).Float()));
}
}
@@ -110,7 +110,7 @@ namespace Content.Server.Nutrition.Components
}
var utensils = utensilUsed != null
? new List<UtensilComponent> {utensilUsed}
? new List<UtensilComponent> { utensilUsed }
: null;
if (_utensilsNeeded != UtensilType.None)
@@ -160,10 +160,7 @@ namespace Content.Server.Nutrition.Components
firstStomach.TryTransferSolution(split);
if (UseSound.TryGetSound(out var useSound))
{
SoundSystem.Play(Filter.Pvs(trueTarget), useSound, trueTarget, AudioParams.Default.WithVolume(-1f));
}
SoundSystem.Play(Filter.Pvs(trueTarget), UseSound.GetSound(), trueTarget, AudioParams.Default.WithVolume(-1f));
trueTarget.PopupMessage(user, Loc.GetString("food-nom"));

View File

@@ -24,13 +24,16 @@ namespace Content.Server.Nutrition.Components
int IInteractUsing.Priority => 1; // take priority over eating with utensils
[DataField("slice")] [ViewVariables(VVAccess.ReadWrite)]
[DataField("slice")]
[ViewVariables(VVAccess.ReadWrite)]
private string _slice = string.Empty;
[DataField("sound")] [ViewVariables(VVAccess.ReadWrite)]
[DataField("sound")]
[ViewVariables(VVAccess.ReadWrite)]
private SoundSpecifier _sound = new SoundPathSpecifier("/Audio/Items/Culinary/chop.ogg");
[DataField("count")] [ViewVariables(VVAccess.ReadWrite)]
[DataField("count")]
[ViewVariables(VVAccess.ReadWrite)]
private ushort _totalCount = 5;
[ViewVariables(VVAccess.ReadWrite)] public ushort Count;
@@ -67,9 +70,8 @@ namespace Content.Server.Nutrition.Components
}
}
if(_sound.TryGetSound(out var sound))
SoundSystem.Play(Filter.Pvs(Owner), sound, Owner.Transform.Coordinates,
AudioParams.Default.WithVolume(-2));
SoundSystem.Play(Filter.Pvs(Owner), _sound.GetSound(), Owner.Transform.Coordinates,
AudioParams.Default.WithVolume(-2));
Count--;
if (Count < 1)

View File

@@ -71,9 +71,9 @@ namespace Content.Server.Nutrition.Components
internal void TryBreak(IEntity user)
{
if (_breakSound.TryGetSound(out var breakSound) && IoCManager.Resolve<IRobustRandom>().Prob(_breakChance))
if (IoCManager.Resolve<IRobustRandom>().Prob(_breakChance))
{
SoundSystem.Play(Filter.Pvs(user), breakSound, user, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(user), _breakSound.GetSound(), user, AudioParams.Default.WithVolume(-2f));
Owner.Delete();
}
}