diff --git a/Robust.Client/GameObjects/EntitySystems/EyeSystem.cs b/Robust.Client/GameObjects/EntitySystems/EyeSystem.cs
index a8e29d902..f2a7bba70 100644
--- a/Robust.Client/GameObjects/EntitySystems/EyeSystem.cs
+++ b/Robust.Client/GameObjects/EntitySystems/EyeSystem.cs
@@ -1,8 +1,6 @@
using Robust.Client.Graphics;
using Robust.Client.Physics;
-using Robust.Client.Player;
using Robust.Shared.GameObjects;
-using Robust.Shared.Graphics;
using Robust.Shared.IoC;
using Robust.Shared.Player;
@@ -27,17 +25,13 @@ public sealed class EyeSystem : SharedEyeSystem
private void OnEyeAutoState(EntityUid uid, EyeComponent component, ref AfterAutoHandleStateEvent args)
{
- UpdateEye(component);
+ UpdateEye((uid, component));
}
private void OnEyeAttached(EntityUid uid, EyeComponent component, LocalPlayerAttachedEvent args)
{
- // TODO: This probably shouldn't be nullable bruv.
- if (component._eye != null)
- {
- _eyeManager.CurrentEye = component._eye;
- }
-
+ UpdateEye((uid, component));
+ _eyeManager.CurrentEye = component.Eye;
var ev = new EyeAttachedEvent(uid, component);
RaiseLocalEvent(uid, ref ev, true);
}
@@ -49,13 +43,7 @@ public sealed class EyeSystem : SharedEyeSystem
private void OnInit(EntityUid uid, EyeComponent component, ComponentInit args)
{
- component._eye = new Eye
- {
- Position = Transform(uid).MapPosition,
- Zoom = component.Zoom,
- DrawFov = component.DrawFov,
- Rotation = component.Rotation,
- };
+ UpdateEye((uid, component));
}
///
@@ -65,7 +53,7 @@ public sealed class EyeSystem : SharedEyeSystem
while (query.MoveNext(out var uid, out var eyeComponent))
{
- if (eyeComponent._eye == null)
+ if (eyeComponent.Eye == null)
continue;
if (!TryComp(eyeComponent.Target, out var xform))
@@ -74,7 +62,7 @@ public sealed class EyeSystem : SharedEyeSystem
eyeComponent.Target = null;
}
- eyeComponent._eye.Position = xform.MapPosition;
+ eyeComponent.Eye.Position = xform.MapPosition;
}
}
}
diff --git a/Robust.Shared/GameObjects/Components/Eye/EyeComponent.cs b/Robust.Shared/GameObjects/Components/Eye/EyeComponent.cs
index 13eb13549..bea23bc0c 100644
--- a/Robust.Shared/GameObjects/Components/Eye/EyeComponent.cs
+++ b/Robust.Shared/GameObjects/Components/Eye/EyeComponent.cs
@@ -12,16 +12,10 @@ namespace Robust.Shared.GameObjects
[RegisterComponent, NetworkedComponent, Access(typeof(SharedEyeSystem)), AutoGenerateComponentState(true)]
public sealed partial class EyeComponent : Component
{
- #region Client
-
- [ViewVariables] internal Eye? _eye = default!;
-
- public IEye? Eye => _eye;
+ public const int DefaultVisibilityMask = 1;
[ViewVariables]
- public MapCoordinates? Position => _eye?.Position;
-
- #endregion
+ public readonly Eye Eye = new();
///
/// If not null, this entity is used to update the eye's position instead of just using the component's owner.
@@ -47,8 +41,6 @@ namespace Robust.Shared.GameObjects
[ViewVariables(VVAccess.ReadWrite), DataField("offset"), AutoNetworkedField]
public Vector2 Offset;
- public const int DefaultVisibilityMask = 1;
-
///
/// The visibility mask for this eye.
/// The player will be able to get updates for entities whose layers match the mask.
@@ -58,7 +50,7 @@ namespace Robust.Shared.GameObjects
}
///
- /// Single layer used for Eye visiblity. Controls what entities they are allowed to see.
+ /// Single layer used for Eye visibility. Controls what entities they are allowed to see.
///
public sealed class VisibilityMaskLayer {}
}
diff --git a/Robust.Shared/GameObjects/Systems/SharedEyeSystem.cs b/Robust.Shared/GameObjects/Systems/SharedEyeSystem.cs
index 6575f9a0a..727cd8c17 100644
--- a/Robust.Shared/GameObjects/Systems/SharedEyeSystem.cs
+++ b/Robust.Shared/GameObjects/Systems/SharedEyeSystem.cs
@@ -11,15 +11,16 @@ public abstract class SharedEyeSystem : EntitySystem
///
/// Refreshes all values for IEye with the component.
///
- public void UpdateEye(EyeComponent component)
+ public void UpdateEye(Entity entity)
{
- if (component._eye == null)
+ var component = entity.Comp;
+ if (!Resolve(entity, ref component))
return;
- component._eye.Offset = component.Offset;
- component._eye.DrawFov = component.DrawFov;
- component._eye.Rotation = component.Rotation;
- component._eye.Zoom = component.Zoom;
+ component.Eye.Offset = component.Offset;
+ component.Eye.DrawFov = component.DrawFov;
+ component.Eye.Rotation = component.Rotation;
+ component.Eye.Zoom = component.Zoom;
}
public void SetOffset(EntityUid uid, Vector2 value, EyeComponent? eyeComponent = null)
@@ -31,9 +32,9 @@ public abstract class SharedEyeSystem : EntitySystem
return;
eyeComponent.Offset = value;
- if (eyeComponent._eye != null)
+ if (eyeComponent.Eye != null)
{
- eyeComponent._eye.Offset = value;
+ eyeComponent.Eye.Offset = value;
}
Dirty(uid, eyeComponent);
}
@@ -47,9 +48,9 @@ public abstract class SharedEyeSystem : EntitySystem
return;
eyeComponent.DrawFov = value;
- if (eyeComponent._eye != null)
+ if (eyeComponent.Eye != null)
{
- eyeComponent._eye.DrawFov = value;
+ eyeComponent.Eye.DrawFov = value;
}
Dirty(uid, eyeComponent);
}
@@ -63,9 +64,9 @@ public abstract class SharedEyeSystem : EntitySystem
return;
eyeComponent.Rotation = rotation;
- if (eyeComponent._eye != null)
+ if (eyeComponent.Eye != null)
{
- eyeComponent._eye.Rotation = rotation;
+ eyeComponent.Eye.Rotation = rotation;
}
}
@@ -90,9 +91,9 @@ public abstract class SharedEyeSystem : EntitySystem
return;
eyeComponent.Zoom = value;
- if (eyeComponent._eye != null)
+ if (eyeComponent.Eye != null)
{
- eyeComponent._eye.Zoom = value;
+ eyeComponent.Eye.Zoom = value;
}
}