Files
RobustToolbox/Robust.Client/ComponentTrees/LightTreeSystem.cs
Leon Friedrich 8ae35e12ee Update ComponentTreeSystem (#6211)
* Allow component trees to be disabled

* forgot

* I'm pretty sure this wasn't working as intended

* also outdated

* reduce branches in QueueTreeUpdate

* remove update hashset

* try fix

* Use Entity<T> and add ray overloads

* Move InRangeUnoccluded to engine

* reduce code duplication

* move _initialized check

* release notes
2025-10-09 17:30:00 +13:00

40 lines
1.5 KiB
C#

using System.Numerics;
using Robust.Client.GameObjects;
using Robust.Shared.ComponentTrees;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
namespace Robust.Client.ComponentTrees;
public sealed class LightTreeSystem : ComponentTreeSystem<LightTreeComponent, PointLightComponent>
{
#region Component Tree Overrides
protected override bool DoFrameUpdate => true;
protected override bool DoTickUpdate => false;
protected override bool Recursive => true;
protected override int InitialCapacity => 128;
protected override Box2 ExtractAabb(in ComponentTreeEntry<PointLightComponent> entry, Vector2 pos, Angle rot)
{
// Really we should be rotating the light offset by the relative rotation. But I assume the light offset will
// always be relatively small, so fuck it, this is probably faster than having to compute the angle every time.
var radius = entry.Component.Radius + entry.Component.Offset.Length();
var radiusVec = new Vector2(radius, radius);
return new Box2(pos - radiusVec, pos + radiusVec);
}
protected override Box2 ExtractAabb(in ComponentTreeEntry<PointLightComponent> entry)
{
if (entry.Component.TreeUid == null)
return default;
var pos = XformSystem.GetRelativePosition(
entry.Transform,
entry.Component.TreeUid.Value);
return ExtractAabb(in entry, pos, default);
}
#endregion
}