Added power checks
Added power checks to: Reagent Dispenser Medical Scanner Lathes Research Console Vending Machines Added power device component to: chem dispenser prototype medical scanner prototype Fixes for #706
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Medical;
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.Components.Container;
|
||||
using Robust.Server.GameObjects.Components.UserInterface;
|
||||
@@ -24,6 +25,10 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
private readonly Vector2 _ejectOffset = new Vector2(-0.5f, 0f);
|
||||
public bool IsOccupied => _bodyContainer.ContainedEntity != null;
|
||||
|
||||
///implementing PowerDeviceComponent
|
||||
private PowerDeviceComponent _powerDevice;
|
||||
private bool Powered => _powerDevice.Powered;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -31,6 +36,7 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
|
||||
.GetBoundUserInterface(MedicalScannerUiKey.Key);
|
||||
_bodyContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-bodyContainer", Owner);
|
||||
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
|
||||
UpdateUserInterface();
|
||||
}
|
||||
|
||||
@@ -79,6 +85,8 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
|
||||
private void UpdateUserInterface()
|
||||
{
|
||||
if (!Powered)
|
||||
return;
|
||||
var newState = GetUserInterfaceState();
|
||||
_userInterface.SetState(newState);
|
||||
}
|
||||
@@ -112,6 +120,8 @@ namespace Content.Server.GameObjects.Components.Medical
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Powered)
|
||||
return;
|
||||
_userInterface.Open(actor.playerSession);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user