diff --git a/Content.Client/TrueBlindness/TrueBlindnessOverlay.cs b/Content.Client/TrueBlindness/TrueBlindnessOverlay.cs index 56e15697c49d05..452dce5745911f 100644 --- a/Content.Client/TrueBlindness/TrueBlindnessOverlay.cs +++ b/Content.Client/TrueBlindness/TrueBlindnessOverlay.cs @@ -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) @@ -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; diff --git a/Content.Client/TrueBlindness/TrueBlindnessSystem.cs b/Content.Client/TrueBlindness/TrueBlindnessSystem.cs index abcb943c01f51c..2ed9f02dc0fa4b 100644 --- a/Content.Client/TrueBlindness/TrueBlindnessSystem.cs +++ b/Content.Client/TrueBlindness/TrueBlindnessSystem.cs @@ -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; @@ -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!; @@ -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(); @@ -77,17 +78,11 @@ public bool CreateGhost(Entity 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) @@ -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))) { @@ -132,8 +134,6 @@ public override void Update(float frameTime) CreateGhost((uid, visible), out _); } - CreatePlayerGhost(player.Value, out _); - var query = EntityQueryEnumerator(); diff --git a/Content.Client/TrueBlindness/TrueBlindnessGhostComponent.cs b/Content.Shared/TrueBlindness/TrueBlindnessGhostComponent.cs similarity index 100% rename from Content.Client/TrueBlindness/TrueBlindnessGhostComponent.cs rename to Content.Shared/TrueBlindness/TrueBlindnessGhostComponent.cs diff --git a/Content.Shared/TrueBlindness/TrueBlindnessRangeExtendComponent.cs b/Content.Shared/TrueBlindness/TrueBlindnessRangeExtendComponent.cs new file mode 100644 index 00000000000000..d0616f8322a9fe --- /dev/null +++ b/Content.Shared/TrueBlindness/TrueBlindnessRangeExtendComponent.cs @@ -0,0 +1,11 @@ +namespace Content.Shared.TrueBlindness; + +[RegisterComponent] +public sealed partial class TrueBlindnessRangeExtendComponent : Component +{ + /// + /// How far you can see when holding this. + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public float Range = 1.5f; +} diff --git a/Content.Client/TrueBlindness/TrueBlindnessVisibleComponent.cs b/Content.Shared/TrueBlindness/TrueBlindnessVisibleComponent.cs similarity index 100% rename from Content.Client/TrueBlindness/TrueBlindnessVisibleComponent.cs rename to Content.Shared/TrueBlindness/TrueBlindnessVisibleComponent.cs diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/white_cane.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/white_cane.yml index 997c3771d56a34..efac95d9c0ce29 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/white_cane.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/white_cane.yml @@ -24,4 +24,6 @@ Blunt: 3 - type: UseDelay delay: 1 + - type: TrueBlindnessRangeExtend + range: 3