Add gas tanks throw damage (#20035)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Vyacheslav Kovalevsky
2023-12-04 09:32:17 +03:00
committed by GitHub
parent fe2672744f
commit 5b55b9ce3b
8 changed files with 36 additions and 53 deletions

View File

@@ -1,3 +1,4 @@
using System.Numerics;
using Content.Server.Atmos.Components;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
@@ -8,6 +9,7 @@ using Content.Shared.Actions;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Content.Shared.Examine;
using Content.Shared.Throwing;
using Content.Shared.Toggleable;
using Content.Shared.Verbs;
using JetBrains.Annotations;
@@ -33,6 +35,7 @@ namespace Content.Server.Atmos.EntitySystems
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
private const float TimerDelay = 0.5f;
private float _timer = 0f;
@@ -172,9 +175,9 @@ namespace Content.Server.Atmos.EntitySystems
{
_atmosphereSystem.Merge(environment, removed);
}
var impulse = removed.TotalMoles * removed.Temperature;
_physics.ApplyLinearImpulse(gasTank, _random.NextAngle().ToWorldVec() * impulse);
_physics.ApplyAngularImpulse(gasTank, _random.NextFloat(-3f, 3f));
var strength = removed.TotalMoles * MathF.Sqrt(removed.Temperature);
var dir = _random.NextAngle().ToWorldVec();
_throwing.TryThrow(gasTank, dir * strength, strength);
_audioSys.PlayPvs(gasTank.Comp.RuptureSound, gasTank);
}