Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the powered examine text fully client predicted #30441

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Content.Client/Power/EntitySystems/PowerReceiverSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Client.Power.Components;
using Content.Client.Power.Components;
using Content.Shared.Power.Components;
using Content.Shared.Power.EntitySystems;
using Content.Shared.Examine;
using Robust.Shared.GameStates;

namespace Content.Client.Power.EntitySystems;
Expand All @@ -10,9 +11,15 @@ public sealed class PowerReceiverSystem : SharedPowerReceiverSystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ApcPowerReceiverComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<ApcPowerReceiverComponent, ComponentHandleState>(OnHandleState);
}

private void OnExamined(Entity<ApcPowerReceiverComponent> ent, ref ExaminedEvent args)
{
args.PushMarkup(GetExamineText(ent.Comp.Powered));
}

private void OnHandleState(EntityUid uid, ApcPowerReceiverComponent component, ref ComponentHandleState args)
{
if (args.Current is not ApcPowerReceiverComponentState state)
Expand Down
16 changes: 5 additions & 11 deletions Content.Server/Power/EntitySystems/PowerReceiverSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public override void Initialize()
_provQuery = GetEntityQuery<ApcPowerProviderComponent>();
}

private void OnExamined(Entity<ApcPowerReceiverComponent> ent, ref ExaminedEvent args)
{
args.PushMarkup(GetExamineText(ent.Comp.Powered));
}

private void OnGetVerbs(EntityUid uid, ApcPowerReceiverComponent component, GetVerbsEvent<Verb> args)
{
if (!_adminManager.HasAdminFlag(args.User, AdminFlags.Admin))
Expand All @@ -61,17 +66,6 @@ private void OnGetVerbs(EntityUid uid, ApcPowerReceiverComponent component, GetV
});
}

///<summary>
///Adds some markup to the examine text of whatever object is using this component to tell you if it's powered or not, even if it doesn't have an icon state to do this for you.
///</summary>
private void OnExamined(EntityUid uid, ApcPowerReceiverComponent component, ExaminedEvent args)
{
args.PushMarkup(Loc.GetString("power-receiver-component-on-examine-main",
("stateText", Loc.GetString( component.Powered
? "power-receiver-component-on-examine-powered"
: "power-receiver-component-on-examine-unpowered"))));
}

private void OnProviderShutdown(EntityUid uid, ApcPowerProviderComponent component, ComponentShutdown args)
{
foreach (var receiver in component.LinkedReceivers)
Expand Down
13 changes: 11 additions & 2 deletions Content.Shared/Power/EntitySystems/SharedPowerReceiverSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
namespace Content.Shared.Power.EntitySystems;
using Content.Shared.Examine;
using Content.Shared.Power.Components;

namespace Content.Shared.Power.EntitySystems;

public abstract class SharedPowerReceiverSystem : EntitySystem
{

protected string GetExamineText(bool powered)
{
return Loc.GetString("power-receiver-component-on-examine-main",
("stateText", Loc.GetString(powered
? "power-receiver-component-on-examine-powered"
: "power-receiver-component-on-examine-unpowered")));
}
}
Loading