diff --git a/Content.Client/GameObjects/EntitySystems/ChemicalReactionSystem.cs b/Content.Client/GameObjects/EntitySystems/ChemicalReactionSystem.cs new file mode 100644 index 0000000000..f58526eec0 --- /dev/null +++ b/Content.Client/GameObjects/EntitySystems/ChemicalReactionSystem.cs @@ -0,0 +1,9 @@ +using Content.Shared.GameObjects.EntitySystems; + +namespace Content.Client.GameObjects.EntitySystems.NewFolder +{ + public class ChemicalReactionSystem : SharedChemicalReactionSystem + { + + } +} diff --git a/Content.Server/GameObjects/EntitySystems/ChemicalReactionSystem.cs b/Content.Server/GameObjects/EntitySystems/ChemicalReactionSystem.cs new file mode 100644 index 0000000000..2fde1f8f59 --- /dev/null +++ b/Content.Server/GameObjects/EntitySystems/ChemicalReactionSystem.cs @@ -0,0 +1,17 @@ +using Content.Shared.Chemistry; +using Content.Shared.GameObjects.EntitySystems; +using Robust.Server.GameObjects.EntitySystems; +using Robust.Shared.Interfaces.GameObjects; + +namespace Content.Server.GameObjects.EntitySystems.NewFolder +{ + public class ChemicalReactionSystem : SharedChemicalReactionSystem + { + protected override void OnReaction(ReactionPrototype reaction, IEntity owner, ReagentUnit unitReactions) + { + base.OnReaction(reaction, owner, unitReactions); + + Get().PlayAtCoords(reaction.Sound, owner.Transform.Coordinates); + } + } +} diff --git a/Content.Shared/Chemistry/ReactionPrototype.cs b/Content.Shared/Chemistry/ReactionPrototype.cs index 1c0911da95..02799b9229 100644 --- a/Content.Shared/Chemistry/ReactionPrototype.cs +++ b/Content.Shared/Chemistry/ReactionPrototype.cs @@ -36,6 +36,8 @@ namespace Content.Shared.Chemistry /// public IReadOnlyList Effects => _effects; + public string Sound { get; private set; } + [Dependency] private readonly IModuleManager _moduleManager = default!; public void LoadFrom(YamlMappingNode mapping) @@ -46,6 +48,7 @@ namespace Content.Shared.Chemistry serializer.DataField(ref _name, "name", string.Empty); serializer.DataField(ref _reactants, "reactants", new Dictionary()); serializer.DataField(ref _products, "products", new Dictionary()); + serializer.DataField(this, x => x.Sound, "sound", "/Audio/Effects/Chemistry/bubbles.ogg"); if (_moduleManager.IsServerModule) { diff --git a/Content.Shared/GameObjects/Components/Chemistry/SharedSolutionContainerComponent.cs b/Content.Shared/GameObjects/Components/Chemistry/SharedSolutionContainerComponent.cs index 584ab4cd19..e453f4aeda 100644 --- a/Content.Shared/GameObjects/Components/Chemistry/SharedSolutionContainerComponent.cs +++ b/Content.Shared/GameObjects/Components/Chemistry/SharedSolutionContainerComponent.cs @@ -179,7 +179,7 @@ namespace Content.Shared.GameObjects.Components.Chemistry if (!CanReact) return; - EntitySystem.Get() + EntitySystem.Get() .FullyReactSolution(Solution, Owner, MaxVolume); } diff --git a/Content.Shared/GameObjects/EntitySystems/ChemicalReactionSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedChemicalReactionSystem.cs similarity index 93% rename from Content.Shared/GameObjects/EntitySystems/ChemicalReactionSystem.cs rename to Content.Shared/GameObjects/EntitySystems/SharedChemicalReactionSystem.cs index 811c97756d..8c2a3a6e7e 100644 --- a/Content.Shared/GameObjects/EntitySystems/ChemicalReactionSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SharedChemicalReactionSystem.cs @@ -8,8 +8,7 @@ using System.Collections.Generic; namespace Content.Shared.GameObjects.EntitySystems { - //TODO: Reimplement sounds for reactions - public class ChemicalReactionSystem : EntitySystem + public abstract class SharedChemicalReactionSystem : EntitySystem { private IEnumerable _reactions; @@ -56,7 +55,7 @@ namespace Content.Shared.GameObjects.EntitySystems /// Perform a reaction on a solution. This assumes all reaction criteria are met. /// Removes the reactants from the solution, then returns a solution with all products. /// - private static Solution PerformReaction(Solution solution, IEntity owner, ReactionPrototype reaction, ReagentUnit unitReactions) + private Solution PerformReaction(Solution solution, IEntity owner, ReactionPrototype reaction, ReagentUnit unitReactions) { //Remove reactants foreach (var reactant in reaction.Reactants) @@ -76,12 +75,17 @@ namespace Content.Shared.GameObjects.EntitySystems } // Trigger reaction effects + OnReaction(reaction, owner, unitReactions); + + return products; + } + + protected virtual void OnReaction(ReactionPrototype reaction, IEntity owner, ReagentUnit unitReactions) + { foreach (var effect in reaction.Effects) { effect.React(owner, unitReactions.Double()); } - - return products; } ///