Remove IStartCollide from containment fields (#4318)
* Remove IStartCollide from containment fields * Emitter namespace * vera reviews
This commit is contained in:
@@ -12,30 +12,14 @@ using Robust.Shared.Timing;
|
|||||||
namespace Content.Server.ParticleAccelerator.Components
|
namespace Content.Server.ParticleAccelerator.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class ParticleProjectileComponent : Component, IStartCollide
|
public class ParticleProjectileComponent : Component
|
||||||
{
|
{
|
||||||
public override string Name => "ParticleProjectile";
|
public override string Name => "ParticleProjectile";
|
||||||
private ParticleAcceleratorPowerState _state;
|
public 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 void Fire(ParticleAcceleratorPowerState state, Angle angle, IEntity firer)
|
public void Fire(ParticleAcceleratorPowerState state, Angle angle, IEntity firer)
|
||||||
{
|
{
|
||||||
_state = state;
|
State = state;
|
||||||
|
|
||||||
if (!Owner.TryGetComponent<PhysicsComponent>(out var physicsComponent))
|
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");
|
Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var multiplier = _state switch
|
var multiplier = State switch
|
||||||
{
|
{
|
||||||
ParticleAcceleratorPowerState.Standby => 0,
|
ParticleAcceleratorPowerState.Standby => 0,
|
||||||
ParticleAcceleratorPowerState.Level0 => 1,
|
ParticleAcceleratorPowerState.Level0 => 1,
|
||||||
|
|||||||
@@ -1,24 +1,11 @@
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Physics.Collision;
|
|
||||||
using Robust.Shared.Physics.Dynamics;
|
|
||||||
|
|
||||||
namespace Content.Server.Singularity.Components
|
namespace Content.Server.Singularity.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class ContainmentFieldComponent : Component, IStartCollide
|
public class ContainmentFieldComponent : Component
|
||||||
{
|
{
|
||||||
public override string Name => "ContainmentField";
|
public override string Name => "ContainmentField";
|
||||||
public ContainmentFieldConnection? Parent;
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,18 @@ using System;
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Shared.Physics;
|
using Content.Shared.Physics;
|
||||||
using Content.Shared.Tag;
|
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Physics.Broadphase;
|
using Robust.Shared.Physics.Broadphase;
|
||||||
using Robust.Shared.Physics.Collision;
|
|
||||||
using Robust.Shared.Physics.Dynamics;
|
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.Singularity.Components
|
namespace Content.Server.Singularity.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class ContainmentFieldGeneratorComponent : Component, IStartCollide
|
public class ContainmentFieldGeneratorComponent : Component
|
||||||
{
|
{
|
||||||
public override string Name => "ContainmentFieldGenerator";
|
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()
|
public void UpdateConnectionLights()
|
||||||
{
|
{
|
||||||
if (_pointLightComponent != null)
|
if (_pointLightComponent != null)
|
||||||
|
|||||||
@@ -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.GameObjects;
|
||||||
|
using Robust.Shared.Physics.Dynamics;
|
||||||
|
|
||||||
namespace Content.Server.Singularity.EntitySystems
|
namespace Content.Server.Singularity.EntitySystems
|
||||||
{
|
{
|
||||||
@@ -10,6 +14,45 @@ namespace Content.Server.Singularity.EntitySystems
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<ContainmentFieldGeneratorComponent, PhysicsBodyTypeChangedEvent>(BodyTypeChanged);
|
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(
|
private static void BodyTypeChanged(
|
||||||
|
|||||||
Reference in New Issue
Block a user