Skip to content

Commit

Permalink
hoi
Browse files Browse the repository at this point in the history
  • Loading branch information
notquitehadouken committed Sep 19, 2024
1 parent e80b855 commit 59124da
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
6 changes: 5 additions & 1 deletion Content.Client/TrueBlindness/TrueBlindnessOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ protected override bool BeforeDraw(in OverlayDrawArgs args)

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture is null)
return;

var playerEntity = _playerManager.LocalSession?.AttachedEntity;

if (playerEntity == null)
Expand All @@ -68,7 +71,8 @@ protected override void Draw(in OverlayDrawArgs args)
_stencilShader.SetParameter("Zoom", content.Zoom.X);
}

_greyscaleShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);
_stencilShader.SetParameter("CircleRadius", 22.5f);
_greyscaleShader.SetParameter("SCREEN_TEXTURE", ScreenTexture);

var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
Expand Down
28 changes: 14 additions & 14 deletions Content.Client/TrueBlindness/TrueBlindnessSystem.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using Content.Shared.Inventory;
using Content.Shared.Physics;
using Content.Shared.TrueBlindness;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Physics;
using Robust.Client.Player;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
Expand All @@ -23,6 +21,7 @@ public sealed class TrueBlindnessSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly PhysicsSystem _physics = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
Expand All @@ -31,6 +30,8 @@ public sealed class TrueBlindnessSystem : EntitySystem

private TrueBlindnessOverlay _overlay = default!;

private const float DefaultVisibleRange = 1.5f;

public override void Initialize()
{
base.Initialize();
Expand Down Expand Up @@ -77,17 +78,11 @@ public bool CreateGhost(Entity<TrueBlindnessVisibleComponent> uid,
ghostSprite.CopyFrom(sprite);
if (applyShader)
ghostSprite.PostShader = _shader;
ghostSprite.DrawDepth += (int)DrawDepth.Overlays + 1; // Lol.
ghostSprite.DrawDepth += (int)DrawDepth.Overlays * 2; // Lol.
ghostEntity = ghost;
return true;
}

public bool CreatePlayerGhost(EntityUid playerUid, [NotNullWhen(true)] out EntityUid? ghostEntity)
{
EnsureComp(playerUid, out TrueBlindnessVisibleComponent trueBlindnessVisible);
return CreateGhost((playerUid, trueBlindnessVisible), out ghostEntity, false);
}

public override void Update(float frameTime)
{
if (!_timing.IsFirstTimePredicted)
Expand All @@ -113,9 +108,16 @@ public override void Update(float frameTime)

_overlay.SetEnabled(true);

CreatePlayerGhost(player.Value, out _);
var visibleRange = DefaultVisibleRange;

foreach (var uid in _lookup.GetEntitiesInRange(player.Value, 1.5f, LookupFlags.Uncontained))
foreach (var entityUid in _inventory.GetHandOrInventoryEntities(player.Value, SlotFlags.PREVENTEQUIP))
{
if (TryComp(entityUid, out TrueBlindnessRangeExtendComponent? rangeExtend) &&
rangeExtend.Range > visibleRange)
visibleRange = rangeExtend.Range;
}

foreach (var uid in _lookup.GetEntitiesInRange(player.Value, visibleRange / 2, LookupFlags.Uncontained))
{
if (HasComp(uid, typeof(TrueBlindnessGhostComponent)))
{
Expand All @@ -132,8 +134,6 @@ public override void Update(float frameTime)
CreateGhost((uid, visible), out _);
}

CreatePlayerGhost(player.Value, out _);


var query = EntityQueryEnumerator<TrueBlindnessGhostComponent>();

Expand Down
11 changes: 11 additions & 0 deletions Content.Shared/TrueBlindness/TrueBlindnessRangeExtendComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Content.Shared.TrueBlindness;

[RegisterComponent]
public sealed partial class TrueBlindnessRangeExtendComponent : Component
{
/// <summary>
/// How far you can see when holding this.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float Range = 1.5f;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@
Blunt: 3
- type: UseDelay
delay: 1
- type: TrueBlindnessRangeExtend
range: 3

0 comments on commit 59124da

Please sign in to comment.