-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into LambdaFix
- Loading branch information
Showing
300 changed files
with
6,914 additions
and
1,718 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Content.Client/Chemistry/EntitySystems/FillableOneTimeInjectorSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Content.Client.Chemistry.UI; | ||
using Content.Client.Items; | ||
using Content.Shared.Chemistry.Components; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Client.Chemistry.EntitySystems; | ||
|
||
public sealed class FillableOneTimeInjectorSystem : SharedFillableOneTimeInjectorSystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
Subs.ItemStatus<FillableOneTimeInjectorComponent>(ent => new FillableOneTimeInjectorStatusControl(ent, SolutionContainers)); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
Content.Client/Chemistry/UI/FillableOneTimeInjectorStatusControl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using Content.Client.Message; | ||
using Content.Client.Stylesheets; | ||
using Content.Shared.Chemistry.Components; | ||
using Content.Shared.Chemistry.EntitySystems; | ||
using Content.Shared.FixedPoint; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.Chemistry.UI; | ||
|
||
public sealed class FillableOneTimeInjectorStatusControl : Control | ||
{ | ||
private readonly Entity<FillableOneTimeInjectorComponent> _parent; | ||
private readonly SharedSolutionContainerSystem _solutionContainers; | ||
private readonly RichTextLabel _label; | ||
|
||
private FixedPoint2 PrevVolume; | ||
private FixedPoint2 PrevMaxVolume; | ||
private FixedPoint2 PrevTransferAmount; | ||
private FillableOneTimeInjectorToggleMode PrevToggleStateIndex; | ||
|
||
public FillableOneTimeInjectorStatusControl(Entity<FillableOneTimeInjectorComponent> parent, SharedSolutionContainerSystem solutionContainers) | ||
{ | ||
_parent = parent; | ||
_solutionContainers = solutionContainers; | ||
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } }; | ||
AddChild(_label); | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
|
||
if (!_solutionContainers.TryGetSolution(_parent.Owner, _parent.Comp.SolutionName, out _, out var solution)) | ||
return; | ||
|
||
// only updates the UI if any of the details are different than they previously were | ||
if (PrevVolume == solution.Volume | ||
&& PrevMaxVolume == solution.MaxVolume | ||
&& PrevTransferAmount == _parent.Comp.TransferAmount) | ||
return; | ||
|
||
PrevVolume = solution.Volume; | ||
PrevMaxVolume = solution.MaxVolume; | ||
PrevTransferAmount = _parent.Comp.TransferAmount; | ||
var modeStringLocalized = ""; | ||
|
||
// only updates the UI if any of the details are different than they previously were | ||
if(PrevToggleStateIndex == _parent.Comp.ToggleState) | ||
return; | ||
|
||
PrevToggleStateIndex = _parent.Comp.ToggleState; | ||
|
||
// Update current volume and injector state | ||
modeStringLocalized = Loc.GetString( | ||
_parent.Comp.ToggleState switch | ||
{ | ||
FillableOneTimeInjectorToggleMode.Draw => "injector-draw-text", | ||
FillableOneTimeInjectorToggleMode.Inject => "injector-inject-text", | ||
FillableOneTimeInjectorToggleMode.Spent => "injector-spent-text", | ||
_ => "injector-invalid-injector-toggle-mode" | ||
}); | ||
|
||
if (_parent.Comp.ToggleState != FillableOneTimeInjectorToggleMode.Draw) | ||
{ | ||
_label.SetMarkup( | ||
Loc.GetString( | ||
"onetime-injector-simple-volume-label", | ||
("currentVolume", solution.Volume), | ||
("modeString", modeStringLocalized))); | ||
} | ||
else | ||
{ | ||
_label.SetMarkup( | ||
Loc.GetString( | ||
"injector-volume-label", | ||
("currentVolume", solution.Volume), | ||
("totalVolume", solution.MaxVolume), | ||
("modeString", modeStringLocalized), | ||
("transferVolume", _parent.Comp.TransferAmount))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System.Numerics; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Enums; | ||
|
||
namespace Content.Client.Light; | ||
|
||
/// <summary> | ||
/// This exists just to copy <see cref="BeforeLightTargetOverlay"/> to the light render target | ||
/// </summary> | ||
public sealed class AfterLightTargetOverlay : Overlay | ||
{ | ||
public override OverlaySpace Space => OverlaySpace.BeforeLighting; | ||
|
||
[Dependency] private readonly IOverlayManager _overlay = default!; | ||
|
||
public const int ContentZIndex = LightBlurOverlay.ContentZIndex + 1; | ||
|
||
public AfterLightTargetOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
ZIndex = ContentZIndex; | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
var viewport = args.Viewport; | ||
var worldHandle = args.WorldHandle; | ||
|
||
if (viewport.Eye == null) | ||
return; | ||
|
||
var lightOverlay = _overlay.GetOverlay<BeforeLightTargetOverlay>(); | ||
var bounds = args.WorldBounds; | ||
|
||
// at 1-1 render scale it's mostly fine but at 4x4 it's way too fkn big | ||
var newScale = viewport.RenderScale / 2f; | ||
|
||
var localMatrix = | ||
viewport.LightRenderTarget.GetWorldToLocalMatrix(viewport.Eye, newScale); | ||
var diff = (lightOverlay.EnlargedLightTarget.Size - viewport.LightRenderTarget.Size); | ||
var halfDiff = diff / 2; | ||
|
||
// Pixels -> Metres -> Half distance. | ||
// If we're zoomed in need to enlarge the bounds further. | ||
args.WorldHandle.RenderInRenderTarget(viewport.LightRenderTarget, | ||
() => | ||
{ | ||
// We essentially need to draw the cropped version onto the lightrendertarget. | ||
var subRegion = new UIBox2i(halfDiff.X, | ||
halfDiff.Y, | ||
viewport.LightRenderTarget.Size.X + halfDiff.X, | ||
viewport.LightRenderTarget.Size.Y + halfDiff.Y); | ||
|
||
worldHandle.SetTransform(localMatrix); | ||
worldHandle.DrawTextureRectRegion(lightOverlay.EnlargedLightTarget.Texture, bounds, subRegion: subRegion); | ||
}, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System.Numerics; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Enums; | ||
|
||
namespace Content.Client.Light; | ||
|
||
/// <summary> | ||
/// Handles an enlarged lighting target so content can use large blur radii. | ||
/// </summary> | ||
public sealed class BeforeLightTargetOverlay : Overlay | ||
{ | ||
public override OverlaySpace Space => OverlaySpace.BeforeLighting; | ||
|
||
[Dependency] private readonly IClyde _clyde = default!; | ||
|
||
public IRenderTexture EnlargedLightTarget = default!; | ||
public Box2Rotated EnlargedBounds; | ||
|
||
/// <summary> | ||
/// In metres | ||
/// </summary> | ||
private float _skirting = 1.5f; | ||
|
||
public const int ContentZIndex = -10; | ||
|
||
public BeforeLightTargetOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
ZIndex = ContentZIndex; | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
// Code is weird but I don't think engine should be enlarging the lighting render target arbitrarily either, maybe via cvar? | ||
// The problem is the blur has no knowledge of pixels outside the viewport so with a large enough blur radius you get sampling issues. | ||
var size = args.Viewport.LightRenderTarget.Size + (int) (_skirting * EyeManager.PixelsPerMeter); | ||
EnlargedBounds = args.WorldBounds.Enlarged(_skirting / 2f); | ||
|
||
// This just exists to copy the lightrendertarget and write back to it. | ||
if (EnlargedLightTarget?.Size != size) | ||
{ | ||
EnlargedLightTarget = _clyde | ||
.CreateRenderTarget(size, new RenderTargetFormatParameters(RenderTargetColorFormat.Rgba8Srgb), name: "enlarged-light-copy"); | ||
} | ||
|
||
args.WorldHandle.RenderInRenderTarget(EnlargedLightTarget, | ||
() => | ||
{ | ||
}, _clyde.GetClearColor(args.MapUid)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Robust.Client.Graphics; | ||
|
||
namespace Content.Client.Light.EntitySystems; | ||
|
||
public sealed class PlanetLightSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IOverlayManager _overlayMan = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<GetClearColorEvent>(OnClearColor); | ||
|
||
_overlayMan.AddOverlay(new BeforeLightTargetOverlay()); | ||
_overlayMan.AddOverlay(new RoofOverlay(EntityManager)); | ||
_overlayMan.AddOverlay(new TileEmissionOverlay(EntityManager)); | ||
_overlayMan.AddOverlay(new LightBlurOverlay()); | ||
_overlayMan.AddOverlay(new AfterLightTargetOverlay()); | ||
} | ||
|
||
private void OnClearColor(ref GetClearColorEvent ev) | ||
{ | ||
ev.Color = Color.Transparent; | ||
} | ||
|
||
public override void Shutdown() | ||
{ | ||
base.Shutdown(); | ||
_overlayMan.RemoveOverlay<BeforeLightTargetOverlay>(); | ||
_overlayMan.RemoveOverlay<RoofOverlay>(); | ||
_overlayMan.RemoveOverlay<TileEmissionOverlay>(); | ||
_overlayMan.RemoveOverlay<LightBlurOverlay>(); | ||
_overlayMan.RemoveOverlay<AfterLightTargetOverlay>(); | ||
} | ||
} |
Oops, something went wrong.