Split Respirator into ThermalRegulator and Respirator and ECSes both (#5603)

This commit is contained in:
mirrorcult
2021-11-28 19:25:42 -07:00
committed by GitHub
parent 9075cf6163
commit fc4a950257
19 changed files with 415 additions and 371 deletions

View File

@@ -0,0 +1,62 @@
using Content.Server.UserInterface;
using Content.Shared.Body.Components;
using Content.Shared.Interaction;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.ViewVariables;
namespace Content.Server.Body.Components
{
[RegisterComponent]
[ComponentReference(typeof(IActivate))]
[ComponentReference(typeof(SharedBodyScannerComponent))]
public class BodyScannerComponent : SharedBodyScannerComponent, IActivate
{
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(BodyScannerUiKey.Key);
void IActivate.Activate(ActivateEventArgs eventArgs)
{
if (!eventArgs.User.TryGetComponent(out ActorComponent? actor))
{
return;
}
var session = actor.PlayerSession;
if (session.AttachedEntity == null)
{
return;
}
if (session.AttachedEntity.TryGetComponent(out SharedBodyComponent? body))
{
var state = InterfaceState(body);
UserInterface?.SetState(state);
}
UserInterface?.Open(session);
}
protected override void Initialize()
{
base.Initialize();
Owner.EnsureComponentWarn<ServerUserInterfaceComponent>();
if (UserInterface != null)
{
UserInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
}
}
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage serverMsg) { }
/// <summary>
/// Copy BodyTemplate and BodyPart data into a common data class that the client can read.
/// </summary>
private BodyScannerUIState InterfaceState(SharedBodyComponent body)
{
return new(body.Owner.Uid);
}
}
}