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

revenant refactor #34620

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions Content.Client/Revenant/Components/RevenantVisualsComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Robust.Client.Graphics;

namespace Content.Client.Revenant.Components;

[RegisterComponent]
public sealed partial class RevenantVisualsComponent : Component
{
[ViewVariables]
public RSI.StateId State = "idle";

[ViewVariables]
public RSI.StateId CorporealState = "active";

[ViewVariables]
public RSI.StateId StunnedState = "stunned";

[ViewVariables]
public RSI.StateId HarvestingState = "harvesting";
}
8 changes: 0 additions & 8 deletions Content.Client/Revenant/CorporealSystem.cs

This file was deleted.

53 changes: 0 additions & 53 deletions Content.Client/Revenant/RevenantSystem.cs

This file was deleted.

5 changes: 5 additions & 0 deletions Content.Client/Revenant/Systems/CorporealSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Content.Shared.Revenant.Systems;

namespace Content.Client.Revenant.Systems;

public sealed class CorporealSystem : SharedCorporealSystem;
5 changes: 5 additions & 0 deletions Content.Client/Revenant/Systems/EssenceSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Content.Shared.Revenant.Systems;

namespace Content.Client.Revenant.Systems;

public sealed class EssenceSystem : SharedEssenceSystem;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Content.Shared.Revenant.Components;
using Content.Shared.Revenant.EntitySystems;
using Content.Shared.Revenant.Systems;
using Robust.Client.GameObjects;

namespace Content.Client.Revenant;
namespace Content.Client.Revenant.Systems;

public sealed class RevenantOverloadedLightsSystem : SharedRevenantOverloadedLightsSystem
{
Expand All @@ -25,38 +25,37 @@ public override void Update(float frameTime)
while (enumerator.MoveNext(out var uid, out var comp, out var light))
{
//this looks cool :HECK:
_lights.SetEnergy(uid, 2f * Math.Abs((float) Math.Sin(0.25 * Math.PI * comp.Accumulator)), light);
_lights.SetEnergy(uid, 2f * Math.Abs((float) Math.Sin(0.25 * Math.PI * comp.NextZapTime.TotalSeconds)), light);
}
}

private void OnStartup(EntityUid uid, RevenantOverloadedLightsComponent component, ComponentStartup args)
private void OnStartup(Entity<RevenantOverloadedLightsComponent> ent, ref ComponentStartup args)
{
var light = _lights.EnsureLight(uid);
component.OriginalEnergy = light.Energy;
component.OriginalEnabled = light.Enabled;
var light = _lights.EnsureLight(ent);
ent.Comp.OriginalEnergy = light.Energy;
ent.Comp.OriginalEnabled = light.Enabled;

_lights.SetEnabled(uid, component.OriginalEnabled, light);
Dirty(uid, light);
_lights.SetEnabled(ent, ent.Comp.OriginalEnabled, light);
Dirty(ent, light);
}

private void OnShutdown(EntityUid uid, RevenantOverloadedLightsComponent component, ComponentShutdown args)
private void OnShutdown(Entity<RevenantOverloadedLightsComponent> ent, ref ComponentShutdown args)
{
if (!_lights.TryGetLight(uid, out var light))
if (!_lights.TryGetLight(ent, out var light))
return;

if (component.OriginalEnergy == null)
if (ent.Comp.OriginalEnergy is not { } originalEnergy)
{
RemComp(uid, light);
RemComp(ent, light);
return;
}

_lights.SetEnergy(uid, component.OriginalEnergy.Value, light);
_lights.SetEnabled(uid, component.OriginalEnabled, light);
Dirty(uid, light);
_lights.SetEnergy(ent, originalEnergy, light);
_lights.SetEnabled(ent, ent.Comp.OriginalEnabled, light);
Dirty(ent, light);
}

protected override void OnZap(Entity<RevenantOverloadedLightsComponent> component)
{

}
}
28 changes: 28 additions & 0 deletions Content.Client/Revenant/Systems/RevenantSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Content.Client.Alerts;
using Content.Shared.Revenant;
using Content.Shared.Revenant.Components;
using Content.Shared.Revenant.Systems;

namespace Content.Client.Revenant.Systems;

public sealed class RevenantSystem : SharedRevenantSystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RevenantComponent, UpdateAlertSpriteEvent>(OnUpdateAlert);
}

private static void OnUpdateAlert(Entity<RevenantComponent> ent, ref UpdateAlertSpriteEvent args)
{
if (args.Alert.ID != ent.Comp.EssenceAlert)
return;

var sprite = args.SpriteViewEnt.Comp;
var essence = Math.Clamp(ent.Comp.Essence.Int(), 0, 999);
sprite.LayerSetState(RevenantVisualLayers.Digit1, $"{essence / 100 % 10}");
sprite.LayerSetState(RevenantVisualLayers.Digit2, $"{essence / 10 % 10}");
sprite.LayerSetState(RevenantVisualLayers.Digit3, $"{essence % 10}");
}
}
31 changes: 31 additions & 0 deletions Content.Client/Revenant/Systems/RevenantVisualsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Content.Client.Revenant.Components;
using Content.Shared.Revenant;
using Robust.Client.GameObjects;

namespace Content.Client.Revenant.Systems;

public sealed class RevenantVisualsSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RevenantVisualsComponent, AppearanceChangeEvent>(OnAppearanceChange);
}

private void OnAppearanceChange(Entity<RevenantVisualsComponent> ent, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;

if (_appearance.TryGetData<bool>(ent, RevenantVisuals.Harvesting, out var harvesting, args.Component) &&
harvesting)
args.Sprite.LayerSetState(0, ent.Comp.HarvestingState);
else if (_appearance.TryGetData<bool>(ent, RevenantVisuals.Stunned, out var stunned, args.Component) && stunned)
args.Sprite.LayerSetState(0, ent.Comp.StunnedState);
else if (_appearance.TryGetData<bool>(ent, RevenantVisuals.Corporeal, out var corporeal, args.Component))
args.Sprite.LayerSetState(0, corporeal ? ent.Comp.CorporealState : ent.Comp.State);
}
}
Loading
Loading