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

@@ -160,8 +160,7 @@ namespace Content.Server.Kitchen.Components
// TODO: Need to be able to leave them on the spike to do DoT, see ss13.
victim.Delete();
if (SpikeSound.TryGetSound(out var spikeSound))
SoundSystem.Play(Filter.Pvs(Owner), spikeSound, Owner);
SoundSystem.Play(Filter.Pvs(Owner), SpikeSound.GetSound(), Owner);
}
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)

View File

@@ -107,10 +107,10 @@ namespace Content.Server.Kitchen.Components
switch (message.Message)
{
case MicrowaveStartCookMessage msg :
case MicrowaveStartCookMessage msg:
Wzhzhzh();
break;
case MicrowaveEjectMessage msg :
case MicrowaveEjectMessage msg:
if (_hasContents)
{
VaporizeReagents();
@@ -271,7 +271,7 @@ namespace Content.Server.Kitchen.Components
}
Owner.PopupMessage(eventArgs.User, Loc.GetString("microwave-component-interact-using-transfer-success",
("amount",removedSolution.TotalVolume)));
("amount", removedSolution.TotalVolume)));
return true;
}
@@ -300,14 +300,14 @@ namespace Content.Server.Kitchen.Components
_busy = true;
// Convert storage into Dictionary of ingredients
var solidsDict = new Dictionary<string, int>();
foreach(var item in _storage.ContainedEntities)
foreach (var item in _storage.ContainedEntities)
{
if (item.Prototype == null)
{
continue;
}
if(solidsDict.ContainsKey(item.Prototype.ID))
if (solidsDict.ContainsKey(item.Prototype.ID))
{
solidsDict[item.Prototype.ID]++;
}
@@ -318,9 +318,9 @@ namespace Content.Server.Kitchen.Components
}
var failState = MicrowaveSuccessState.RecipeFail;
foreach(var id in solidsDict.Keys)
foreach (var id in solidsDict.Keys)
{
if(_recipeManager.SolidAppears(id))
if (_recipeManager.SolidAppears(id))
{
continue;
}
@@ -337,43 +337,41 @@ namespace Content.Server.Kitchen.Components
}
SetAppearance(MicrowaveVisualState.Cooking);
if(_startCookingSound.TryGetSound(out var startCookingSound))
SoundSystem.Play(Filter.Pvs(Owner), startCookingSound, Owner, AudioParams.Default);
Owner.SpawnTimer((int)(_currentCookTimerTime * _cookTimeMultiplier), (Action)(() =>
{
if (_lostPower)
{
return;
}
SoundSystem.Play(Filter.Pvs(Owner), _startCookingSound.GetSound(), Owner, AudioParams.Default);
Owner.SpawnTimer((int) (_currentCookTimerTime * _cookTimeMultiplier), (Action) (() =>
{
if (_lostPower)
{
return;
}
if(failState == MicrowaveSuccessState.UnwantedForeignObject)
{
VaporizeReagents();
EjectSolids();
}
else
{
if (recipeToCook != null)
{
SubtractContents(recipeToCook);
Owner.EntityManager.SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates);
}
else
{
VaporizeReagents();
VaporizeSolids();
Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates);
}
}
if (failState == MicrowaveSuccessState.UnwantedForeignObject)
{
VaporizeReagents();
EjectSolids();
}
else
{
if (recipeToCook != null)
{
SubtractContents(recipeToCook);
Owner.EntityManager.SpawnEntity(recipeToCook.Result, Owner.Transform.Coordinates);
}
else
{
VaporizeReagents();
VaporizeSolids();
Owner.EntityManager.SpawnEntity(_badRecipeName, Owner.Transform.Coordinates);
}
}
if(_cookingCompleteSound.TryGetSound(out var cookingCompleteSound))
SoundSystem.Play(Filter.Pvs(Owner), cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f));
SoundSystem.Play(Filter.Pvs(Owner), _cookingCompleteSound.GetSound(), Owner, AudioParams.Default.WithVolume(-1f));
SetAppearance(MicrowaveVisualState.Idle);
_busy = false;
SetAppearance(MicrowaveVisualState.Idle);
_busy = false;
_uiDirty = true;
}));
_uiDirty = true;
}));
_lostPower = false;
_uiDirty = true;
}
@@ -396,7 +394,7 @@ namespace Content.Server.Kitchen.Components
private void VaporizeSolids()
{
for(var i = _storage.ContainedEntities.Count-1; i>=0; i--)
for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--)
{
var item = _storage.ContainedEntities.ElementAt(i);
_storage.Remove(item);
@@ -407,7 +405,7 @@ namespace Content.Server.Kitchen.Components
private void EjectSolids()
{
for(var i = _storage.ContainedEntities.Count-1; i>=0; i--)
for (var i = _storage.ContainedEntities.Count - 1; i >= 0; i--)
{
_storage.Remove(_storage.ContainedEntities.ElementAt(i));
}
@@ -429,7 +427,7 @@ namespace Content.Server.Kitchen.Components
return;
}
foreach(var recipeReagent in recipe.IngredientsReagents)
foreach (var recipeReagent in recipe.IngredientsReagents)
{
solution?.TryRemoveReagent(recipeReagent.Key, ReagentUnit.New(recipeReagent.Value));
}
@@ -457,7 +455,7 @@ namespace Content.Server.Kitchen.Components
}
private MicrowaveSuccessState CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary<string,int> solids)
private MicrowaveSuccessState CanSatisfyRecipe(FoodRecipePrototype recipe, Dictionary<string, int> solids)
{
if (_currentCookTimerTime != (uint) recipe.CookTime)
{
@@ -500,8 +498,7 @@ namespace Content.Server.Kitchen.Components
private void ClickSound()
{
if(_clickSound.TryGetSound(out var clickSound))
SoundSystem.Play(Filter.Pvs(Owner), clickSound, Owner,AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
SuicideKind ISuicideAct.Suicide(IEntity victim, IChatManager chat)
@@ -537,7 +534,7 @@ namespace Content.Server.Kitchen.Components
var othersMessage = headCount > 1
? Loc.GetString("microwave-component-suicide-multi-head-others-message", ("victim", victim))
: Loc.GetString("microwave-component-suicide-others-message",("victim", victim));
: Loc.GetString("microwave-component-suicide-others-message", ("victim", victim));
victim.PopupMessageOtherClients(othersMessage);

View File

@@ -39,8 +39,8 @@ namespace Content.Server.Kitchen.Components
//YAML serialization vars
[ViewVariables(VVAccess.ReadWrite)] [DataField("chamberCapacity")] public int StorageCap = 16;
[ViewVariables(VVAccess.ReadWrite)] [DataField("workTime")] public int WorkTime = 3500; //3.5 seconds, completely arbitrary for now.
[DataField("clickSound")] private SoundSpecifier _clickSound = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
[DataField("grindSound")] private SoundSpecifier _grindSound = new SoundPathSpecifier("/Audio/Machines/blender.ogg");
[DataField("juiceSound")] private SoundSpecifier _juiceSound = new SoundPathSpecifier("/Audio/Machines/juicer.ogg");
[DataField("clickSound")] public SoundSpecifier ClickSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/machine_switch.ogg");
[DataField("grindSound")] public SoundSpecifier GrindSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/blender.ogg");
[DataField("juiceSound")] public SoundSpecifier JuiceSound { get; set; } = new SoundPathSpecifier("/Audio/Machines/juicer.ogg");
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.Chemistry.Components;
@@ -270,7 +270,7 @@ namespace Content.Server.Kitchen.EntitySystems
switch (program)
{
case SharedReagentGrinderComponent.GrinderProgram.Grind:
SoundSystem.Play(Filter.Pvs(component.Owner), "/Audio/Machines/blender.ogg", component.Owner, AudioParams.Default);
SoundSystem.Play(Filter.Pvs(component.Owner), component.GrindSound.GetSound(), component.Owner, AudioParams.Default);
//Get each item inside the chamber and get the reagents it contains. Transfer those reagents to the beaker, given we have one in.
component.Owner.SpawnTimer(component.WorkTime, (Action) (() =>
{
@@ -291,7 +291,7 @@ namespace Content.Server.Kitchen.EntitySystems
break;
case SharedReagentGrinderComponent.GrinderProgram.Juice:
SoundSystem.Play(Filter.Pvs(component.Owner), "/Audio/Machines/juicer.ogg", component.Owner, AudioParams.Default);
SoundSystem.Play(Filter.Pvs(component.Owner), component.JuiceSound.GetSound(), component.Owner, AudioParams.Default);
component.Owner.SpawnTimer(component.WorkTime, (Action) (() =>
{
foreach (var item in component.Chamber.ContainedEntities.ToList())
@@ -311,7 +311,7 @@ namespace Content.Server.Kitchen.EntitySystems
private void ClickSound(ReagentGrinderComponent component)
{
SoundSystem.Play(Filter.Pvs(component.Owner), "/Audio/Machines/machine_switch.ogg", component.Owner, AudioParams.Default.WithVolume(-2f));
SoundSystem.Play(Filter.Pvs(component.Owner), component.ClickSound.GetSound(), component.Owner, AudioParams.Default.WithVolume(-2f));
}
}
}