mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-01 17:47:24 +02:00
Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using System;
|
|
using System.Numerics;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Physics;
|
|
|
|
namespace Robust.Shared.ComponentTrees;
|
|
|
|
public abstract partial class SharedLightTreeSystem : ComponentTreeSystem<LightTreeComponent, SharedPointLightComponent>
|
|
{
|
|
[Dependency] private IConfigurationManager _cfg = default!;
|
|
[Dependency] private INetManager _net = default!;
|
|
|
|
public bool IsAvailable => Enabled;
|
|
|
|
#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 bool Enabled => _net.IsClient || _cfg.GetCVar(CVars.LookupEnableServerLightTree);
|
|
|
|
protected override Box2 ExtractAabb(in ComponentTreeEntry<SharedPointLightComponent> entry, Vector2 pos, Angle rot)
|
|
{
|
|
var radius = Math.Min(entry.Component.Radius, _cfg.GetCVar(CVars.MaxLightRadius)) + entry.Component.Offset.Length();
|
|
var radiusVec = new Vector2(radius, radius);
|
|
return new Box2(pos - radiusVec, pos + radiusVec);
|
|
}
|
|
|
|
protected override Box2 ExtractAabb(in ComponentTreeEntry<SharedPointLightComponent> 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
|
|
}
|