mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
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:
parent
841bb101c5
commit
ef2b665ff0
4 changed files with 36 additions and 7 deletions
|
|
@ -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.EntitySystems;
|
||||
using Content.Shared.GameObjects.Components.Materials;
|
||||
|
|
@ -30,12 +31,15 @@ namespace Content.Server.GameObjects.Components.Research
|
|||
public bool Producing { get; private set; } = false;
|
||||
|
||||
private LatheRecipePrototype _producingRecipe = null;
|
||||
private PowerDeviceComponent _powerDevice;
|
||||
private bool Powered => _powerDevice.Powered;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>().GetBoundUserInterface(LatheUiKey.Key);
|
||||
_userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
|
||||
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
|
||||
}
|
||||
|
||||
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
|
||||
|
|
@ -75,7 +79,10 @@ namespace Content.Server.GameObjects.Components.Research
|
|||
}
|
||||
|
||||
internal bool Produce(LatheRecipePrototype recipe)
|
||||
{
|
||||
{ if(!Powered)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (Producing || !CanProduce(recipe) || !Owner.TryGetComponent(out MaterialStorageComponent storage)) return false;
|
||||
|
||||
_userInterface.SendMessage(new LatheFullQueueMessage(GetIDQueue()));
|
||||
|
|
@ -111,7 +118,10 @@ namespace Content.Server.GameObjects.Components.Research
|
|||
{
|
||||
if (!eventArgs.User.TryGetComponent(out IActorComponent actor))
|
||||
return;
|
||||
|
||||
if (!Powered)
|
||||
{
|
||||
return;
|
||||
}
|
||||
OpenUserInterface(actor.playerSession);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.GameObjects.Components.Research;
|
||||
using Content.Shared.Research;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.Components.UserInterface;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
|
|
@ -30,13 +32,18 @@ namespace Content.Server.GameObjects.Components.Research
|
|||
|
||||
private BoundUserInterface _userInterface;
|
||||
private ResearchClientComponent _client;
|
||||
private PowerDeviceComponent _powerDevice;
|
||||
private const string _soundCollectionName = "keyboard";
|
||||
|
||||
private bool Powered => _powerDevice.Powered;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>().GetBoundUserInterface(ResearchConsoleUiKey.Key);
|
||||
_userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
|
||||
_client = Owner.GetComponent<ResearchClientComponent>();
|
||||
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
|
||||
}
|
||||
|
||||
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
|
||||
|
|
@ -99,7 +106,10 @@ namespace Content.Server.GameObjects.Components.Research
|
|||
{
|
||||
if (!eventArgs.User.TryGetComponent(out IActorComponent actor))
|
||||
return;
|
||||
|
||||
if (!Powered)
|
||||
{
|
||||
return;
|
||||
}
|
||||
OpenUserInterface(actor.playerSession);
|
||||
PlayKeyboardSound();
|
||||
return;
|
||||
|
|
@ -112,5 +122,7 @@ namespace Content.Server.GameObjects.Components.Research
|
|||
var audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
||||
audioSystem.Play(file);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,11 @@
|
|||
offset: Center
|
||||
- type: ResearchServer
|
||||
- type: TechnologyDatabase
|
||||
|
||||
- type: PowerDevice
|
||||
drawtype: Both
|
||||
load: 200
|
||||
priority: Low
|
||||
|
||||
- type: entity
|
||||
id: baseResearchAndDevelopmentPointSource
|
||||
name: "Base R&D Point Source"
|
||||
|
|
|
|||
|
|
@ -109,7 +109,10 @@
|
|||
type: ResearchConsoleBoundUserInterface
|
||||
- key: enum.ResearchClientUiKey.Key
|
||||
type: ResearchClientBoundUserInterface
|
||||
|
||||
- type: PowerDevice
|
||||
drawtype: Both
|
||||
load: 200
|
||||
priority: Low
|
||||
|
||||
- type: entity
|
||||
id: computerId
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue