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

@@ -0,0 +1,10 @@
namespace Content.Shared.Climbing.Events;
/// <summary>
/// Raised on an entity when it ends climbing.
/// </summary>
[ByRefEvent]
public readonly record struct EndClimbEvent
{
}

View File

@@ -45,7 +45,7 @@ namespace Content.Shared.Nutrition.EntitySystems
}
}
private void OnCreamPieLand(EntityUid uid, CreamPieComponent component, LandEvent args)
private void OnCreamPieLand(EntityUid uid, CreamPieComponent component, ref LandEvent args)
{
SplatCreamPie(uid, component);
}

View File

@@ -29,7 +29,7 @@ namespace Content.Shared.Sound
{
base.Initialize();
SubscribeLocalEvent<EmitSoundOnSpawnComponent, ComponentInit>(HandleEmitSpawnOnInit);
SubscribeLocalEvent<EmitSoundOnLandComponent, LandEvent>(HandleEmitSoundOnLand);
SubscribeLocalEvent<EmitSoundOnLandComponent, LandEvent>(OnEmitSoundOnLand);
SubscribeLocalEvent<EmitSoundOnUseComponent, UseInHandEvent>(HandleEmitSoundOnUseInHand);
SubscribeLocalEvent<EmitSoundOnThrowComponent, ThrownEvent>(HandleEmitSoundOnThrown);
SubscribeLocalEvent<EmitSoundOnActivateComponent, ActivateInWorldEvent>(HandleEmitSoundOnActivateInWorld);
@@ -42,7 +42,7 @@ namespace Content.Shared.Sound
TryEmitSound(component, predict: false);
}
private void HandleEmitSoundOnLand(EntityUid uid, BaseEmitSoundComponent component, LandEvent args)
private void OnEmitSoundOnLand(EntityUid uid, BaseEmitSoundComponent component, ref LandEvent args)
{
if (!TryComp<TransformComponent>(uid, out var xform) ||
!_mapManager.TryGetGrid(xform.GridUid, out var grid))

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>