Fix overlay bugs (#11406)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Content.Shared.Drugs;
|
using Content.Shared.Drugs;
|
||||||
using Content.Shared.StatusEffect;
|
using Content.Shared.StatusEffect;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
@@ -53,6 +54,12 @@ public sealed class RainbowOverlay : Overlay
|
|||||||
|
|
||||||
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
||||||
{
|
{
|
||||||
|
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (args.Viewport.Eye != eyeComp.Eye)
|
||||||
|
return false;
|
||||||
|
|
||||||
return EffectScale > 0;
|
return EffectScale > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Shared.Drunk;
|
using Content.Shared.Drunk;
|
||||||
using Content.Shared.StatusEffect;
|
using Content.Shared.StatusEffect;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
@@ -53,6 +54,12 @@ public sealed class DrunkOverlay : Overlay
|
|||||||
|
|
||||||
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
||||||
{
|
{
|
||||||
|
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (args.Viewport.Eye != eyeComp.Eye)
|
||||||
|
return false;
|
||||||
|
|
||||||
_visualScale = BoozePowerToVisual(CurrentBoozePower);
|
_visualScale = BoozePowerToVisual(CurrentBoozePower);
|
||||||
return _visualScale > 0;
|
return _visualScale > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
@@ -29,6 +30,12 @@ namespace Content.Client.Eye.Blinding
|
|||||||
}
|
}
|
||||||
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
||||||
{
|
{
|
||||||
|
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (args.Viewport.Eye != eyeComp.Eye)
|
||||||
|
return false;
|
||||||
|
|
||||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||||
|
|
||||||
if (playerEntity == null)
|
if (playerEntity == null)
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
@@ -25,6 +26,12 @@ namespace Content.Client.Eye.Blinding
|
|||||||
|
|
||||||
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
protected override bool BeforeDraw(in OverlayDrawArgs args)
|
||||||
{
|
{
|
||||||
|
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (args.Viewport.Eye != eyeComp.Eye)
|
||||||
|
return false;
|
||||||
|
|
||||||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
|
||||||
|
|
||||||
if (playerEntity == null)
|
if (playerEntity == null)
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using Content.Client.Viewport;
|
using Content.Client.Viewport;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.State;
|
using Robust.Client.State;
|
||||||
|
using Robust.Client.Player;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
@@ -16,6 +18,8 @@ namespace Content.Client.Flash
|
|||||||
[Dependency] private readonly IClyde _displayManager = default!;
|
[Dependency] private readonly IClyde _displayManager = default!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
[Dependency] private readonly IStateManager _stateManager = default!;
|
[Dependency] private readonly IStateManager _stateManager = default!;
|
||||||
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
|
|
||||||
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
||||||
private readonly ShaderInstance _shader;
|
private readonly ShaderInstance _shader;
|
||||||
@@ -46,6 +50,12 @@ namespace Content.Client.Flash
|
|||||||
|
|
||||||
protected override void Draw(in OverlayDrawArgs args)
|
protected override void Draw(in OverlayDrawArgs args)
|
||||||
{
|
{
|
||||||
|
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.Viewport.Eye != eyeComp.Eye)
|
||||||
|
return;
|
||||||
|
|
||||||
var percentComplete = (float) ((_gameTiming.CurTime.TotalSeconds - _startTime) / _lastsFor);
|
var percentComplete = (float) ((_gameTiming.CurTime.TotalSeconds - _startTime) / _lastsFor);
|
||||||
if (percentComplete >= 1.0f)
|
if (percentComplete >= 1.0f)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using Content.Shared.MobState;
|
using Content.Shared.MobState;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
|
using Robust.Client.Player;
|
||||||
using Robust.Shared.Enums;
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
@@ -10,6 +12,8 @@ public sealed class DamageOverlay : Overlay
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
|
|
||||||
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
||||||
|
|
||||||
@@ -53,6 +57,12 @@ public sealed class DamageOverlay : Overlay
|
|||||||
|
|
||||||
protected override void Draw(in OverlayDrawArgs args)
|
protected override void Draw(in OverlayDrawArgs args)
|
||||||
{
|
{
|
||||||
|
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.Viewport.Eye != eyeComp.Eye)
|
||||||
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here's the rundown:
|
* Here's the rundown:
|
||||||
* 1. There's lerping for each level so the transitions are smooth.
|
* 1. There's lerping for each level so the transitions are smooth.
|
||||||
|
|||||||
@@ -44,9 +44,12 @@ namespace Content.Client.Radiation
|
|||||||
|
|
||||||
foreach ((var shd, var instance) in _pulses.Values)
|
foreach ((var shd, var instance) in _pulses.Values)
|
||||||
{
|
{
|
||||||
|
if (instance.CurrentMapCoords.MapId != args.MapId)
|
||||||
|
continue;
|
||||||
|
|
||||||
// To be clear, this needs to use "inside-viewport" pixels.
|
// To be clear, this needs to use "inside-viewport" pixels.
|
||||||
// In other words, specifically NOT IViewportControl.WorldToScreen (which uses outer coordinates).
|
// In other words, specifically NOT IViewportControl.WorldToScreen (which uses outer coordinates).
|
||||||
var tempCoords = viewport.WorldToLocal(instance.CurrentMapCoords);
|
var tempCoords = viewport.WorldToLocal(instance.CurrentMapCoords.Position);
|
||||||
tempCoords.Y = viewport.Size.Y - tempCoords.Y;
|
tempCoords.Y = viewport.Size.Y - tempCoords.Y;
|
||||||
shd?.SetParameter("renderScale", viewport.RenderScale);
|
shd?.SetParameter("renderScale", viewport.RenderScale);
|
||||||
shd?.SetParameter("positionInput", tempCoords);
|
shd?.SetParameter("positionInput", tempCoords);
|
||||||
@@ -59,7 +62,7 @@ namespace Content.Client.Radiation
|
|||||||
shd?.SetParameter("SCREEN_TEXTURE", viewport.RenderTarget.Texture);
|
shd?.SetParameter("SCREEN_TEXTURE", viewport.RenderTarget.Texture);
|
||||||
|
|
||||||
worldHandle.UseShader(shd);
|
worldHandle.UseShader(shd);
|
||||||
worldHandle.DrawRect(Box2.CenteredAround(instance.CurrentMapCoords, new Vector2(instance.Range, instance.Range) * 2f), Color.White);
|
worldHandle.DrawRect(Box2.CenteredAround(instance.CurrentMapCoords.Position, new Vector2(instance.Range, instance.Range) * 2f), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
worldHandle.UseShader(null);
|
worldHandle.UseShader(null);
|
||||||
@@ -88,7 +91,7 @@ namespace Content.Client.Radiation
|
|||||||
(
|
(
|
||||||
_baseShader.Duplicate(),
|
_baseShader.Duplicate(),
|
||||||
new RadiationShaderInstance(
|
new RadiationShaderInstance(
|
||||||
_entityManager.GetComponent<TransformComponent>(pulseEntity).MapPosition.Position,
|
_entityManager.GetComponent<TransformComponent>(pulseEntity).MapPosition,
|
||||||
pulse.VisualRange,
|
pulse.VisualRange,
|
||||||
pulse.StartTime,
|
pulse.StartTime,
|
||||||
pulse.VisualDuration
|
pulse.VisualDuration
|
||||||
@@ -106,7 +109,7 @@ namespace Content.Client.Radiation
|
|||||||
_entityManager.TryGetComponent<RadiationPulseComponent?>(pulseEntity, out var pulse))
|
_entityManager.TryGetComponent<RadiationPulseComponent?>(pulseEntity, out var pulse))
|
||||||
{
|
{
|
||||||
var shaderInstance = _pulses[pulseEntity];
|
var shaderInstance = _pulses[pulseEntity];
|
||||||
shaderInstance.instance.CurrentMapCoords = _entityManager.GetComponent<TransformComponent>(pulseEntity).MapPosition.Position;
|
shaderInstance.instance.CurrentMapCoords = _entityManager.GetComponent<TransformComponent>(pulseEntity).MapPosition;
|
||||||
shaderInstance.instance.Range = pulse.VisualRange;
|
shaderInstance.instance.Range = pulse.VisualRange;
|
||||||
} else {
|
} else {
|
||||||
_pulses[pulseEntity].shd.Dispose();
|
_pulses[pulseEntity].shd.Dispose();
|
||||||
@@ -121,9 +124,9 @@ namespace Content.Client.Radiation
|
|||||||
return _entityManager.GetComponent<TransformComponent>(pulseEntity).MapID == currentEyeLoc.MapId && _entityManager.GetComponent<TransformComponent>(pulseEntity).Coordinates.InRange(_entityManager, EntityCoordinates.FromMap(_entityManager, _entityManager.GetComponent<TransformComponent>(pulseEntity).ParentUid, currentEyeLoc), MaxDist);
|
return _entityManager.GetComponent<TransformComponent>(pulseEntity).MapID == currentEyeLoc.MapId && _entityManager.GetComponent<TransformComponent>(pulseEntity).Coordinates.InRange(_entityManager, EntityCoordinates.FromMap(_entityManager, _entityManager.GetComponent<TransformComponent>(pulseEntity).ParentUid, currentEyeLoc), MaxDist);
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed record RadiationShaderInstance(Vector2 CurrentMapCoords, float Range, TimeSpan Start, float Duration)
|
private sealed record RadiationShaderInstance(MapCoordinates CurrentMapCoords, float Range, TimeSpan Start, float Duration)
|
||||||
{
|
{
|
||||||
public Vector2 CurrentMapCoords = CurrentMapCoords;
|
public MapCoordinates CurrentMapCoords = CurrentMapCoords;
|
||||||
public float Range = Range;
|
public float Range = Range;
|
||||||
public TimeSpan Start = Start;
|
public TimeSpan Start = Start;
|
||||||
public float Duration = Duration;
|
public float Duration = Duration;
|
||||||
|
|||||||
Reference in New Issue
Block a user