Remove IStartCollide from containment fields (#4318)

* Remove IStartCollide from containment fields

* Emitter namespace

* vera reviews
This commit is contained in:
metalgearsloth
2021-07-21 22:26:18 +10:00
committed by GitHub
parent 3775d329bd
commit 39801372be
4 changed files with 50 additions and 46 deletions

View File

@@ -12,30 +12,14 @@ using Robust.Shared.Timing;
namespace Content.Server.ParticleAccelerator.Components
{
[RegisterComponent]
public class ParticleProjectileComponent : Component, IStartCollide
public class ParticleProjectileComponent : Component
{
public override string Name => "ParticleProjectile";
private ParticleAcceleratorPowerState _state;
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (otherFixture.Body.Owner.TryGetComponent<SingularityGeneratorComponent>(out var singularityGeneratorComponent))
{
singularityGeneratorComponent.Power += _state switch
{
ParticleAcceleratorPowerState.Standby => 0,
ParticleAcceleratorPowerState.Level0 => 1,
ParticleAcceleratorPowerState.Level1 => 2,
ParticleAcceleratorPowerState.Level2 => 4,
ParticleAcceleratorPowerState.Level3 => 8,
_ => 0
};
Owner.Delete();
}
}
public ParticleAcceleratorPowerState State;
public void Fire(ParticleAcceleratorPowerState state, Angle angle, IEntity firer)
{
_state = state;
State = state;
if (!Owner.TryGetComponent<PhysicsComponent>(out var physicsComponent))
{
@@ -56,7 +40,7 @@ namespace Content.Server.ParticleAccelerator.Components
Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent");
return;
}
var multiplier = _state switch
var multiplier = State switch
{
ParticleAcceleratorPowerState.Standby => 0,
ParticleAcceleratorPowerState.Level0 => 1,

View File

@@ -1,24 +1,11 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
namespace Content.Server.Singularity.Components
{
[RegisterComponent]
public class ContainmentFieldComponent : Component, IStartCollide
public class ContainmentFieldComponent : Component
{
public override string Name => "ContainmentField";
public ContainmentFieldConnection? Parent;
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (Parent == null)
{
Owner.QueueDelete();
return;
}
Parent.TryRepell(Owner, otherFixture.Body.Owner);
}
}
}

View File

@@ -2,21 +2,18 @@ using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Physics;
using Content.Shared.Tag;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Broadphase;
using Robust.Shared.Physics.Collision;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.ViewVariables;
namespace Content.Server.Singularity.Components
{
[RegisterComponent]
public class ContainmentFieldGeneratorComponent : Component, IStartCollide
public class ContainmentFieldGeneratorComponent : Component
{
public override string Name => "ContainmentFieldGenerator";
@@ -165,13 +162,6 @@ namespace Content.Server.Singularity.Components
}
}
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
{
if (otherFixture.Body.Owner.HasTag("EmitterBolt")) {
ReceivePower(6);
}
}
public void UpdateConnectionLights()
{
if (_pointLightComponent != null)

View File

@@ -1,5 +1,9 @@
using Content.Server.Singularity.Components;
using Content.Server.ParticleAccelerator.Components;
using Content.Server.Singularity.Components;
using Content.Shared.Singularity.Components;
using Content.Shared.Tag;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics.Dynamics;
namespace Content.Server.Singularity.EntitySystems
{
@@ -10,6 +14,45 @@ namespace Content.Server.Singularity.EntitySystems
base.Initialize();
SubscribeLocalEvent<ContainmentFieldGeneratorComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
SubscribeLocalEvent<ContainmentFieldComponent, StartCollideEvent>(HandleFieldCollide);
SubscribeLocalEvent<ContainmentFieldGeneratorComponent, StartCollideEvent>(HandleGeneratorCollide);
SubscribeLocalEvent<ParticleProjectileComponent, StartCollideEvent>(HandleParticleCollide);
}
private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent component, StartCollideEvent args)
{
if (args.OtherFixture.Body.Owner.TryGetComponent<SingularityGeneratorComponent>(out var singularityGeneratorComponent))
{
singularityGeneratorComponent.Power += component.State switch
{
ParticleAcceleratorPowerState.Standby => 0,
ParticleAcceleratorPowerState.Level0 => 1,
ParticleAcceleratorPowerState.Level1 => 2,
ParticleAcceleratorPowerState.Level2 => 4,
ParticleAcceleratorPowerState.Level3 => 8,
_ => 0
};
EntityManager.QueueDeleteEntity(uid);
}
}
private void HandleGeneratorCollide(EntityUid uid, ContainmentFieldGeneratorComponent component, StartCollideEvent args)
{
if (args.OtherFixture.Body.Owner.HasTag("EmitterBolt")) {
component.ReceivePower(6);
}
}
private void HandleFieldCollide(EntityUid uid, ContainmentFieldComponent component, StartCollideEvent args)
{
if (component.Parent == null)
{
EntityManager.QueueDeleteEntity(uid);
return;
}
component.Parent.TryRepell(component.Owner, args.OtherFixture.Body.Owner);
}
private static void BodyTypeChanged(