Merge remote-tracking branch 'upstream/master' into DecimalReagents
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Cargo;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.Components.Cargo;
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Content.Shared.Prototypes.Cargo;
|
||||
using Robust.Server.GameObjects.Components.UserInterface;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
@@ -40,6 +41,9 @@ namespace Content.Server.GameObjects.Components.Cargo
|
||||
|
||||
private bool _requestOnly = false;
|
||||
|
||||
private PowerDeviceComponent _powerDevice;
|
||||
private bool Powered => _powerDevice.Powered;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -47,6 +51,7 @@ namespace Content.Server.GameObjects.Components.Cargo
|
||||
Orders = Owner.GetComponent<CargoOrderDatabaseComponent>();
|
||||
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>().GetBoundUserInterface(CargoConsoleUiKey.Key);
|
||||
_userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
|
||||
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
|
||||
_galacticBankManager.AddComponent(this);
|
||||
BankId = 0;
|
||||
}
|
||||
@@ -66,6 +71,8 @@ namespace Content.Server.GameObjects.Components.Cargo
|
||||
var message = serverMsg.Message;
|
||||
if (!Orders.ConnectedToDatabase)
|
||||
return;
|
||||
if (!Powered)
|
||||
return;
|
||||
switch (message)
|
||||
{
|
||||
case CargoConsoleAddOrderMessage msg:
|
||||
@@ -119,6 +126,8 @@ namespace Content.Server.GameObjects.Components.Cargo
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Powered)
|
||||
return;
|
||||
|
||||
_userInterface.Open(actor.playerSession);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Sound;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Interfaces.GameObjects;
|
||||
using Content.Shared.Chemistry;
|
||||
@@ -46,6 +47,11 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
[ViewVariables]
|
||||
private SolutionComponent Solution => _beakerContainer.ContainedEntity.GetComponent<SolutionComponent>();
|
||||
|
||||
///implementing PowerDeviceComponent
|
||||
private PowerDeviceComponent _powerDevice;
|
||||
private bool Powered => _powerDevice.Powered;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Shows the serializer how to save/load this components yaml prototype.
|
||||
/// </summary>
|
||||
@@ -70,6 +76,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
|
||||
_beakerContainer =
|
||||
ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-reagentContainerContainer", Owner);
|
||||
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
|
||||
|
||||
InitializeFromPrototype();
|
||||
UpdateUserInterface();
|
||||
@@ -159,6 +166,9 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
//Check if player can interact in their current state
|
||||
if (!ActionBlockerSystem.CanInteract(playerEntity) || !ActionBlockerSystem.CanUse(playerEntity))
|
||||
return false;
|
||||
//Check if device is powered
|
||||
if (!Powered)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -251,6 +261,9 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Powered)
|
||||
return;
|
||||
|
||||
var activeHandEntity = hands.GetActiveHand?.Owner;
|
||||
if (activeHandEntity == null)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,12 +104,6 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
/// </summary>
|
||||
[ViewVariables] public bool DiagonalMovementEnabled => _configurationManager.GetCVar<bool>("game.diagonalmovement");
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_configurationManager.RegisterCVar("game.diagonalmovement", true, CVar.ARCHIVE);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAdd()
|
||||
{
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
// Only unused on .NET Core due to KeyValuePair.Deconstruct
|
||||
// ReSharper disable once RedundantUsingDirective
|
||||
|
||||
using System;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Content.Server.GameObjects.Components.Stack;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.Components.Materials;
|
||||
using Content.Shared.GameObjects.Components.Power;
|
||||
using Content.Shared.GameObjects.Components.Research;
|
||||
using Content.Shared.Research;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.Components.UserInterface;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timers;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -32,20 +36,35 @@ namespace Content.Server.GameObjects.Components.Research
|
||||
[ViewVariables]
|
||||
public bool Producing { get; private set; } = false;
|
||||
|
||||
private AppearanceComponent _appearance;
|
||||
private LatheState _state = LatheState.Base;
|
||||
|
||||
protected virtual LatheState State
|
||||
{
|
||||
get => _state;
|
||||
set => _state = value;
|
||||
}
|
||||
|
||||
private LatheRecipePrototype _producingRecipe = null;
|
||||
private PowerDeviceComponent _powerDevice;
|
||||
private bool Powered => _powerDevice.Powered;
|
||||
|
||||
private static readonly TimeSpan InsertionTime = TimeSpan.FromSeconds(0.9f);
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>().GetBoundUserInterface(LatheUiKey.Key);
|
||||
_userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
|
||||
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
|
||||
_appearance = Owner.GetComponent<AppearanceComponent>();
|
||||
}
|
||||
|
||||
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
|
||||
{
|
||||
if (!Powered)
|
||||
return;
|
||||
|
||||
switch (message.Message)
|
||||
{
|
||||
case LatheQueueRecipeMessage msg:
|
||||
@@ -71,13 +90,15 @@ namespace Content.Server.GameObjects.Components.Research
|
||||
|
||||
case LatheServerSyncMessage msg:
|
||||
if (!Owner.TryGetComponent(out TechnologyDatabaseComponent database)
|
||||
|| !Owner.TryGetComponent(out ProtolatheDatabaseComponent protoDatabase)) return;
|
||||
|| !Owner.TryGetComponent(out ProtolatheDatabaseComponent protoDatabase)) return;
|
||||
|
||||
if(database.SyncWithServer())
|
||||
if (database.SyncWithServer())
|
||||
protoDatabase.Sync();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
internal bool Produce(LatheRecipePrototype recipe)
|
||||
@@ -100,12 +121,17 @@ namespace Content.Server.GameObjects.Components.Research
|
||||
|
||||
_userInterface.SendMessage(new LatheProducingRecipeMessage(recipe.ID));
|
||||
|
||||
State = LatheState.Producing;
|
||||
SetAppearance(LatheVisualState.Producing);
|
||||
|
||||
Timer.Spawn(recipe.CompleteTime, () =>
|
||||
{
|
||||
Producing = false;
|
||||
_producingRecipe = null;
|
||||
Owner.EntityManager.SpawnEntity(recipe.Result, Owner.Transform.GridPosition);
|
||||
_userInterface.SendMessage(new LatheStoppedProducingRecipeMessage());
|
||||
State = LatheState.Base;
|
||||
SetAppearance(LatheVisualState.Idle);
|
||||
});
|
||||
|
||||
return true;
|
||||
@@ -125,7 +151,6 @@ namespace Content.Server.GameObjects.Components.Research
|
||||
return;
|
||||
}
|
||||
OpenUserInterface(actor.playerSession);
|
||||
return;
|
||||
}
|
||||
bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
|
||||
{
|
||||
@@ -151,15 +176,37 @@ namespace Content.Server.GameObjects.Components.Research
|
||||
|
||||
foreach (var mat in material.MaterialTypes.Values)
|
||||
{
|
||||
|
||||
storage.InsertMaterial(mat.ID, VolumePerSheet * multiplier);
|
||||
}
|
||||
|
||||
State = LatheState.Inserting;
|
||||
switch (material.MaterialTypes.Values.First().Name)
|
||||
{
|
||||
case "Steel":
|
||||
SetAppearance(LatheVisualState.InsertingMetal);
|
||||
break;
|
||||
case "Glass":
|
||||
SetAppearance(LatheVisualState.InsertingGlass);
|
||||
break;
|
||||
}
|
||||
|
||||
Timer.Spawn(InsertionTime, async () =>
|
||||
{
|
||||
State = LatheState.Base;
|
||||
SetAppearance(LatheVisualState.Idle);
|
||||
});
|
||||
|
||||
eventArgs.AttackWith.Delete();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SetAppearance(LatheVisualState state)
|
||||
{
|
||||
if (_appearance != null || Owner.TryGetComponent(out _appearance))
|
||||
_appearance.SetData(PowerDeviceVisuals.VisualState, state);
|
||||
}
|
||||
|
||||
private Queue<string> GetIDQueue()
|
||||
{
|
||||
var queue = new Queue<string>();
|
||||
@@ -170,5 +217,12 @@ namespace Content.Server.GameObjects.Components.Research
|
||||
|
||||
return queue;
|
||||
}
|
||||
|
||||
protected enum LatheState
|
||||
{
|
||||
Base,
|
||||
Inserting,
|
||||
Producing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace Content.Server.GameObjects.Components.Research
|
||||
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out TechnologyDatabaseComponent database)) return;
|
||||
if (!Powered)
|
||||
return;
|
||||
|
||||
switch (message.Message)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace Content.Server.GameObjects.Components.VendingMachines
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!Powered)
|
||||
return;
|
||||
|
||||
var wires = Owner.GetComponent<WiresComponent>();
|
||||
if (wires.IsPanelOpen)
|
||||
@@ -121,6 +123,9 @@ namespace Content.Server.GameObjects.Components.VendingMachines
|
||||
|
||||
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage serverMsg)
|
||||
{
|
||||
if (!Powered)
|
||||
return;
|
||||
|
||||
var message = serverMsg.Message;
|
||||
switch (message)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user