From 719ee50c965d34550837968456c3d0afd64d2dc0 Mon Sep 17 00:00:00 2001 From: Ed <96445749+TheShuEd@users.noreply.github.com> Date: Mon, 3 Mar 2025 16:07:19 +0300 Subject: [PATCH] CP14AreaEffectBehavior --- .../SmokeBomb/CP14AreaEffectBehavior.cs | 46 +++++++++++++++++++ .../SmokeBomb/CP14SmokeBombComponent.cs | 24 ---------- .../SmokeBomb/CP14SmokeBombSystem.cs | 41 ----------------- .../Objects/Specific/Alchemy/vial_bomb.yml | 25 +++++++++- 4 files changed, 69 insertions(+), 67 deletions(-) create mode 100644 Content.Server/_CP14/Chemistry/SmokeBomb/CP14AreaEffectBehavior.cs delete mode 100644 Content.Server/_CP14/Chemistry/SmokeBomb/CP14SmokeBombComponent.cs delete mode 100644 Content.Server/_CP14/Chemistry/SmokeBomb/CP14SmokeBombSystem.cs diff --git a/Content.Server/_CP14/Chemistry/SmokeBomb/CP14AreaEffectBehavior.cs b/Content.Server/_CP14/Chemistry/SmokeBomb/CP14AreaEffectBehavior.cs new file mode 100644 index 0000000000..fa0263cf6f --- /dev/null +++ b/Content.Server/_CP14/Chemistry/SmokeBomb/CP14AreaEffectBehavior.cs @@ -0,0 +1,46 @@ +using Content.Server._CP14.ModularCraft; +using Content.Server.Destructible; +using Content.Server.Destructible.Thresholds.Behaviors; +using Content.Server.Fluids.EntitySystems; +using Content.Shared.Audio; +using Content.Shared.Chemistry.Components.SolutionManager; +using Content.Shared.Chemistry.EntitySystems; +using Robust.Shared.Audio; +using Robust.Shared.Audio.Systems; +using Robust.Shared.Prototypes; + +namespace Content.Server._CP14.Chemistry.SmokeBomb; + +[Serializable] +[DataDefinition] +public sealed partial class CP14AreaEffectBehavior : IThresholdBehavior +{ + [DataField] + public string? Solution; + + [DataField] + public EntProtoId SmokeProto = "CP14Mist"; + + [DataField] + public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Effects/smoke.ogg"); + + [DataField] + public float Duration = 10; + + public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null) + { + var solutionContainerSystem = system.EntityManager.System(); + + if (!solutionContainerSystem.TryGetSolution(owner, Solution, out _, out var solution)) + return; + + var smokeSystem = system.EntityManager.System(); + var audio = system.EntityManager.System(); + + var coordinates = system.EntityManager.GetComponent(owner).Coordinates; + var ent = system.EntityManager.SpawnAtPosition(SmokeProto, coordinates); + + smokeSystem.StartSmoke(ent, solution, Duration, (int) solution.Volume); + audio.PlayPvs(Sound, coordinates, AudioHelpers.WithVariation(0.125f)); + } +} diff --git a/Content.Server/_CP14/Chemistry/SmokeBomb/CP14SmokeBombComponent.cs b/Content.Server/_CP14/Chemistry/SmokeBomb/CP14SmokeBombComponent.cs deleted file mode 100644 index 07922d38a1..0000000000 --- a/Content.Server/_CP14/Chemistry/SmokeBomb/CP14SmokeBombComponent.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Content.Shared._CP14.MagicSpell; -using Robust.Shared.Audio; -using Robust.Shared.Prototypes; - -namespace Content.Server._CP14.Chemistry.SmokeBomb; - -/// -/// A smoke bomb that creates a cloud of smoke when it lands -/// -[RegisterComponent, Access(typeof(CP14SharedMagicSystem))] -public sealed partial class CP14SmokeBombComponent : Component -{ - [DataField] - public string Solution = "bomb"; - - [DataField] - public EntProtoId SmokeProto = "CP14Mist"; - - [DataField] - public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Effects/smoke.ogg"); - - [DataField] - public float Duration = 10; -} diff --git a/Content.Server/_CP14/Chemistry/SmokeBomb/CP14SmokeBombSystem.cs b/Content.Server/_CP14/Chemistry/SmokeBomb/CP14SmokeBombSystem.cs deleted file mode 100644 index cbab9055b0..0000000000 --- a/Content.Server/_CP14/Chemistry/SmokeBomb/CP14SmokeBombSystem.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Content.Server.Destructible; -using Content.Server.Fluids.EntitySystems; -using Content.Shared.Chemistry.Components.SolutionManager; -using Content.Shared.Chemistry.EntitySystems; -using Content.Shared.Throwing; -using Robust.Shared.Audio.Systems; - -namespace Content.Server._CP14.Chemistry.SmokeBomb; - -public partial class CP14SmokeBombSystem : EntitySystem -{ - [Dependency] private readonly SmokeSystem _smoke = default!; - [Dependency] private readonly SharedSolutionContainerSystem _solution = default!; - [Dependency] private readonly SharedAudioSystem _audio = default!; - - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnLand, before: [typeof(DestructibleSystem)]); - } - - private void OnLand(Entity ent, ref LandEvent args) - { - if (!TryComp(ent, out var solutionManager)) - return; - - if (!_solution.TryGetSolution((ent, solutionManager), ent.Comp.Solution, out var solution)) - return; - - var position = Transform(ent).Coordinates; - var spreadAmount = (int) solution.Value.Comp.Solution.Volume; - - if (spreadAmount <= 0) - return; - - var smokeEnt = SpawnAtPosition(ent.Comp.SmokeProto, Transform(ent).Coordinates); - _smoke.StartSmoke(smokeEnt, solution.Value.Comp.Solution, ent.Comp.Duration, spreadAmount); - _audio.PlayPvs(ent.Comp.Sound, position); - } -} diff --git a/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/vial_bomb.yml b/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/vial_bomb.yml index 4816593da4..7be3887f48 100644 --- a/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/vial_bomb.yml +++ b/Resources/Prototypes/_CP14/Entities/Objects/Specific/Alchemy/vial_bomb.yml @@ -5,8 +5,29 @@ name: alchemical bomb description: A vial of liquid that explodes with an alchemical reagent cloud when thrown. components: - - type: CP14SmokeBomb - solution: vial + - type: Spillable + solution: none #Disable spillable + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 5 + behaviors: + - !type:PlaySoundBehavior + sound: + collection: GlassBreak + params: + volume: -4 + - !type:CP14AreaEffectBehavior + solution: vial + - !type:SpawnEntitiesBehavior + spawn: + CP14GlassShard: + min: 1 + max: 1 + transferForensics: true + - !type:DoActsBehavior + acts: [ "Destruction" ] - type: Sprite noRot: false layers: