This commit is contained in:
metalgearsloth
2023-01-18 05:25:32 +11:00
committed by GitHub
parent 4456229836
commit 6c9ce79387
27 changed files with 405 additions and 22 deletions

View File

@@ -5,11 +5,8 @@ namespace Content.Shared.Throwing
/// <summary>
/// Raised when an entity that was thrown lands. This occurs before they stop moving and is when their tile-friction is reapplied.
/// </summary>
[PublicAPI]
public sealed class LandEvent : EntityEventArgs
{
public EntityUid? User;
}
[ByRefEvent]
public readonly record struct LandEvent(EntityUid? User);
/// <summary>
/// Raised when a thrown entity is no longer moving.

View File

@@ -82,8 +82,7 @@ public sealed class ThrowingSystem : EntitySystem
if (time < FlyTime)
{
_physics.SetBodyStatus(physics, BodyStatus.OnGround);
_thrownSystem.LandComponent(comp);
_thrownSystem.LandComponent(comp, physics);
}
else
{
@@ -94,8 +93,7 @@ public sealed class ThrowingSystem : EntitySystem
if (physics.Deleted)
return;
_physics.SetBodyStatus(physics, BodyStatus.OnGround);
_thrownSystem.LandComponent(comp);
_thrownSystem.LandComponent(comp, physics);
});
}

View File

@@ -19,9 +19,11 @@ namespace Content.Shared.Throwing
/// </summary>
public sealed class ThrownItemSystem : EntitySystem
{
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly FixtureSystem _fixtures = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
private const string ThrowingFixture = "throw-fixture";
@@ -115,8 +117,10 @@ namespace Content.Shared.Throwing
EntityManager.RemoveComponent<ThrownItemComponent>(uid);
}
public void LandComponent(ThrownItemComponent thrownItem)
public void LandComponent(ThrownItemComponent thrownItem, PhysicsComponent physics)
{
_physics.SetBodyStatus(physics, BodyStatus.OnGround);
if (thrownItem.Deleted || Deleted(thrownItem.Owner) || _containerSystem.IsEntityInContainer(thrownItem.Owner)) return;
var landing = thrownItem.Owner;
@@ -133,8 +137,9 @@ namespace Content.Shared.Throwing
if (thrownItem.Thrower is not null)
_adminLogger.Add(LogType.Landed, LogImpact.Low, $"{ToPrettyString(landing):entity} thrown by {ToPrettyString(thrownItem.Thrower.Value):thrower} landed.");
var landMsg = new LandEvent {User = thrownItem.Thrower};
RaiseLocalEvent(landing, landMsg, false);
_broadphase.RegenerateContacts(physics);
var landEvent = new LandEvent(thrownItem.Thrower);
RaiseLocalEvent(landing, ref landEvent);
}
/// <summary>