Singulo eats unpowered containment gens (#8343)

This commit is contained in:
wrexbe
2022-05-26 17:35:19 -07:00
committed by GitHub
parent 821df271c4
commit 33c03fa0a0
3 changed files with 6 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
using System.Threading;
using Content.Shared.Singularity.Components;
using Timer = Robust.Shared.Timing.Timer;
namespace Content.Server.Singularity.Components
@@ -65,13 +66,9 @@ namespace Content.Server.Singularity.Components
Timer.SpawnRepeating(1000, () => { SharedEnergyPool--;}, _powerDecreaseCancellationTokenSource.Token);
}
public bool CanRepell(EntityUid toRepell)
public bool CanRepel(SharedSingularityComponent toRepel)
{
var powerNeeded = 1;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<ServerSingularityComponent?>(toRepell, out var singularityComponent))
{
powerNeeded += 2*singularityComponent.Level;
}
var powerNeeded = 2 * toRepel.Level + 1;
return _sharedEnergyPool > powerNeeded;
}

View File

@@ -55,8 +55,8 @@ namespace Content.Server.Singularity.Components
private Tuple<Direction, ContainmentFieldConnection>? _connection1;
private Tuple<Direction, ContainmentFieldConnection>? _connection2;
public bool CanRepell(EntityUid toRepell) => _connection1?.Item2?.CanRepell(toRepell) == true ||
_connection2?.Item2?.CanRepell(toRepell) == true;
public bool CanRepel(SharedSingularityComponent toRepel) => _connection1?.Item2?.CanRepel(toRepel) == true ||
_connection2?.Item2?.CanRepel(toRepel) == true;
public void OnAnchoredChanged()
{

View File

@@ -132,7 +132,7 @@ namespace Content.Server.Singularity.EntitySystems
!EntityManager.HasComponent<GhostComponent>(entity) &&
(component.Level > 4 ||
!EntityManager.HasComponent<ContainmentFieldComponent>(entity) &&
!EntityManager.HasComponent<ContainmentFieldGeneratorComponent>(entity));
!(EntityManager.TryGetComponent<ContainmentFieldGeneratorComponent>(entity, out var containFieldGen) && containFieldGen.CanRepel(component)));
}
private void HandleDestroy(ServerSingularityComponent component, EntityUid entity)