Skip to content

Commit

Permalink
Remove SharedEye (but content) (#19481)
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth authored Sep 11, 2023
1 parent c477e5b commit 28bf3a6
Show file tree
Hide file tree
Showing 29 changed files with 86 additions and 75 deletions.
1 change: 1 addition & 0 deletions Content.Client/Clickable/ClickableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Utility;
using Robust.Shared.Graphics;
using static Robust.Client.GameObjects.SpriteComponent;

namespace Content.Client.Clickable
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/DragDrop/DragDropSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public override void Initialize()
base.Initialize();
_sawmill = Logger.GetSawmill("drag_drop");
UpdatesOutsidePrediction = true;
UpdatesAfter.Add(typeof(EyeUpdateSystem));
UpdatesAfter.Add(typeof(SharedEyeSystem));

_cfgMan.OnValueChanged(CCVars.DragDropDeadZone, SetDeadZone, true);

Expand Down
1 change: 0 additions & 1 deletion Content.Client/Drugs/RainbowOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Content.Shared.Drugs;
using Content.Shared.StatusEffect;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
Expand Down
1 change: 0 additions & 1 deletion Content.Client/Drunk/DrunkOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Content.Shared.Drunk;
using Content.Shared.StatusEffect;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
Expand Down
1 change: 0 additions & 1 deletion Content.Client/Eye/Blinding/BlindOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
Expand Down
1 change: 0 additions & 1 deletion Content.Client/Eye/Blinding/BlurryVisionOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
Expand Down
23 changes: 12 additions & 11 deletions Content.Client/Eye/EyeLerpingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public sealed class EyeLerpingSystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly SharedEyeSystem _eye = default!;
[Dependency] private readonly SharedMoverController _mover = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;

Expand All @@ -26,14 +27,14 @@ public override void Initialize()

SubscribeLocalEvent<EyeComponent, ComponentStartup>(OnEyeStartup);
SubscribeLocalEvent<EyeComponent, ComponentShutdown>(OnEyeShutdown);
SubscribeLocalEvent<EyeComponent, PlayerAttachedEvent>(OnAttached);
SubscribeLocalEvent<EyeAttachedEvent>(OnAttached);

SubscribeLocalEvent<LerpingEyeComponent, EntParentChangedMessage>(HandleMapChange);
SubscribeLocalEvent<LerpingEyeComponent, PlayerDetachedEvent>(OnDetached);

UpdatesAfter.Add(typeof(TransformSystem));
UpdatesAfter.Add(typeof(PhysicsSystem));
UpdatesBefore.Add(typeof(EyeUpdateSystem));
UpdatesBefore.Add(typeof(SharedEyeSystem));
UpdatesOutsidePrediction = true;
}

Expand Down Expand Up @@ -64,8 +65,8 @@ public void AddEye(EntityUid uid, EyeComponent? component = null, bool automatic

if (component.Eye != null)
{
component.Eye.Rotation = lerpInfo.TargetRotation;
component.Eye.Zoom = lerpInfo.TargetZoom;
_eye.SetRotation(uid, lerpInfo.TargetRotation, component);
_eye.SetZoom(uid, lerpInfo.TargetZoom, component);
}
}

Expand All @@ -88,9 +89,9 @@ private void HandleMapChange(EntityUid uid, LerpingEyeComponent component, ref E
component.LastRotation = GetRotation(uid, args.Transform);
}

private void OnAttached(EntityUid uid, EyeComponent component, PlayerAttachedEvent args)
private void OnAttached(ref EyeAttachedEvent ev)
{
AddEye(uid, component, true);
AddEye(ev.Entity, ev.Component, true);
}

private void OnDetached(EntityUid uid, LerpingEyeComponent component, PlayerDetachedEvent args)
Expand Down Expand Up @@ -182,11 +183,11 @@ public override void FrameUpdate(float frameTime)

if ((zoomDiff - lerpInfo.TargetZoom).Length() < lerpMinimum)
{
eye.Zoom = lerpInfo.TargetZoom;
_eye.SetZoom(entity, lerpInfo.TargetZoom, eye);
}
else
{
eye.Zoom = zoomDiff;
_eye.SetZoom(entity, zoomDiff, eye);
}

// Handle Rotation
Expand All @@ -197,19 +198,19 @@ public override void FrameUpdate(float frameTime)

if (!NeedsLerp(mover))
{
eye.Rotation = lerpInfo.TargetRotation;
_eye.SetRotation(entity, lerpInfo.TargetRotation, eye);
continue;
}

var shortest = Angle.ShortestDistance(lerpInfo.LastRotation, lerpInfo.TargetRotation);

if (Math.Abs(shortest.Theta) < lerpMinimum)
{
eye.Rotation = lerpInfo.TargetRotation;
_eye.SetRotation(entity, lerpInfo.TargetRotation, eye);
continue;
}

eye.Rotation = shortest * tickFraction + lerpInfo.LastRotation;
_eye.SetRotation(entity, shortest * tickFraction + lerpInfo.LastRotation, eye);
}
}
}
1 change: 0 additions & 1 deletion Content.Client/Flash/FlashOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Numerics;
using Content.Client.Viewport;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.State;
using Robust.Client.Player;
Expand Down
1 change: 0 additions & 1 deletion Content.Client/Movement/Systems/ContentEyeSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Numerics;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Robust.Client.GameObjects;
using Robust.Client.Player;

namespace Content.Client.Movement.Systems;
Expand Down
3 changes: 1 addition & 2 deletions Content.Client/Outline/InteractionOutlineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Content.Client.Viewport;
using Content.Shared.CCVar;
using Content.Shared.Interaction;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
Expand Down Expand Up @@ -42,7 +41,7 @@ public override void Initialize()
base.Initialize();

_configManager.OnValueChanged(CCVars.OutlineEnabled, SetCvarEnabled);
UpdatesAfter.Add(typeof(EyeUpdateSystem));
UpdatesAfter.Add(typeof(SharedEyeSystem));
}

public override void Shutdown()
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Radiation.Components;
using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.Graphics;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Graphics;
using Robust.Shared.Prototypes;

namespace Content.Client.SurveillanceCamera.UI;
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Tabletop/UI/TabletopWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Graphics;
using Robust.Shared.Maths;

namespace Content.Client.Tabletop.UI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Content.Shared.Mobs;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Shared.CCVar;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.UserInterface.Controllers;
Expand Down
14 changes: 11 additions & 3 deletions Content.Client/Vehicle/VehicleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace Content.Client.Vehicle;

public sealed class VehicleSystem : SharedVehicleSystem
{
[Dependency] private EyeSystem _eye = default!;

public override void Initialize()
{
base.Initialize();
Expand All @@ -21,14 +23,18 @@ private void OnRiderStartup(EntityUid uid, RiderComponent component, ComponentSt
{
// Center the player's eye on the vehicle
if (TryComp(uid, out EyeComponent? eyeComp))
eyeComp.Target ??= component.Vehicle;
{
_eye.SetTarget(uid, eyeComp.Target ?? component.Vehicle, eyeComp);
}
}

private void OnRiderShutdown(EntityUid uid, RiderComponent component, ComponentShutdown args)
{
// reset the riders eye centering.
if (TryComp(uid, out EyeComponent? eyeComp) && eyeComp.Target == component.Vehicle)
eyeComp.Target = null;
{
_eye.SetTarget(uid, eyeComp.Target, eyeComp);
}
}

private void OnRiderHandleState(EntityUid uid, RiderComponent component, ref ComponentHandleState args)
Expand All @@ -39,7 +45,9 @@ private void OnRiderHandleState(EntityUid uid, RiderComponent component, ref Com
var entity = EnsureEntity<RiderComponent>(state.Entity, uid);

if (TryComp(uid, out EyeComponent? eyeComp) && eyeComp.Target == component.Vehicle)
eyeComp.Target = entity;
{
_eye.SetTarget(uid, entity, eyeComp);
}

component.Vehicle = entity;
}
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Viewport/ScalingViewport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Robust.Client.Input;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Graphics;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
Expand Down
19 changes: 11 additions & 8 deletions Content.Server/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using Content.Server.Ghost.Components;
using Content.Server.Mind;
using Content.Server.Roles.Jobs;
using Content.Server.Visible;
using Content.Server.Warps;
using Content.Shared.Actions;
using Content.Shared.Administration;
using Content.Shared.Examine;
using Content.Shared.Eye;
using Content.Shared.Follower;
using Content.Shared.Ghost;
using Content.Shared.Mind;
Expand Down Expand Up @@ -37,6 +37,7 @@ public sealed partial class GhostSystem : SharedGhostSystem
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly FollowerSystem _followerSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedEyeSystem _eye = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly JobSystem _jobs = default!;
Expand Down Expand Up @@ -106,7 +107,7 @@ private void OnRelayMoveInput(EntityUid uid, GhostOnMoveComponent component, ref
private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentStartup args)
{
// Allow this entity to be seen by other ghosts.
var visibility = EntityManager.EnsureComponent<VisibilityComponent>(component.Owner);
var visibility = EntityManager.EnsureComponent<VisibilityComponent>(uid);

if (_ticker.RunLevel != GameRunLevel.PostRound)
{
Expand All @@ -115,9 +116,9 @@ private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentSt
_visibilitySystem.RefreshVisibility(visibility);
}

if (EntityManager.TryGetComponent(component.Owner, out EyeComponent? eye))
if (EntityManager.TryGetComponent(uid, out EyeComponent? eye))
{
eye.VisibilityMask |= (uint) VisibilityFlags.Ghost;
_eye.SetVisibilityMask(uid, eye.VisibilityMask | (int) VisibilityFlags.Ghost, eye);
}

var time = _gameTiming.CurTime;
Expand All @@ -142,17 +143,17 @@ private void OnGhostShutdown(EntityUid uid, GhostComponent component, ComponentS
if (!Terminating(uid))
{
// Entity can't be seen by ghosts anymore.
if (EntityManager.TryGetComponent(component.Owner, out VisibilityComponent? visibility))
if (EntityManager.TryGetComponent(uid, out VisibilityComponent? visibility))
{
_visibilitySystem.RemoveLayer(visibility, (int) VisibilityFlags.Ghost, false);
_visibilitySystem.AddLayer(visibility, (int) VisibilityFlags.Normal, false);
_visibilitySystem.RefreshVisibility(visibility);
}

// Entity can't see ghosts anymore.
if (EntityManager.TryGetComponent(component.Owner, out EyeComponent? eye))
if (EntityManager.TryGetComponent(uid, out EyeComponent? eye))
{
eye.VisibilityMask &= ~(uint) VisibilityFlags.Ghost;
_eye.SetVisibilityMask(uid, eye.VisibilityMask & ~(int) VisibilityFlags.Ghost, eye);
}

_actions.RemoveAction(uid, component.ActionEntity);
Expand Down Expand Up @@ -334,9 +335,11 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
if (uid == null
|| !entityManager.HasComponent<GhostComponent>(uid)
|| !entityManager.TryGetComponent<EyeComponent>(uid, out var eyeComponent))
{
return;
}

eyeComponent.VisibilityMask ^= (uint) VisibilityFlags.Ghost;
entityManager.System<EyeSystem>().SetVisibilityMask(uid.Value, eyeComponent.VisibilityMask ^ (int) VisibilityFlags.Ghost, eyeComponent);
}
}
}
2 changes: 1 addition & 1 deletion Content.Server/Pointing/EntitySystems/PointingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Linq;
using Content.Server.Administration.Logs;
using Content.Server.Pointing.Components;
using Content.Server.Visible;
using Content.Shared.Bed.Sleep;
using Content.Shared.Database;
using Content.Shared.Eye;
using Content.Shared.Ghost;
using Content.Shared.IdentityManagement;
using Content.Shared.Input;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Revenant/EntitySystems/CorporealSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Content.Server.GameTicking;
using Content.Server.Visible;
using Content.Shared.Eye;
using Content.Shared.Revenant.Components;
using Content.Shared.Revenant.EntitySystems;
using Robust.Server.GameObjects;
Expand Down
13 changes: 8 additions & 5 deletions Content.Server/Revenant/EntitySystems/RevenantSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
using Content.Server.GameTicking;
using Content.Server.Store.Components;
using Content.Server.Store.Systems;
using Content.Server.Visible;
using Content.Shared.Alert;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
using Content.Shared.Examine;
using Content.Shared.Eye;
using Content.Shared.FixedPoint;
using Content.Shared.Interaction;
using Content.Shared.Maps;
Expand All @@ -31,18 +31,19 @@ public sealed partial class RevenantSystem : EntitySystem
[Dependency] private readonly ActionsSystem _action = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly DamageableSystem _damage = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly PhysicsSystem _physics = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedEyeSystem _eye = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
[Dependency] private readonly SharedInteractionSystem _interact = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly StoreSystem _store = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly VisibilitySystem _visibility = default!;
[Dependency] private readonly GameTicker _ticker = default!;

[ValidatePrototypeId<EntityPrototype>]
private const string RevenantShopId = "ActionRevenantShop";
Expand Down Expand Up @@ -83,7 +84,9 @@ private void OnStartup(EntityUid uid, RevenantComponent component, ComponentStar

//ghost vision
if (TryComp(uid, out EyeComponent? eye))
eye.VisibilityMask |= (uint) (VisibilityFlags.Ghost);
{
_eye.SetVisibilityMask(uid, eye.VisibilityMask | (int) (VisibilityFlags.Ghost), eye);
}
}

private void OnMapInit(EntityUid uid, RevenantComponent component, MapInitEvent args)
Expand Down
Loading

0 comments on commit 28bf3a6

Please sign in to comment.