-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
time to fix all debug test fails! :cl: - fix: Traitors now get correct TC amount. - fix: Surplus bundles now have the correct TC cost. - add: Corpsman can take portable crew monitor now. - fix: NanoChat now scrolls to the bottom whenever you open a new chat.
- Loading branch information
Showing
231 changed files
with
303,871 additions
and
284,426 deletions.
There are no files selected for viewing
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>(); | ||
} | ||
} |
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,9 @@ | ||
using Content.Shared.Light.EntitySystems; | ||
|
||
namespace Content.Client.Light.EntitySystems; | ||
|
||
/// <inheritdoc/> | ||
public sealed class RoofSystem : SharedRoofSystem | ||
{ | ||
|
||
} |
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,44 @@ | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Enums; | ||
|
||
namespace Content.Client.Light; | ||
|
||
/// <summary> | ||
/// Essentially handles blurring for content-side light overlays. | ||
/// </summary> | ||
public sealed class LightBlurOverlay : Overlay | ||
{ | ||
public override OverlaySpace Space => OverlaySpace.BeforeLighting; | ||
|
||
[Dependency] private readonly IClyde _clyde = default!; | ||
[Dependency] private readonly IOverlayManager _overlay = default!; | ||
|
||
public const int ContentZIndex = TileEmissionOverlay.ContentZIndex + 1; | ||
|
||
private IRenderTarget? _blurTarget; | ||
|
||
public LightBlurOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
ZIndex = ContentZIndex; | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (args.Viewport.Eye == null) | ||
return; | ||
|
||
var beforeOverlay = _overlay.GetOverlay<BeforeLightTargetOverlay>(); | ||
var size = beforeOverlay.EnlargedLightTarget.Size; | ||
|
||
if (_blurTarget?.Size != size) | ||
{ | ||
_blurTarget = _clyde | ||
.CreateRenderTarget(size, new RenderTargetFormatParameters(RenderTargetColorFormat.Rgba8Srgb), name: "enlarged-light-blur"); | ||
} | ||
|
||
var target = beforeOverlay.EnlargedLightTarget; | ||
// Yeah that's all this does keep walkin. | ||
_clyde.BlurRenderTarget(args.Viewport, target, _blurTarget, args.Viewport.Eye, 14f * 2f); | ||
} | ||
} |
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,33 @@ | ||
using Content.Client.GameTicking.Managers; | ||
using Content.Shared; | ||
using Content.Shared.Light.Components; | ||
using Robust.Shared.Map.Components; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.Light; | ||
|
||
/// <inheritdoc/> | ||
public sealed class LightCycleSystem : SharedLightCycleSystem | ||
{ | ||
[Dependency] private readonly ClientGameTicker _ticker = default!; | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
var mapQuery = AllEntityQuery<LightCycleComponent, MapLightComponent>(); | ||
while (mapQuery.MoveNext(out var uid, out var cycle, out var map)) | ||
{ | ||
if (!cycle.Running) | ||
continue; | ||
|
||
var time = (float) _timing.CurTime | ||
.Add(cycle.Offset) | ||
.Subtract(_ticker.RoundStartTimeSpan) | ||
.TotalSeconds; | ||
|
||
var color = GetColor((uid, cycle), cycle.OriginalColor, time); | ||
map.AmbientLightColor = color; | ||
} | ||
} | ||
} |
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,100 @@ | ||
using System.Numerics; | ||
using Content.Shared.Light.Components; | ||
using Content.Shared.Maps; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Map.Components; | ||
|
||
namespace Content.Client.Light; | ||
|
||
public sealed class RoofOverlay : Overlay | ||
{ | ||
private readonly IEntityManager _entManager; | ||
[Dependency] private readonly IOverlayManager _overlay = default!; | ||
|
||
private readonly EntityLookupSystem _lookup; | ||
private readonly SharedMapSystem _mapSystem; | ||
private readonly SharedTransformSystem _xformSystem; | ||
|
||
private readonly HashSet<Entity<OccluderComponent>> _occluders = new(); | ||
|
||
public override OverlaySpace Space => OverlaySpace.BeforeLighting; | ||
|
||
public const int ContentZIndex = BeforeLightTargetOverlay.ContentZIndex + 1; | ||
|
||
public RoofOverlay(IEntityManager entManager) | ||
{ | ||
_entManager = entManager; | ||
IoCManager.InjectDependencies(this); | ||
|
||
_lookup = _entManager.System<EntityLookupSystem>(); | ||
_mapSystem = _entManager.System<SharedMapSystem>(); | ||
_xformSystem = _entManager.System<SharedTransformSystem>(); | ||
|
||
ZIndex = ContentZIndex; | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (args.Viewport.Eye == null) | ||
return; | ||
|
||
var mapEnt = _mapSystem.GetMap(args.MapId); | ||
|
||
if (!_entManager.TryGetComponent(mapEnt, out RoofComponent? roofComp) || | ||
!_entManager.TryGetComponent(mapEnt, out MapGridComponent? grid)) | ||
{ | ||
return; | ||
} | ||
|
||
var viewport = args.Viewport; | ||
var eye = args.Viewport.Eye; | ||
|
||
var worldHandle = args.WorldHandle; | ||
var lightoverlay = _overlay.GetOverlay<BeforeLightTargetOverlay>(); | ||
var bounds = lightoverlay.EnlargedBounds; | ||
var target = lightoverlay.EnlargedLightTarget; | ||
|
||
worldHandle.RenderInRenderTarget(target, | ||
() => | ||
{ | ||
var invMatrix = target.GetWorldToLocalMatrix(eye, viewport.RenderScale / 2f); | ||
|
||
var gridMatrix = _xformSystem.GetWorldMatrix(mapEnt); | ||
var matty = Matrix3x2.Multiply(gridMatrix, invMatrix); | ||
|
||
worldHandle.SetTransform(matty); | ||
|
||
var tileEnumerator = _mapSystem.GetTilesEnumerator(mapEnt, grid, bounds); | ||
|
||
// Due to stencilling we essentially draw on unrooved tiles | ||
while (tileEnumerator.MoveNext(out var tileRef)) | ||
{ | ||
if ((tileRef.Tile.Flags & (byte) TileFlag.Roof) == 0x0) | ||
{ | ||
// Check if the tile is occluded in which case hide it anyway. | ||
// This is to avoid lit walls bleeding over to unlit tiles. | ||
_occluders.Clear(); | ||
_lookup.GetLocalEntitiesIntersecting(mapEnt, tileRef.GridIndices, _occluders); | ||
var found = false; | ||
|
||
foreach (var occluder in _occluders) | ||
{ | ||
if (!occluder.Comp.Enabled) | ||
continue; | ||
|
||
found = true; | ||
break; | ||
} | ||
|
||
if (!found) | ||
continue; | ||
} | ||
|
||
var local = _lookup.GetLocalBounds(tileRef, grid.TileSize); | ||
worldHandle.DrawRect(local, roofComp.Color); | ||
} | ||
|
||
}, null); | ||
} | ||
} |
Oops, something went wrong.