Add ImplicitRoofComponent (#36112)
* Add ImplicitRoofComponent So shuttles get marked as rooved. * Early-out So the new render doesn't suck up perf unnecessarily.
This commit is contained in:
@@ -43,7 +43,7 @@ public sealed class RoofOverlay : Overlay
|
|||||||
|
|
||||||
protected override void Draw(in OverlayDrawArgs args)
|
protected override void Draw(in OverlayDrawArgs args)
|
||||||
{
|
{
|
||||||
if (args.Viewport.Eye == null)
|
if (args.Viewport.Eye == null || !_entManager.HasComponent<MapLightComponent>(args.MapUid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var viewport = args.Viewport;
|
var viewport = args.Viewport;
|
||||||
@@ -55,24 +55,42 @@ public sealed class RoofOverlay : Overlay
|
|||||||
var target = lightoverlay.EnlargedLightTarget;
|
var target = lightoverlay.EnlargedLightTarget;
|
||||||
|
|
||||||
_grids.Clear();
|
_grids.Clear();
|
||||||
_mapManager.FindGridsIntersecting(args.MapId, bounds, ref _grids);
|
_mapManager.FindGridsIntersecting(args.MapId, bounds, ref _grids, approx: true, includeMap: true);
|
||||||
|
|
||||||
for (var i = _grids.Count - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
var grid = _grids[i];
|
|
||||||
|
|
||||||
if (_entManager.HasComponent<RoofComponent>(grid.Owner))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
_grids.RemoveAt(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_grids.Count == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var lightScale = viewport.LightRenderTarget.Size / (Vector2) viewport.Size;
|
var lightScale = viewport.LightRenderTarget.Size / (Vector2) viewport.Size;
|
||||||
var scale = viewport.RenderScale / (Vector2.One / lightScale);
|
var scale = viewport.RenderScale / (Vector2.One / lightScale);
|
||||||
|
|
||||||
|
worldHandle.RenderInRenderTarget(target,
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
for (var i = 0; i < _grids.Count; i++)
|
||||||
|
{
|
||||||
|
var grid = _grids[i];
|
||||||
|
|
||||||
|
if (!_entManager.TryGetComponent(grid.Owner, out ImplicitRoofComponent? roof))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var invMatrix = target.GetWorldToLocalMatrix(eye, scale);
|
||||||
|
|
||||||
|
var gridMatrix = _xformSystem.GetWorldMatrix(grid.Owner);
|
||||||
|
var matty = Matrix3x2.Multiply(gridMatrix, invMatrix);
|
||||||
|
|
||||||
|
worldHandle.SetTransform(matty);
|
||||||
|
|
||||||
|
var tileEnumerator = _mapSystem.GetTilesEnumerator(grid.Owner, grid, bounds);
|
||||||
|
var color = roof.Color;
|
||||||
|
|
||||||
|
while (tileEnumerator.MoveNext(out var tileRef))
|
||||||
|
{
|
||||||
|
var local = _lookup.GetLocalBounds(tileRef, grid.Comp.TileSize);
|
||||||
|
worldHandle.DrawRect(local, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't need it for the next stage.
|
||||||
|
_grids.RemoveAt(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}, null);
|
||||||
|
|
||||||
worldHandle.RenderInRenderTarget(target,
|
worldHandle.RenderInRenderTarget(target,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using Content.Server.Stunnable;
|
|||||||
using Content.Shared.Buckle.Components;
|
using Content.Shared.Buckle.Components;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.GameTicking;
|
using Content.Shared.GameTicking;
|
||||||
|
using Content.Shared.Light.Components;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Mobs.Systems;
|
using Content.Shared.Mobs.Systems;
|
||||||
using Content.Shared.Movement.Events;
|
using Content.Shared.Movement.Events;
|
||||||
@@ -121,7 +122,8 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
|
|||||||
if (HasComp<MapComponent>(ev.EntityUid))
|
if (HasComp<MapComponent>(ev.EntityUid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EntityManager.EnsureComponent<ShuttleComponent>(ev.EntityUid);
|
EnsureComp<ShuttleComponent>(ev.EntityUid);
|
||||||
|
EnsureComp<ImplicitRoofComponent>(ev.EntityUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnShuttleStartup(EntityUid uid, ShuttleComponent component, ComponentStartup args)
|
private void OnShuttleStartup(EntityUid uid, ShuttleComponent component, ComponentStartup args)
|
||||||
|
|||||||
13
Content.Shared/Light/Components/ImplicitRoofComponent.cs
Normal file
13
Content.Shared/Light/Components/ImplicitRoofComponent.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Light.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Assumes the entire attached grid is rooved.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||||
|
public sealed partial class ImplicitRoofComponent : Component
|
||||||
|
{
|
||||||
|
[DataField, AutoNetworkedField]
|
||||||
|
public Color Color = Color.Black;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user