Skip to content
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
57 changes: 26 additions & 31 deletions Content.Client/_CE/MagicVision/CEClientMagicVisionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public sealed partial class CEClientMagicVisionSystem : EntitySystem
[Dependency] private IGameTiming _timing = default!;

private CEMagicVisionOverlay? _overlay;
private CEMagicVisionNoirOverlay? _noirOverlay;

private readonly SoundSpecifier _startSound = new SoundPathSpecifier(new ResPath("/Audio/Effects/eye_open.ogg"));
private readonly SoundSpecifier _endSound = new SoundPathSpecifier(new ResPath("/Audio/Effects/eye_close.ogg"));
Expand All @@ -28,6 +27,7 @@ public override void Initialize()

SubscribeLocalEvent<CEMagicVisionComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<CEMagicVisionComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<CEMagicVisionComponent, AfterAutoHandleStateEvent>(OnHandleState);

SubscribeLocalEvent<LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<LocalPlayerDetachedEvent>(OnPlayerDetached);
Expand All @@ -38,66 +38,61 @@ private void OnStartup(Entity<CEMagicVisionComponent> ent, ref ComponentStartup
if (ent.Owner != _player.LocalEntity)
return;

ApplyOverlay(ent);
SyncOverlay(ent);
_audio.PlayGlobal(_startSound, ent.Owner);
}

private void OnShutdown(Entity<CEMagicVisionComponent> ent, ref ComponentShutdown args)
{
if (ent.Owner != _player.LocalEntity)
return;

RemoveOverlay(ent);
RemoveOverlay();
_audio.PlayGlobal(_endSound, ent.Owner);
}

private void OnHandleState(Entity<CEMagicVisionComponent> ent, ref AfterAutoHandleStateEvent args)
{
if (ent.Owner != _player.LocalEntity)
return;

SyncOverlay(ent);
}

private void OnPlayerAttached(LocalPlayerAttachedEvent args)
{
if (TryComp<CEMagicVisionComponent>(args.Entity, out var comp))
ApplyOverlay((args.Entity, comp));
SyncOverlay((args.Entity, comp));
}

private void OnPlayerDetached(LocalPlayerDetachedEvent args)
{
RemoveOverlay(null);
RemoveOverlay();
}

private void ApplyOverlay(Entity<CEMagicVisionComponent> ent)
private void SyncOverlay(Entity<CEMagicVisionComponent> ent)
{
if (!ent.Comp.ShowOverlay)
{
RemoveOverlay();
return;
}

if (_overlay == null)
{
_overlay = new CEMagicVisionOverlay();
_overlayMan.AddOverlay(_overlay);
}

_overlay.StartOverlay = _timing.CurTime;

// TEMP: noir/color-correction overlay disabled, re-enable this block to restore it
// if (_noirOverlay == null)
// {
// _noirOverlay = new CEMagicVisionNoirOverlay();
// _overlayMan.AddOverlay(_noirOverlay);
// }

_audio.PlayGlobal(_startSound, ent.Owner);
}

private void RemoveOverlay(Entity<CEMagicVisionComponent>? ent)
private void RemoveOverlay()
{
if (_overlay == null && _noirOverlay == null)
if (_overlay == null)
return;

if (_overlay != null)
{
_overlayMan.RemoveOverlay(_overlay);
_overlay = null;
}

if (_noirOverlay != null)
{
_overlayMan.RemoveOverlay(_noirOverlay);
_noirOverlay = null;
}

if (ent is { } target)
_audio.PlayGlobal(_endSound, target.Owner);
_overlayMan.RemoveOverlay(_overlay);
_overlay = null;
}
}
35 changes: 0 additions & 35 deletions Content.Client/_CE/MagicVision/CEMagicVisionNoirOverlay.cs

This file was deleted.

7 changes: 0 additions & 7 deletions Content.Client/_CE/Satiation/CEClientSatiationSystem.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ private void OnAltarExamined(Entity<CEInfusionAltarComponent> ent, ref ExaminedE
var instabilityPercent = (int)MathF.Round(altar.Instability / altar.MaxInstability * 100f);
args.PushMarkup(Loc.GetString("ce-infusion-altar-examine-instability", ("percent", instabilityPercent)));

var stabilizationPercent = (int)MathF.Round((1f - altar.StabilizerFactor) * 100f);
args.PushMarkup(Loc.GetString("ce-infusion-altar-examine-stabilizers", ("percent", stabilizationPercent)));

if (altar.AttemptingRecipe is { } recipeId
&& _proto.TryIndex(recipeId, out var recipe)
&& recipe.RitualDuration > TimeSpan.Zero)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ public override void Update(float frameTime)
var query = EntityQueryEnumerator<CEInfusionAltarComponent>();
while (query.MoveNext(out var uid, out var altar))
{
if (_timing.CurTime >= altar.NextStabilizerScan)
{
altar.NextStabilizerScan = _timing.CurTime + altar.StabilizerScanInterval;
ScanStabilizers((uid, altar));
}

if (_timing.CurTime < altar.NextCheckTime)
continue;
altar.NextCheckTime = _timing.CurTime + altar.CheckInterval;
Expand Down Expand Up @@ -96,14 +90,14 @@ private void TickAltar(Entity<CEInfusionAltarComponent> ent, float dt)
// as broken conditions, except progress resets instead of pausing (there's no
// attempt to resume).
altar.Instability = MathF.Min(altar.MaxInstability,
altar.Instability + altar.BrokenConditionInstabilityRate * altar.StabilizerFactor * dt);
altar.Instability + altar.BrokenConditionInstabilityRate * dt);
altar.RitualProgress = TimeSpan.Zero;
}
else if (essenceSatisfied && pedestalsSatisfied)
{
altar.RitualProgress += TimeSpan.FromSeconds(dt);
altar.Instability = MathF.Min(altar.MaxInstability,
altar.Instability + recipe.Instability * altar.StabilizerFactor * dt);
altar.Instability + recipe.Instability * dt);

if (altar.RitualProgress >= recipe.RitualDuration)
{
Expand All @@ -117,7 +111,7 @@ private void TickAltar(Entity<CEInfusionAltarComponent> ent, float dt)
{
// Conditions currently broken - progress is paused (not reset) until fixed.
altar.Instability = MathF.Min(altar.MaxInstability,
altar.Instability + altar.BrokenConditionInstabilityRate * altar.StabilizerFactor * dt);
altar.Instability + altar.BrokenConditionInstabilityRate * dt);
}
}

Expand Down

This file was deleted.

45 changes: 38 additions & 7 deletions Content.Server/_CE/MagicVision/CEMagicVisionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace Content.Server._CE.MagicVision;
/// <summary>
/// Grants entities magic vision (the <see cref="CEMagicVisionComponent"/> marker, which drives the
/// visibility mask and the client-side overlay) based on however many sources currently want them to
/// have it - clothing (<see cref="CEMagicVisionClothingComponent"/>), and potentially skills or other
/// have it - clothing (<see cref="CEMagicVisionClothingComponent"/>), innate sources
/// (<see cref="CEPermanentMagicVisionComponent"/>, e.g. ghosts), and potentially skills or other
/// sources in the future, all decided fresh each time via <see cref="CECheckMagicVisionEvent"/>. This
/// is entirely server-authoritative: the component is networked and drives PVS filtering, so the
/// client only ever mirrors it from replicated state and never predicts it.
Expand All @@ -28,6 +29,10 @@ public override void Initialize()
SubscribeLocalEvent<CEMagicVisionClothingComponent, InventoryRelayedEvent<CECheckMagicVisionEvent>>(OnClothingCheckVision);
SubscribeLocalEvent<CEMagicVisionClothingComponent, GotEquippedEvent>(OnClothingEquipped);
SubscribeLocalEvent<CEMagicVisionClothingComponent, GotUnequippedEvent>(OnClothingUnequipped);

SubscribeLocalEvent<CEPermanentMagicVisionComponent, CECheckMagicVisionEvent>(OnPermanentCheckVision);
SubscribeLocalEvent<CEPermanentMagicVisionComponent, ComponentInit>(OnPermanentInit);
SubscribeLocalEvent<CEPermanentMagicVisionComponent, ComponentShutdown>(OnPermanentShutdown);
}

private void OnGetVisMask(Entity<CEMagicVisionComponent> ent, ref GetVisMaskEvent args)
Expand Down Expand Up @@ -56,6 +61,22 @@ private void OnClothingUnequipped(Entity<CEMagicVisionClothingComponent> ent, re
RefreshMagicVision(args.EquipTarget);
}

private void OnPermanentCheckVision(Entity<CEPermanentMagicVisionComponent> ent, ref CECheckMagicVisionEvent args)
{
// Innate vision isn't a worn artifact straining the wearer, so no overlay.
args.GrantVision(showOverlay: false);
}

private void OnPermanentInit(Entity<CEPermanentMagicVisionComponent> ent, ref ComponentInit args)
{
RefreshMagicVision(ent.Owner);
}

private void OnPermanentShutdown(Entity<CEPermanentMagicVisionComponent> ent, ref ComponentShutdown args)
{
RefreshMagicVision(ent.Owner);
}

/// <summary>
/// Recomputes whether <see cref="uid"/> currently has magic vision by asking every subscribed
/// source via <see cref="CECheckMagicVisionEvent"/>, then adds or removes
Expand All @@ -74,14 +95,24 @@ public void RefreshMagicVision(EntityUid uid)
var ev = new CECheckMagicVisionEvent();
RaiseLocalEvent(uid, ev);

if (ev.HasVision == HasComp<CEMagicVisionComponent>(uid))
if (!ev.HasVision)
{
if (RemComp<CEMagicVisionComponent>(uid))
_eye.RefreshVisibilityMask(uid);

return;
}

var isNew = !HasComp<CEMagicVisionComponent>(uid);
var comp = EnsureComp<CEMagicVisionComponent>(uid);

if (ev.HasVision)
EnsureComp<CEMagicVisionComponent>(uid);
else
RemComp<CEMagicVisionComponent>(uid);
if (isNew)
_eye.RefreshVisibilityMask(uid);

_eye.RefreshVisibilityMask(uid);
if (comp.ShowOverlay != ev.ShowOverlay)
{
comp.ShowOverlay = ev.ShowOverlay;
Dirty(uid, comp);
}
}
}
34 changes: 0 additions & 34 deletions Content.Server/_CE/Satiation/CESatiationSystem.cs

This file was deleted.

Loading
Loading