2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Medical.Components;
|
2021-09-20 19:06:48 +10:00
|
|
|
using Content.Shared.ActionBlocker;
|
|
|
|
|
using Content.Shared.Movement;
|
2020-08-13 22:17:12 +10:00
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-09-20 19:06:48 +10:00
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Timing;
|
2019-09-18 20:24:55 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Medical
|
2019-09-18 20:24:55 +02:00
|
|
|
{
|
2020-08-13 22:17:12 +10:00
|
|
|
[UsedImplicitly]
|
|
|
|
|
internal sealed class MedicalScannerSystem : EntitySystem
|
2019-09-18 20:24:55 +02:00
|
|
|
{
|
2021-09-20 19:06:48 +10:00
|
|
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
|
|
|
|
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
SubscribeLocalEvent<MedicalScannerComponent, RelayMovementEntityEvent>(OnRelayMovement);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnRelayMovement(EntityUid uid, MedicalScannerComponent component, RelayMovementEntityEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (_blocker.CanInteract(args.Entity))
|
|
|
|
|
{
|
|
|
|
|
if (_gameTiming.CurTime <
|
|
|
|
|
component.LastInternalOpenAttempt + MedicalScannerComponent.InternalOpenAttemptDelay)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
component.LastInternalOpenAttempt = _gameTiming.CurTime;
|
|
|
|
|
component.EjectBody();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-19 10:23:20 -04:00
|
|
|
|
2019-09-18 20:24:55 +02:00
|
|
|
public override void Update(float frameTime)
|
|
|
|
|
{
|
2021-02-04 00:20:48 +11:00
|
|
|
foreach (var comp in ComponentManager.EntityQuery<MedicalScannerComponent>(true))
|
2019-09-18 20:24:55 +02:00
|
|
|
{
|
|
|
|
|
comp.Update(frameTime);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|