Adds Research, unlockable technologies, Protolathes... (#264)

* Work on Research so far
More work on UI...
Fix ResearchClient and Protolathe UI stuff.
Fix infinite select -> request state -> select -> ... loop
Add UI to ResearchClient, etc.
Technology Database states, and a bit of work on the research console ui
A bit of work on Research Console UI
Protolathe sync
Stuff that actually does things
Protolathe databases yay
Alright got my motivation back
Yeah, no. It's almost 3 AM already
Fix serialization bug again
More work on stuff
Stuff
Adds files for most new components/systems.

* Protolathes actually work now

* Research. Just Research.

* Adds icons from Eris.

* Address reviews

* Change LatheMenu resize behaviour

* Update Content.Client/GameObjects/Components/Research/ResearchConsoleBoundUserInterface.cs

Co-Authored-By: Pieter-Jan Briers <pieterjan.briers@gmail.com>

* Update Content.Client/Research/ResearchConsoleMenu.cs

Co-Authored-By: Pieter-Jan Briers <pieterjan.briers@gmail.com>

* Move IoC Resolve out of for loop

* Address review

* Localize stuff
This commit is contained in:
Víctor Aguilera Puerto
2019-09-03 22:51:19 +02:00
committed by Pieter-Jan Briers
parent b62fb4a318
commit ba8b495ec0
61 changed files with 1884 additions and 23 deletions

View File

@@ -0,0 +1,109 @@
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Research;
using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.UserInterface;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Systems;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Research
{
[RegisterComponent]
public class ResearchClientComponent : SharedResearchClientComponent, IActivate
{
// TODO: Create GUI for changing RD server.
private BoundUserInterface _userInterface;
#pragma warning disable 649
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
#pragma warning restore 649
public bool ConnectedToServer => Server != null;
[ViewVariables(VVAccess.ReadOnly)]
public ResearchServerComponent Server { get; set; }
public bool RegisterServer(ResearchServerComponent server)
{
var result = server != null && server.RegisterClient(this);
return result;
}
public void UnregisterFromServer()
{
Server?.UnregisterClient(this);
}
public override void Initialize()
{
base.Initialize();
// For now it just registers on the first server it can find.
var servers = _entitySystemManager.GetEntitySystem<ResearchSystem>().Servers;
if(servers.Count > 0)
RegisterServer(servers[0]);
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>().GetBoundUserInterface(ResearchClientUiKey.Key);
_userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
}
public void OpenUserInterface(IPlayerSession session)
{
UpdateUserInterface();
_userInterface.Open(session);
}
void IActivate.Activate(ActivateEventArgs eventArgs)
{
if (!eventArgs.User.TryGetComponent(out IActorComponent actor))
return;
OpenUserInterface(actor.playerSession);
return;
}
public void UpdateUserInterface()
{
_userInterface?.SetState(GetNewUiState());
}
private ResearchClientBoundInterfaceState GetNewUiState()
{
var rd = _entitySystemManager.GetEntitySystem<ResearchSystem>();
return new ResearchClientBoundInterfaceState(rd.Servers.Count, rd.GetServerNames(),
rd.GetServerIds(), ConnectedToServer ? Server.Id : -1);
}
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage msg)
{
switch (msg.Message)
{
case ResearchClientSyncMessage _:
UpdateUserInterface();
break;
case ResearchClientServerSelectedMessage selectedMessage:
UnregisterFromServer();
RegisterServer(_entitySystemManager.GetEntitySystem<ResearchSystem>().GetServerById(selectedMessage.ServerId));
UpdateUserInterface();
break;
case ResearchClientServerDeselectedMessage _:
UnregisterFromServer();
UpdateUserInterface();
break;
}
}
public override void Shutdown()
{
base.Shutdown();
UnregisterFromServer();
}
}
}