Skip to content

Commit

Permalink
Добавлены дымовые гранаты,(снова)
Browse files Browse the repository at this point in the history
  • Loading branch information
1Stepka1 committed Oct 15, 2023
1 parent 72759d1 commit 38e85f4
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Content.Shared.Chemistry.Components;
using Robust.Shared.Audio;

namespace Content.Server.Fluids.EntitySystems;

[RegisterComponent]
[Access(typeof(SmokeSystem))]
public partial class SmokeOnTriggerComponent : Component
{
[DataField("spreadAmount"), ViewVariables(VVAccess.ReadWrite)]
public int SpreadAmount = 20;

[DataField("time"), ViewVariables(VVAccess.ReadWrite)]
public float Time = 30f;
/// <summary>
/// Код взят из https://github.com/space-wizards/space-station-14/pull/16942
/// </summary>
[DataField("sound")]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Effects/smoke.ogg");
}
15 changes: 15 additions & 0 deletions Content.Server/Fluids/EntitySystems/SmokeSystem.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using System.Linq;
using Content.Server.Chemistry.Components;
using Robust.Shared.Audio;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Chemistry.ReactionEffects;
using Content.Server.Explosion.EntitySystems;
using Content.Server.Spreader;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.FixedPoint;
using Content.Shared.Smoking;
using Robust.Server.GameObjects;
using Content.Server.Explosion.EntitySystems;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand All @@ -30,6 +33,7 @@ public sealed class SmokeSystem : EntitySystem
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SolutionContainerSystem _solutionSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly AudioSystem _audioSystem = default!;

/// <inheritdoc/>
public override void Initialize()
Expand All @@ -38,6 +42,7 @@ public override void Initialize()
SubscribeLocalEvent<SmokeComponent, EntityUnpausedEvent>(OnSmokeUnpaused);
SubscribeLocalEvent<SmokeComponent, ReactionAttemptEvent>(OnReactionAttempt);
SubscribeLocalEvent<SmokeComponent, SpreadNeighborsEvent>(OnSmokeSpread);
SubscribeLocalEvent<SmokeOnTriggerComponent, TriggerEvent>(HandleSmokeTrigger);
}

private void OnSmokeSpread(EntityUid uid, SmokeComponent component, ref SpreadNeighborsEvent args)
Expand Down Expand Up @@ -220,6 +225,16 @@ public void Start(EntityUid uid, SmokeComponent component, Solution solution, fl
timer.Lifetime = duration;
}

private void HandleSmokeTrigger(EntityUid uid, SmokeOnTriggerComponent comp, TriggerEvent args)
{
var xform = Transform(uid);
var smokeEnt = Spawn("Smoke", xform.Coordinates);
var smoke = EnsureComp<SmokeComponent>(smokeEnt);
smoke.SpreadAmount = comp.SpreadAmount;
_audioSystem.PlayPvs(comp.Sound, xform.Coordinates, AudioParams.Default.WithVariation(0.125f));
args.Handled = true;
}

/// <summary>
/// Adds the specified solution to the relevant smoke solution.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ent-ADTSmokeGrenade = Дымовая граната
.desc = Вам определенно не стоит пытаться разобрать её самостоятельно.
.suffix = { "" }
ent-ADTSSmokeGrenade = Дымовая граната синдиката
.desc = Вам определенно не стоит пытаться разобрать её самостоятельно. Вы чувствуете страх держа её в руках
.suffix = { "" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
- type: entity
name: Smoke Grenade
description:
parent: GrenadeBase
id: ADTSmokeGrenade
components:
- type: Sprite
sprite: ADT/Objects/Weapons/Grenades/smokegrenades.rsi
- type: SmokeOnTrigger
spreadAmount: 70
time: 40
sound: /Audio/Effects/smoke.ogg
- type: DeleteOnTrigger
- type: Appearance
- type: OnUseTimerTrigger
delay: 2.5
beepSound:
path: "/Audio/Effects/beep1.ogg"
params:
volume: 5
initialBeepDelay: 0
beepInterval: 2

- type: entity
name: Syndicate Smoke Grenade
description:
parent: GrenadeBase
id: ADTSSmokeGrenade
components:
- type: Sprite
sprite: ADT/Objects/Weapons/Grenades/ssmokegreandes.rsi
- type: SmokeOnTrigger
spreadAmount: 120
time: 60
sound: /Audio/Effects/smoke.ogg
- type: DeleteOnTrigger
- type: Appearance
- type: OnUseTimerTrigger
delay: 2.5
beepSound:
path: "/Audio/Effects/beep1.ogg"
params:
volume: 5
initialBeepDelay: 0
beepInterval: 2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Created by https://github.com/VigersRay",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "primed"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Created by https://github.com/VigersRay",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "primed"
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 38e85f4

Please sign in to comment.