diff --git a/Robust.Client/Graphics/Clyde/Clyde.HLR.cs b/Robust.Client/Graphics/Clyde/Clyde.HLR.cs index 36b7a0154..1da177f6a 100644 --- a/Robust.Client/Graphics/Clyde/Clyde.HLR.cs +++ b/Robust.Client/Graphics/Clyde/Clyde.HLR.cs @@ -512,7 +512,7 @@ namespace Robust.Client.Graphics.Clyde RenderOverlays(viewport, OverlaySpace.WorldSpaceBelowFOV, worldAABB, worldBounds); } - if (_lightManager.Enabled && _lightManager.DrawHardFov && eye.DrawFov) + if (_lightManager.Enabled && _lightManager.DrawHardFov && eye.DrawLight && eye.DrawFov) { ApplyFovToBuffer(viewport, eye); } diff --git a/Robust.Client/Graphics/Clyde/Clyde.LightRendering.cs b/Robust.Client/Graphics/Clyde/Clyde.LightRendering.cs index f1cfdfdce..1aeb2872b 100644 --- a/Robust.Client/Graphics/Clyde/Clyde.LightRendering.cs +++ b/Robust.Client/Graphics/Clyde/Clyde.LightRendering.cs @@ -332,7 +332,7 @@ namespace Robust.Client.Graphics.Clyde private void DrawLightsAndFov(Viewport viewport, Box2Rotated worldBounds, Box2 worldAABB, IEye eye) { - if (!_lightManager.Enabled) + if (!_lightManager.Enabled || !eye.DrawLight) { return; } diff --git a/Robust.Shared/GameObjects/Components/Eye/EyeComponent.cs b/Robust.Shared/GameObjects/Components/Eye/EyeComponent.cs index bea23bc0c..4f2684f28 100644 --- a/Robust.Shared/GameObjects/Components/Eye/EyeComponent.cs +++ b/Robust.Shared/GameObjects/Components/Eye/EyeComponent.cs @@ -31,6 +31,9 @@ namespace Robust.Shared.GameObjects [ViewVariables(VVAccess.ReadWrite), DataField("drawFov"), AutoNetworkedField] public bool DrawFov = true; + [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] + public bool DrawLight = true; + // yes it's not networked, don't ask. [ViewVariables(VVAccess.ReadWrite), DataField("rotation")] public Angle Rotation; diff --git a/Robust.Shared/GameObjects/EntitySystem.Proxy.cs b/Robust.Shared/GameObjects/EntitySystem.Proxy.cs index b0ad3835c..b21ba6d17 100644 --- a/Robust.Shared/GameObjects/EntitySystem.Proxy.cs +++ b/Robust.Shared/GameObjects/EntitySystem.Proxy.cs @@ -154,18 +154,26 @@ public partial class EntitySystem /// Marks a component as dirty. This also implicitly dirties the entity this component belongs to. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected void Dirty(Entity ent, MetaDataComponent? meta = null) where T : IComponent + protected void Dirty(Entity ent, MetaDataComponent? meta = null) where T : IComponent? { - EntityManager.Dirty(ent.Owner, ent.Comp, meta); + var comp = ent.Comp; + if (comp == null && !EntityManager.TryGetComponent(ent.Owner, out comp)) + return; + + EntityManager.Dirty(ent.Owner, comp, meta); } /// /// Marks a component as dirty. This also implicitly dirties the entity this component belongs to. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - protected void Dirty(Entity ent) where T : IComponent + protected void Dirty(Entity ent) where T : IComponent? { - EntityManager.Dirty(ent.Owner, ent.Comp1, ent.Comp2); + var comp = ent.Comp1; + if (comp == null && !EntityManager.TryGetComponent(ent.Owner, out comp)) + return; + + EntityManager.Dirty(ent.Owner, comp, ent.Comp2); } /// diff --git a/Robust.Shared/GameObjects/Systems/SharedEyeSystem.cs b/Robust.Shared/GameObjects/Systems/SharedEyeSystem.cs index 727cd8c17..41473b22c 100644 --- a/Robust.Shared/GameObjects/Systems/SharedEyeSystem.cs +++ b/Robust.Shared/GameObjects/Systems/SharedEyeSystem.cs @@ -6,8 +6,6 @@ namespace Robust.Shared.GameObjects; public abstract class SharedEyeSystem : EntitySystem { - [Dependency] protected readonly SharedTransformSystem TransformSystem = default!; - /// /// Refreshes all values for IEye with the component. /// @@ -19,6 +17,7 @@ public abstract class SharedEyeSystem : EntitySystem component.Eye.Offset = component.Offset; component.Eye.DrawFov = component.DrawFov; + component.Eye.DrawLight = component.DrawLight; component.Eye.Rotation = component.Rotation; component.Eye.Zoom = component.Zoom; } @@ -32,10 +31,7 @@ public abstract class SharedEyeSystem : EntitySystem return; eyeComponent.Offset = value; - if (eyeComponent.Eye != null) - { - eyeComponent.Eye.Offset = value; - } + eyeComponent.Eye.Offset = value; Dirty(uid, eyeComponent); } @@ -48,13 +44,23 @@ public abstract class SharedEyeSystem : EntitySystem return; eyeComponent.DrawFov = value; - if (eyeComponent.Eye != null) - { - eyeComponent.Eye.DrawFov = value; - } + eyeComponent.Eye.DrawFov = value; Dirty(uid, eyeComponent); } + public void SetDrawLight(Entity entity, bool value) + { + if (!Resolve(entity, ref entity.Comp)) + return; + + if (entity.Comp.DrawLight == value) + return; + + entity.Comp.DrawLight = value; + entity.Comp.Eye.DrawLight = value; + Dirty(entity); + } + public void SetRotation(EntityUid uid, Angle rotation, EyeComponent? eyeComponent = null) { if (!Resolve(uid, ref eyeComponent)) @@ -64,10 +70,7 @@ public abstract class SharedEyeSystem : EntitySystem return; eyeComponent.Rotation = rotation; - if (eyeComponent.Eye != null) - { - eyeComponent.Eye.Rotation = rotation; - } + eyeComponent.Eye.Rotation = rotation; } public void SetTarget(EntityUid uid, EntityUid? value, EyeComponent? eyeComponent = null) @@ -91,10 +94,7 @@ public abstract class SharedEyeSystem : EntitySystem return; eyeComponent.Zoom = value; - if (eyeComponent.Eye != null) - { - eyeComponent.Eye.Zoom = value; - } + eyeComponent.Eye.Zoom = value; } public void SetVisibilityMask(EntityUid uid, int value, EyeComponent? eyeComponent = null) diff --git a/Robust.Shared/Graphics/Eye.cs b/Robust.Shared/Graphics/Eye.cs index 3966fbf51..aca7eea52 100644 --- a/Robust.Shared/Graphics/Eye.cs +++ b/Robust.Shared/Graphics/Eye.cs @@ -19,6 +19,10 @@ namespace Robust.Shared.Graphics [ViewVariables(VVAccess.ReadWrite)] public bool DrawFov { get; set; } = true; + /// + [ViewVariables] + public bool DrawLight { get; set; } = true; + /// [ViewVariables(VVAccess.ReadWrite)] public virtual MapCoordinates Position diff --git a/Robust.Shared/Graphics/IEye.cs b/Robust.Shared/Graphics/IEye.cs index 0cdf769a2..d2e33614d 100644 --- a/Robust.Shared/Graphics/IEye.cs +++ b/Robust.Shared/Graphics/IEye.cs @@ -17,6 +17,11 @@ namespace Robust.Shared.Graphics /// bool DrawFov { get; set; } + /// + /// Whether to draw lights for this eye. + /// + bool DrawLight { get; set; } + /// /// Current position of the center of the eye in the game world. ///