mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Allow per-eye lighting toggling. (#4569)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -154,18 +154,26 @@ public partial class EntitySystem
|
||||
/// Marks a component as dirty. This also implicitly dirties the entity this component belongs to.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void Dirty<T>(Entity<T> ent, MetaDataComponent? meta = null) where T : IComponent
|
||||
protected void Dirty<T>(Entity<T> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks a component as dirty. This also implicitly dirties the entity this component belongs to.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void Dirty<T>(Entity<T, MetaDataComponent> ent) where T : IComponent
|
||||
protected void Dirty<T>(Entity<T, MetaDataComponent> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,8 +6,6 @@ namespace Robust.Shared.GameObjects;
|
||||
|
||||
public abstract class SharedEyeSystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes all values for IEye with the component.
|
||||
/// </summary>
|
||||
@@ -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<EyeComponent?> 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)
|
||||
|
||||
@@ -19,6 +19,10 @@ namespace Robust.Shared.Graphics
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool DrawFov { get; set; } = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public bool DrawLight { get; set; } = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public virtual MapCoordinates Position
|
||||
|
||||
@@ -17,6 +17,11 @@ namespace Robust.Shared.Graphics
|
||||
/// </summary>
|
||||
bool DrawFov { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to draw lights for this eye.
|
||||
/// </summary>
|
||||
bool DrawLight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Current position of the center of the eye in the game world.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user