R&D Equipment now require power to operate. (#428)

* Fixes: #392

- Make Lathe require power to interact with or produce.
- Make R&D Console require power to interact with.
- Add PowerDevice component to R&D computer.
- Add PowerDevice component to R&D server.

* Update LatheComponent.cs

* Update LatheComponent.cs

* Update ResearchConsoleComponent.cs
This commit is contained in:
Ephememory
2019-11-12 09:35:34 -05:00
committed by Pieter-Jan Briers
parent 841bb101c5
commit ef2b665ff0
4 changed files with 36 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.Components.Stack; using Content.Server.GameObjects.Components.Stack;
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Materials; using Content.Shared.GameObjects.Components.Materials;
@@ -30,12 +31,15 @@ namespace Content.Server.GameObjects.Components.Research
public bool Producing { get; private set; } = false; public bool Producing { get; private set; } = false;
private LatheRecipePrototype _producingRecipe = null; private LatheRecipePrototype _producingRecipe = null;
private PowerDeviceComponent _powerDevice;
private bool Powered => _powerDevice.Powered;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>().GetBoundUserInterface(LatheUiKey.Key); _userInterface = Owner.GetComponent<ServerUserInterfaceComponent>().GetBoundUserInterface(LatheUiKey.Key);
_userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage; _userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
} }
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message) private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
@@ -75,7 +79,10 @@ namespace Content.Server.GameObjects.Components.Research
} }
internal bool Produce(LatheRecipePrototype recipe) internal bool Produce(LatheRecipePrototype recipe)
{ if(!Powered)
{ {
return false;
}
if (Producing || !CanProduce(recipe) || !Owner.TryGetComponent(out MaterialStorageComponent storage)) return false; if (Producing || !CanProduce(recipe) || !Owner.TryGetComponent(out MaterialStorageComponent storage)) return false;
_userInterface.SendMessage(new LatheFullQueueMessage(GetIDQueue())); _userInterface.SendMessage(new LatheFullQueueMessage(GetIDQueue()));
@@ -111,7 +118,10 @@ namespace Content.Server.GameObjects.Components.Research
{ {
if (!eventArgs.User.TryGetComponent(out IActorComponent actor)) if (!eventArgs.User.TryGetComponent(out IActorComponent actor))
return; return;
if (!Powered)
{
return;
}
OpenUserInterface(actor.playerSession); OpenUserInterface(actor.playerSession);
return; return;
} }

View File

@@ -1,7 +1,9 @@
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.Components.Power;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.Audio; using Content.Shared.Audio;
using Content.Shared.GameObjects.Components.Research; using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Research; using Content.Shared.Research;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.GameObjects.EntitySystems; using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.GameObjects; using Robust.Server.Interfaces.GameObjects;
@@ -30,13 +32,18 @@ namespace Content.Server.GameObjects.Components.Research
private BoundUserInterface _userInterface; private BoundUserInterface _userInterface;
private ResearchClientComponent _client; private ResearchClientComponent _client;
private PowerDeviceComponent _powerDevice;
private const string _soundCollectionName = "keyboard"; private const string _soundCollectionName = "keyboard";
private bool Powered => _powerDevice.Powered;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>().GetBoundUserInterface(ResearchConsoleUiKey.Key); _userInterface = Owner.GetComponent<ServerUserInterfaceComponent>().GetBoundUserInterface(ResearchConsoleUiKey.Key);
_userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage; _userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
_client = Owner.GetComponent<ResearchClientComponent>(); _client = Owner.GetComponent<ResearchClientComponent>();
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
} }
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message) private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
@@ -99,7 +106,10 @@ namespace Content.Server.GameObjects.Components.Research
{ {
if (!eventArgs.User.TryGetComponent(out IActorComponent actor)) if (!eventArgs.User.TryGetComponent(out IActorComponent actor))
return; return;
if (!Powered)
{
return;
}
OpenUserInterface(actor.playerSession); OpenUserInterface(actor.playerSession);
PlayKeyboardSound(); PlayKeyboardSound();
return; return;
@@ -112,5 +122,7 @@ namespace Content.Server.GameObjects.Components.Research
var audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>(); var audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
audioSystem.Play(file); audioSystem.Play(file);
} }
} }
} }

View File

@@ -14,6 +14,10 @@
offset: Center offset: Center
- type: ResearchServer - type: ResearchServer
- type: TechnologyDatabase - type: TechnologyDatabase
- type: PowerDevice
drawtype: Both
load: 200
priority: Low
- type: entity - type: entity
id: baseResearchAndDevelopmentPointSource id: baseResearchAndDevelopmentPointSource

View File

@@ -109,7 +109,10 @@
type: ResearchConsoleBoundUserInterface type: ResearchConsoleBoundUserInterface
- key: enum.ResearchClientUiKey.Key - key: enum.ResearchClientUiKey.Key
type: ResearchClientBoundUserInterface type: ResearchClientBoundUserInterface
- type: PowerDevice
drawtype: Both
load: 200
priority: Low
- type: entity - type: entity
id: computerId id: computerId