2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Solar;
|
2021-06-16 15:49:02 +01:00
|
|
|
using Content.Server.Solar.EntitySystems;
|
|
|
|
|
using Content.Server.GameObjects.Components;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.GameObjects;
|
2020-06-02 12:32:18 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.IoC;
|
2020-08-22 22:29:20 +02:00
|
|
|
using Robust.Shared.ViewVariables;
|
2020-06-02 12:32:18 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Solar.Components
|
2020-06-02 12:32:18 +01:00
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2021-06-16 15:49:02 +01:00
|
|
|
[ComponentReference(typeof(BaseComputerUserInterfaceComponent))]
|
|
|
|
|
public class SolarControlConsoleComponent : BaseComputerUserInterfaceComponent
|
2020-06-02 12:32:18 +01:00
|
|
|
{
|
2021-06-16 15:49:02 +01:00
|
|
|
public override string Name => "SolarControlConsole";
|
|
|
|
|
|
2020-08-22 22:29:20 +02:00
|
|
|
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
|
2020-06-02 12:32:18 +01:00
|
|
|
|
2020-08-22 22:29:20 +02:00
|
|
|
private PowerSolarSystem _powerSolarSystem = default!;
|
|
|
|
|
|
2021-06-16 15:49:02 +01:00
|
|
|
public SolarControlConsoleComponent() : base(SolarControlConsoleUiKey.Key) { }
|
2020-06-02 12:32:18 +01:00
|
|
|
|
2021-06-19 19:41:26 -07:00
|
|
|
protected override void Initialize()
|
2020-06-02 12:32:18 +01:00
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
_powerSolarSystem = _entitySystemManager.GetEntitySystem<PowerSolarSystem>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateUIState()
|
|
|
|
|
{
|
2020-08-22 22:29:20 +02:00
|
|
|
UserInterface?.SetState(new SolarControlConsoleBoundInterfaceState(_powerSolarSystem.TargetPanelRotation, _powerSolarSystem.TargetPanelVelocity, _powerSolarSystem.TotalPanelPower, _powerSolarSystem.TowardsSun));
|
2020-06-02 12:32:18 +01:00
|
|
|
}
|
|
|
|
|
|
2021-06-16 15:49:02 +01:00
|
|
|
protected override void OnReceiveUserInterfaceMessage(ServerBoundUserInterfaceMessage obj)
|
2020-06-02 12:32:18 +01:00
|
|
|
{
|
|
|
|
|
switch (obj.Message)
|
|
|
|
|
{
|
|
|
|
|
case SolarControlConsoleAdjustMessage msg:
|
|
|
|
|
if (double.IsFinite(msg.Rotation))
|
|
|
|
|
{
|
|
|
|
|
_powerSolarSystem.TargetPanelRotation = msg.Rotation.Reduced();
|
|
|
|
|
}
|
|
|
|
|
if (double.IsFinite(msg.AngularVelocity))
|
|
|
|
|
{
|
|
|
|
|
_powerSolarSystem.TargetPanelVelocity = msg.AngularVelocity.Reduced();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|