Remove IStartCollide from singulo (#4313)
I accidentally glanced at the rest of singulo code and went blind.
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Content.Server.Singularity.Components
|
|||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[ComponentReference(typeof(SharedSingularityComponent))]
|
[ComponentReference(typeof(SharedSingularityComponent))]
|
||||||
public class ServerSingularityComponent : SharedSingularityComponent, IStartCollide
|
public class ServerSingularityComponent : SharedSingularityComponent
|
||||||
{
|
{
|
||||||
private SharedSingularitySystem _singularitySystem = default!;
|
private SharedSingularitySystem _singularitySystem = default!;
|
||||||
|
|
||||||
@@ -94,46 +94,6 @@ namespace Content.Server.Singularity.Components
|
|||||||
Energy -= EnergyDrain * seconds;
|
Energy -= EnergyDrain * seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
|
|
||||||
{
|
|
||||||
// If we're being deleted by another singularity, this call is probably for that singularity.
|
|
||||||
// Even if not, just don't bother.
|
|
||||||
if (BeingDeletedByAnotherSingularity)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var otherEntity = otherFixture.Body.Owner;
|
|
||||||
|
|
||||||
if (otherEntity.TryGetComponent<IMapGridComponent>(out var mapGridComponent))
|
|
||||||
{
|
|
||||||
foreach (var tile in mapGridComponent.Grid.GetTilesIntersecting(ourFixture.Body.GetWorldAABB()))
|
|
||||||
{
|
|
||||||
mapGridComponent.Grid.SetTile(tile.GridIndices, Robust.Shared.Map.Tile.Empty);
|
|
||||||
Energy++;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (otherEntity.HasComponent<ContainmentFieldComponent>() ||
|
|
||||||
(otherEntity.TryGetComponent<ContainmentFieldGeneratorComponent>(out var component) && component.CanRepell(Owner)))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (otherEntity.IsInContainer())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Singularity priority management / etc.
|
|
||||||
if (otherEntity.TryGetComponent<ServerSingularityComponent>(out var otherSingulo))
|
|
||||||
otherSingulo.BeingDeletedByAnotherSingularity = true;
|
|
||||||
|
|
||||||
otherEntity.QueueDelete();
|
|
||||||
|
|
||||||
if (otherEntity.TryGetComponent<SinguloFoodComponent>(out var singuloFood))
|
|
||||||
Energy += singuloFood.Energy;
|
|
||||||
else
|
|
||||||
Energy++;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnRemove()
|
protected override void OnRemove()
|
||||||
{
|
{
|
||||||
_playingSound?.Stop();
|
_playingSound?.Stop();
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
using Content.Server.Singularity.Components;
|
using Content.Server.Singularity.Components;
|
||||||
using Content.Shared.Singularity;
|
using Content.Shared.Singularity;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Physics.Dynamics;
|
||||||
|
|
||||||
namespace Content.Server.Singularity.EntitySystems
|
namespace Content.Server.Singularity.EntitySystems
|
||||||
{
|
{
|
||||||
@@ -10,6 +13,52 @@ namespace Content.Server.Singularity.EntitySystems
|
|||||||
private float _updateInterval = 1.0f;
|
private float _updateInterval = 1.0f;
|
||||||
private float _accumulator;
|
private float _accumulator;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
SubscribeLocalEvent<ServerSingularityComponent, StartCollideEvent>(HandleCollide);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleCollide(EntityUid uid, ServerSingularityComponent component, StartCollideEvent args)
|
||||||
|
{
|
||||||
|
// If we're being deleted by another singularity, this call is probably for that singularity.
|
||||||
|
// Even if not, just don't bother.
|
||||||
|
if (component.BeingDeletedByAnotherSingularity)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var otherEntity = args.OtherFixture.Body.Owner;
|
||||||
|
|
||||||
|
if (otherEntity.TryGetComponent<IMapGridComponent>(out var mapGridComponent))
|
||||||
|
{
|
||||||
|
foreach (var tile in mapGridComponent.Grid.GetTilesIntersecting(args.OurFixture.Body.GetWorldAABB()))
|
||||||
|
{
|
||||||
|
mapGridComponent.Grid.SetTile(tile.GridIndices, Robust.Shared.Map.Tile.Empty);
|
||||||
|
component.Energy++;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (otherEntity.HasComponent<ContainmentFieldComponent>() ||
|
||||||
|
(otherEntity.TryGetComponent<ContainmentFieldGeneratorComponent>(out var containmentField) && containmentField.CanRepell(component.Owner)))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (otherEntity.IsInContainer())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Singularity priority management / etc.
|
||||||
|
if (otherEntity.TryGetComponent<ServerSingularityComponent>(out var otherSingulo))
|
||||||
|
otherSingulo.BeingDeletedByAnotherSingularity = true;
|
||||||
|
|
||||||
|
otherEntity.QueueDelete();
|
||||||
|
|
||||||
|
if (otherEntity.TryGetComponent<SinguloFoodComponent>(out var singuloFood))
|
||||||
|
component.Energy += singuloFood.Energy;
|
||||||
|
else
|
||||||
|
component.Energy++;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
|
|||||||
Reference in New Issue
Block a user