Re-organize all projects (#4166)
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.Graphics.Overlays
|
||||
{
|
||||
public class CircleMaskOverlay : Overlay
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
private readonly ShaderInstance _shader;
|
||||
|
||||
public CircleMaskOverlay()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_shader = _prototypeManager.Index<ShaderPrototype>("CircleMask").Instance();
|
||||
}
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
{
|
||||
if (!CritOverlay.LocalPlayerHasState(_playerManager, false, true))
|
||||
return;
|
||||
|
||||
|
||||
var worldHandle = args.WorldHandle;
|
||||
worldHandle.UseShader(_shader);
|
||||
var viewport = _eyeManager.GetWorldViewport();
|
||||
worldHandle.DrawRect(viewport, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#nullable enable
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using System;
|
||||
|
||||
namespace Content.Client.Graphics.Overlays
|
||||
{
|
||||
public class ColoredScreenBorderOverlay : Overlay
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
private readonly ShaderInstance _shader;
|
||||
|
||||
public ColoredScreenBorderOverlay()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_shader = _prototypeManager.Index<ShaderPrototype>("ColoredScreenBorder").Instance();
|
||||
}
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
{
|
||||
var worldHandle = args.WorldHandle;
|
||||
worldHandle.UseShader(_shader);
|
||||
var viewport = _eyeManager.GetWorldViewport();
|
||||
worldHandle.DrawRect(viewport, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
using Content.Shared.GameObjects.Components.Mobs.State;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.Graphics.Overlays
|
||||
{
|
||||
public class CritOverlay : Overlay
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
private readonly ShaderInstance _gradientCircleShader;
|
||||
private readonly ShaderInstance? _glowingBorderShader;
|
||||
|
||||
public CritOverlay()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_gradientCircleShader = _prototypeManager.Index<ShaderPrototype>("GradientCircleMask").Instance();
|
||||
}
|
||||
|
||||
public static bool LocalPlayerHasState(IPlayerManager pm, bool critical, bool dead) {
|
||||
var playerEntity = pm.LocalPlayer?.ControlledEntity;
|
||||
|
||||
if (playerEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (playerEntity.TryGetComponent<IMobStateComponent>(out var mobState))
|
||||
{
|
||||
if (critical)
|
||||
if (mobState.IsCritical())
|
||||
return true;
|
||||
if (dead)
|
||||
if (mobState.IsDead())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
{
|
||||
if (!LocalPlayerHasState(_playerManager, true, false))
|
||||
return;
|
||||
|
||||
var worldHandle = args.WorldHandle;
|
||||
var viewport = _eyeManager.GetWorldViewport();
|
||||
worldHandle.UseShader(_gradientCircleShader);
|
||||
worldHandle.DrawRect(viewport, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
using Content.Client.State;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.State;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
namespace Content.Client.Graphics.Overlays
|
||||
{
|
||||
public class FlashOverlay : Overlay
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IClyde _displayManager = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IStateManager _stateManager = default!;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
||||
private readonly ShaderInstance _shader;
|
||||
private double _startTime = -1;
|
||||
private double _lastsFor = 1;
|
||||
private Texture? _screenshotTexture;
|
||||
|
||||
public FlashOverlay()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_shader = _prototypeManager.Index<ShaderPrototype>("FlashedEffect").Instance().Duplicate();
|
||||
}
|
||||
|
||||
public void ReceiveFlash(double duration)
|
||||
{
|
||||
if (_stateManager.CurrentState is IMainViewportState state)
|
||||
{
|
||||
state.Viewport.Viewport.Screenshot(image =>
|
||||
{
|
||||
var rgba32Image = image.CloneAs<Rgba32>(Configuration.Default);
|
||||
_screenshotTexture = _displayManager.LoadTextureFromImage(rgba32Image);
|
||||
});
|
||||
}
|
||||
|
||||
_startTime = _gameTiming.CurTime.TotalSeconds;
|
||||
_lastsFor = duration;
|
||||
}
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
{
|
||||
var percentComplete = (float) ((_gameTiming.CurTime.TotalSeconds - _startTime) / _lastsFor);
|
||||
if (percentComplete >= 1.0f)
|
||||
return;
|
||||
|
||||
var screenSpaceHandle = args.ScreenHandle;
|
||||
screenSpaceHandle.UseShader(_shader);
|
||||
_shader.SetParameter("percentComplete", percentComplete);
|
||||
|
||||
var screenSize = UIBox2.FromDimensions((0, 0), _displayManager.ScreenSize);
|
||||
|
||||
if (_screenshotTexture != null)
|
||||
{
|
||||
screenSpaceHandle.DrawTextureRect(_screenshotTexture, screenSize);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DisposeBehavior()
|
||||
{
|
||||
base.Dispose();
|
||||
_screenshotTexture = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
#nullable enable
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Client.Graphics;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Content.Client.GameObjects.Components.Singularity;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Client.Graphics.Overlays
|
||||
{
|
||||
public class SingularityOverlay : Overlay
|
||||
{
|
||||
[Dependency] private readonly IComponentManager _componentManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IClyde _displayManager = default!;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
public override bool RequestScreenTexture => true;
|
||||
|
||||
private readonly ShaderInstance _shader;
|
||||
|
||||
Dictionary<EntityUid, SingularityShaderInstance> _singularities = new Dictionary<EntityUid, SingularityShaderInstance>();
|
||||
|
||||
public SingularityOverlay()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_shader = _prototypeManager.Index<ShaderPrototype>("Singularity").Instance().Duplicate();
|
||||
}
|
||||
|
||||
public override bool OverwriteTargetFrameBuffer()
|
||||
{
|
||||
return _singularities.Count() > 0;
|
||||
}
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
{
|
||||
SingularityQuery(args.Viewport.Eye);
|
||||
|
||||
var viewportWB = args.WorldBounds;
|
||||
// Has to be correctly handled because of the way intensity/falloff transform works so just do it.
|
||||
_shader?.SetParameter("renderScale", args.Viewport.RenderScale);
|
||||
foreach (SingularityShaderInstance instance in _singularities.Values)
|
||||
{
|
||||
// To be clear, this needs to use "inside-viewport" pixels.
|
||||
// In other words, specifically NOT IViewportControl.WorldToScreen (which uses outer coordinates).
|
||||
var tempCoords = args.Viewport.WorldToLocal(instance.CurrentMapCoords);
|
||||
tempCoords.Y = args.Viewport.Size.Y - tempCoords.Y;
|
||||
_shader?.SetParameter("positionInput", tempCoords);
|
||||
if (ScreenTexture != null)
|
||||
_shader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);
|
||||
_shader?.SetParameter("intensity", instance.Intensity);
|
||||
_shader?.SetParameter("falloff", instance.Falloff);
|
||||
|
||||
var worldHandle = args.WorldHandle;
|
||||
worldHandle.UseShader(_shader);
|
||||
worldHandle.DrawRect(viewportWB, Color.White);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Queries all singulos on the map and either adds or removes them from the list of rendered singulos based on whether they should be drawn (in range? on the same z-level/map? singulo entity still exists?)
|
||||
private float _maxDist = 15.0f;
|
||||
private void SingularityQuery(IEye? currentEye)
|
||||
{
|
||||
if (currentEye == null)
|
||||
{
|
||||
_singularities.Clear();
|
||||
return;
|
||||
}
|
||||
var currentEyeLoc = currentEye.Position;
|
||||
var currentMap = currentEye.Position.MapId;
|
||||
|
||||
var singuloComponents = _componentManager.EntityQuery<IClientSingularityInstance>();
|
||||
foreach (var singuloInterface in singuloComponents) //Add all singulos that are not added yet but qualify
|
||||
{
|
||||
var singuloComponent = (Component)singuloInterface;
|
||||
var singuloEntity = singuloComponent.Owner;
|
||||
if (!_singularities.Keys.Contains(singuloEntity.Uid) && SinguloQualifies(singuloEntity, currentEyeLoc))
|
||||
{
|
||||
_singularities.Add(singuloEntity.Uid, new SingularityShaderInstance(singuloEntity.Transform.MapPosition.Position, singuloInterface.Intensity, singuloInterface.Falloff));
|
||||
}
|
||||
}
|
||||
|
||||
var activeShaderUids = _singularities.Keys;
|
||||
foreach (var activeSinguloUid in activeShaderUids) //Remove all singulos that are added and no longer qualify
|
||||
{
|
||||
if (_entityManager.TryGetEntity(activeSinguloUid, out IEntity? singuloEntity))
|
||||
{
|
||||
if (!SinguloQualifies(singuloEntity, currentEyeLoc))
|
||||
{
|
||||
_singularities.Remove(activeSinguloUid);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!singuloEntity.TryGetComponent<IClientSingularityInstance>(out var singuloInterface))
|
||||
{
|
||||
_singularities.Remove(activeSinguloUid);
|
||||
}
|
||||
else
|
||||
{
|
||||
var shaderInstance = _singularities[activeSinguloUid];
|
||||
shaderInstance.CurrentMapCoords = singuloEntity.Transform.MapPosition.Position;
|
||||
shaderInstance.Intensity = singuloInterface.Intensity;
|
||||
shaderInstance.Falloff = singuloInterface.Falloff;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_singularities.Remove(activeSinguloUid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private bool SinguloQualifies(IEntity singuloEntity, MapCoordinates currentEyeLoc)
|
||||
{
|
||||
return singuloEntity.Transform.MapID == currentEyeLoc.MapId && singuloEntity.Transform.Coordinates.InRange(_entityManager, EntityCoordinates.FromMap(_entityManager, singuloEntity.Transform.ParentUid, currentEyeLoc), _maxDist);
|
||||
}
|
||||
|
||||
private sealed class SingularityShaderInstance
|
||||
{
|
||||
public Vector2 CurrentMapCoords;
|
||||
public float Intensity;
|
||||
public float Falloff;
|
||||
public SingularityShaderInstance(Vector2 mapCoords, float intensity, float falloff)
|
||||
{
|
||||
CurrentMapCoords = mapCoords;
|
||||
Intensity = intensity;
|
||||
Falloff = falloff;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user