Add gas tanks throw damage (#20035)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
fe2672744f
commit
5b55b9ce3b
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Numerics;
|
||||||
using Content.Server.Atmos.Components;
|
using Content.Server.Atmos.Components;
|
||||||
using Content.Server.Body.Components;
|
using Content.Server.Body.Components;
|
||||||
using Content.Server.Body.Systems;
|
using Content.Server.Body.Systems;
|
||||||
@@ -8,6 +9,7 @@ using Content.Shared.Actions;
|
|||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.Atmos.Components;
|
using Content.Shared.Atmos.Components;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Throwing;
|
||||||
using Content.Shared.Toggleable;
|
using Content.Shared.Toggleable;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@@ -33,6 +35,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
|
[Dependency] private readonly ThrowingSystem _throwing = default!;
|
||||||
|
|
||||||
private const float TimerDelay = 0.5f;
|
private const float TimerDelay = 0.5f;
|
||||||
private float _timer = 0f;
|
private float _timer = 0f;
|
||||||
@@ -172,9 +175,9 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
{
|
{
|
||||||
_atmosphereSystem.Merge(environment, removed);
|
_atmosphereSystem.Merge(environment, removed);
|
||||||
}
|
}
|
||||||
var impulse = removed.TotalMoles * removed.Temperature;
|
var strength = removed.TotalMoles * MathF.Sqrt(removed.Temperature);
|
||||||
_physics.ApplyLinearImpulse(gasTank, _random.NextAngle().ToWorldVec() * impulse);
|
var dir = _random.NextAngle().ToWorldVec();
|
||||||
_physics.ApplyAngularImpulse(gasTank, _random.NextFloat(-3f, 3f));
|
_throwing.TryThrow(gasTank, dir * strength, strength);
|
||||||
_audioSys.PlayPvs(gasTank.Comp.RuptureSound, gasTank);
|
_audioSys.PlayPvs(gasTank.Comp.RuptureSound, gasTank);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1044,25 +1044,6 @@ namespace Content.Shared.Interaction
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Throw
|
|
||||||
/// <summary>
|
|
||||||
/// Calls Thrown on all components that implement the IThrown interface
|
|
||||||
/// on an entity that has been thrown.
|
|
||||||
/// </summary>
|
|
||||||
public void ThrownInteraction(EntityUid user, EntityUid thrown)
|
|
||||||
{
|
|
||||||
var throwMsg = new ThrownEvent(user, thrown);
|
|
||||||
RaiseLocalEvent(thrown, throwMsg, true);
|
|
||||||
if (throwMsg.Handled)
|
|
||||||
{
|
|
||||||
_adminLogger.Add(LogType.Throw, LogImpact.Low,$"{ToPrettyString(user):user} threw {ToPrettyString(thrown):entity}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_adminLogger.Add(LogType.Throw, LogImpact.Low,$"{ToPrettyString(user):user} threw {ToPrettyString(thrown):entity}");
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void DroppedInteraction(EntityUid user, EntityUid item)
|
public void DroppedInteraction(EntityUid user, EntityUid item)
|
||||||
{
|
{
|
||||||
var dropMsg = new DroppedEvent(user);
|
var dropMsg = new DroppedEvent(user);
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public abstract class SharedEmitSoundSystem : EntitySystem
|
|||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEmitSoundOnThrown(EntityUid uid, BaseEmitSoundComponent component, ThrownEvent args)
|
private void OnEmitSoundOnThrown(EntityUid uid, BaseEmitSoundComponent component, ref ThrownEvent args)
|
||||||
{
|
{
|
||||||
TryEmitSound(uid, component, args.User, false);
|
TryEmitSound(uid, component, args.User, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
using JetBrains.Annotations;
|
|
||||||
|
|
||||||
namespace Content.Shared.Throwing
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Raised when throwing the entity in your hands.
|
|
||||||
/// </summary>
|
|
||||||
[PublicAPI]
|
|
||||||
public sealed class ThrownEvent : HandledEntityEventArgs
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Entity that threw the item.
|
|
||||||
/// </summary>
|
|
||||||
public EntityUid User { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Item that was thrown.
|
|
||||||
/// </summary>
|
|
||||||
public EntityUid Thrown { get; }
|
|
||||||
|
|
||||||
public ThrownEvent(EntityUid user, EntityUid thrown)
|
|
||||||
{
|
|
||||||
User = user;
|
|
||||||
Thrown = thrown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using Content.Shared.Administration.Logs;
|
||||||
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Gravity;
|
using Content.Shared.Gravity;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Projectiles;
|
using Content.Shared.Projectiles;
|
||||||
@@ -25,10 +27,10 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
|
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
|
||||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
[Dependency] private readonly ThrownItemSystem _thrownSystem = default!;
|
[Dependency] private readonly ThrownItemSystem _thrownSystem = default!;
|
||||||
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||||
|
|
||||||
public void TryThrow(
|
public void TryThrow(
|
||||||
EntityUid uid,
|
EntityUid uid,
|
||||||
@@ -135,8 +137,10 @@ public sealed class ThrowingSystem : EntitySystem
|
|||||||
_transform.SetLocalRotation(uid, angle + offset);
|
_transform.SetLocalRotation(uid, angle + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var throwEvent = new ThrownEvent(user, uid);
|
||||||
|
RaiseLocalEvent(uid, ref throwEvent, true);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
_interactionSystem.ThrownInteraction(user.Value, uid);
|
_adminLogger.Add(LogType.Throw, LogImpact.Low, $"{ToPrettyString(user.Value):user} threw {ToPrettyString(uid):entity}");
|
||||||
|
|
||||||
var impulseVector = direction.Normalized() * strength * physics.Mass;
|
var impulseVector = direction.Normalized() * strength * physics.Mass;
|
||||||
_physics.ApplyLinearImpulse(uid, impulseVector, body: physics);
|
_physics.ApplyLinearImpulse(uid, impulseVector, body: physics);
|
||||||
|
|||||||
10
Content.Shared/Throwing/ThrownEvent.cs
Normal file
10
Content.Shared/Throwing/ThrownEvent.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace Content.Shared.Throwing;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised on thrown entity.
|
||||||
|
/// </summary>
|
||||||
|
[PublicAPI]
|
||||||
|
[ByRefEvent]
|
||||||
|
public readonly record struct ThrownEvent(EntityUid? User, EntityUid Thrown);
|
||||||
@@ -43,7 +43,7 @@ namespace Content.Shared.Throwing
|
|||||||
component.ThrownTime ??= _gameTiming.CurTime;
|
component.ThrownTime ??= _gameTiming.CurTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
|
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ref ThrownEvent @event)
|
||||||
{
|
{
|
||||||
if (!EntityManager.TryGetComponent(uid, out FixturesComponent? fixturesComponent) ||
|
if (!EntityManager.TryGetComponent(uid, out FixturesComponent? fixturesComponent) ||
|
||||||
fixturesComponent.Fixtures.Count != 1 ||
|
fixturesComponent.Fixtures.Count != 1 ||
|
||||||
|
|||||||
@@ -36,6 +36,10 @@
|
|||||||
damage:
|
damage:
|
||||||
types:
|
types:
|
||||||
Blunt: 10
|
Blunt: 10
|
||||||
|
- type: DamageOtherOnHit
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Blunt: 10
|
||||||
- type: PhysicalComposition
|
- type: PhysicalComposition
|
||||||
materialComposition:
|
materialComposition:
|
||||||
Steel: 400
|
Steel: 400
|
||||||
@@ -117,6 +121,10 @@
|
|||||||
damage:
|
damage:
|
||||||
types:
|
types:
|
||||||
Blunt: 5
|
Blunt: 5
|
||||||
|
- type: DamageOtherOnHit
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Blunt: 5
|
||||||
- type: PhysicalComposition
|
- type: PhysicalComposition
|
||||||
materialComposition:
|
materialComposition:
|
||||||
Steel: 100
|
Steel: 100
|
||||||
@@ -161,6 +169,10 @@
|
|||||||
damage:
|
damage:
|
||||||
types:
|
types:
|
||||||
Blunt: 7.5
|
Blunt: 7.5
|
||||||
|
- type: DamageOtherOnHit
|
||||||
|
damage:
|
||||||
|
types:
|
||||||
|
Blunt: 7.5
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: GasTankRoundBase
|
parent: GasTankRoundBase
|
||||||
|
|||||||
Reference in New Issue
Block a user