CP14AreaEffectBehavior
This commit is contained in:
@@ -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<SharedSolutionContainerSystem>();
|
||||
|
||||
if (!solutionContainerSystem.TryGetSolution(owner, Solution, out _, out var solution))
|
||||
return;
|
||||
|
||||
var smokeSystem = system.EntityManager.System<SmokeSystem>();
|
||||
var audio = system.EntityManager.System<SharedAudioSystem>();
|
||||
|
||||
var coordinates = system.EntityManager.GetComponent<TransformComponent>(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));
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using Content.Shared._CP14.MagicSpell;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._CP14.Chemistry.SmokeBomb;
|
||||
|
||||
/// <summary>
|
||||
/// A smoke bomb that creates a cloud of smoke when it lands
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
@@ -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<CP14SmokeBombComponent, LandEvent>(OnLand, before: [typeof(DestructibleSystem)]);
|
||||
}
|
||||
|
||||
private void OnLand(Entity<CP14SmokeBombComponent> ent, ref LandEvent args)
|
||||
{
|
||||
if (!TryComp<SolutionContainerManagerComponent>(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);
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user