Update for collision events by-ref (#10933)

This commit is contained in:
metalgearsloth
2022-09-14 17:26:26 +10:00
committed by GitHub
parent feb50ce7cc
commit 78a4ab6eb2
105 changed files with 204 additions and 62 deletions

View File

@@ -11,6 +11,8 @@ using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Content.Shared.Throwing;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Events;
using Robust.Shared.Player;
namespace Content.Server.Singularity.EntitySystems;
@@ -58,7 +60,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
/// <summary>
/// A generator receives power from a source colliding with it.
/// </summary>
private void HandleGeneratorCollide(EntityUid uid, ContainmentFieldGeneratorComponent component, StartCollideEvent args)
private void HandleGeneratorCollide(EntityUid uid, ContainmentFieldGeneratorComponent component, ref StartCollideEvent args)
{
if (_tags.HasTag(args.OtherFixture.Body.Owner, component.IDTag))
{

View File

@@ -5,7 +5,9 @@ using Content.Shared.Popups;
using Content.Shared.Tag;
using Content.Shared.Throwing;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Physics.Events;
using Robust.Shared.Player;
namespace Content.Server.Singularity.EntitySystems;
@@ -22,7 +24,7 @@ public sealed class ContainmentFieldSystem : EntitySystem
SubscribeLocalEvent<ContainmentFieldComponent, StartCollideEvent>(HandleFieldCollide);
}
private void HandleFieldCollide(EntityUid uid, ContainmentFieldComponent component, StartCollideEvent args)
private void HandleFieldCollide(EntityUid uid, ContainmentFieldComponent component, ref StartCollideEvent args)
{
var otherBody = args.OtherFixture.Body.Owner;

View File

@@ -14,6 +14,7 @@ using Content.Shared.Singularity.Components;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Utility;

View File

@@ -2,6 +2,7 @@
using Content.Server.Singularity.Components;
using Content.Shared.Singularity.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Physics.Events;
namespace Content.Server.Singularity.EntitySystems;
@@ -14,7 +15,7 @@ public sealed class SingularityGeneratorSystem : EntitySystem
SubscribeLocalEvent<ParticleProjectileComponent, StartCollideEvent>(HandleParticleCollide);
}
private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent component, StartCollideEvent args)
private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent component, ref StartCollideEvent args)
{
if (EntityManager.TryGetComponent<SingularityGeneratorComponent?>(args.OtherFixture.Body.Owner, out var singularityGeneratorComponent))
{

View File

@@ -8,7 +8,9 @@ using Robust.Server.GameStates;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Physics.Events;
namespace Content.Server.Singularity.EntitySystems
{
@@ -44,9 +46,9 @@ namespace Content.Server.Singularity.EntitySystems
_pvs.AddGlobalOverride(uid);
}
protected override bool PreventCollide(EntityUid uid, SharedSingularityComponent component, PreventCollideEvent args)
protected override bool PreventCollide(EntityUid uid, SharedSingularityComponent component, ref PreventCollideEvent args)
{
if (base.PreventCollide(uid, component, args)) return true;
if (base.PreventCollide(uid, component, ref args)) return true;
var otherUid = args.BodyB.Owner;
@@ -54,12 +56,12 @@ namespace Content.Server.Singularity.EntitySystems
// If it's not cancelled then we'll cancel if we can't immediately destroy it on collision
if (!CanDestroy(component, otherUid))
args.Cancel();
args.Cancelled = true;
return true;
}
private void OnCollide(EntityUid uid, ServerSingularityComponent component, StartCollideEvent args)
private void OnCollide(EntityUid uid, ServerSingularityComponent component, ref StartCollideEvent args)
{
if (args.OurFixture.ID != "DeleteCircle") return;