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 { [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 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 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 }