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,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;
}
}
}

View File

@@ -1,4 +1,6 @@
using System.Numerics;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Gravity;
using Content.Shared.Interaction;
using Content.Shared.Projectiles;
@@ -25,10 +27,10 @@ public sealed class ThrowingSystem : EntitySystem
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly SharedGravitySystem _gravity = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly ThrownItemSystem _thrownSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
public void TryThrow(
EntityUid uid,
@@ -135,8 +137,10 @@ public sealed class ThrowingSystem : EntitySystem
_transform.SetLocalRotation(uid, angle + offset);
}
var throwEvent = new ThrownEvent(user, uid);
RaiseLocalEvent(uid, ref throwEvent, true);
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;
_physics.ApplyLinearImpulse(uid, impulseVector, body: physics);

View 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);

View File

@@ -43,7 +43,7 @@ namespace Content.Shared.Throwing
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) ||
fixturesComponent.Fixtures.Count != 1 ||