From 28bf3a624029932b10edcd4d127c942ee0f07a9d Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 11 Sep 2023 16:15:23 +1000 Subject: [PATCH] Remove SharedEye (but content) (#19481) --- .../Clickable/ClickableComponent.cs | 1 + Content.Client/DragDrop/DragDropSystem.cs | 2 +- Content.Client/Drugs/RainbowOverlay.cs | 1 - Content.Client/Drunk/DrunkOverlay.cs | 1 - Content.Client/Eye/Blinding/BlindOverlay.cs | 1 - .../Eye/Blinding/BlurryVisionOverlay.cs | 1 - Content.Client/Eye/EyeLerpingSystem.cs | 23 ++++++++++--------- Content.Client/Flash/FlashOverlay.cs | 1 - .../Movement/Systems/ContentEyeSystem.cs | 1 - .../Outline/InteractionOutlineSystem.cs | 3 +-- .../Overlays/RadiationPulseOverlay.cs | 1 + .../SurveillanceCameraMonitorWindow.xaml.cs | 1 + .../Tabletop/UI/TabletopWindow.xaml.cs | 1 + .../DamageOverlays/Overlays/DamageOverlay.cs | 1 - .../Systems/Viewport/ViewportUIController.cs | 1 - Content.Client/Vehicle/VehicleSystem.cs | 14 ++++++++--- Content.Client/Viewport/ScalingViewport.cs | 1 + Content.Server/Ghost/GhostSystem.cs | 19 ++++++++------- .../Pointing/EntitySystems/PointingSystem.cs | 2 +- .../Revenant/EntitySystems/CorporealSystem.cs | 2 +- .../Revenant/EntitySystems/RevenantSystem.cs | 13 +++++++---- .../Tabletop/TabletopSystem.Session.cs | 5 ++-- Content.Server/Tabletop/TabletopSystem.cs | 6 ++--- Content.Server/Visible/VisibilityFlags.cs | 10 -------- .../Camera/SharedCameraRecoilSystem.cs | 20 ++++++---------- Content.Shared/Examine/ExamineSystemShared.cs | 2 +- Content.Shared/Eye/VisibilityFlags.cs | 13 +++++++++++ .../Systems/SharedContentEyeSystem.cs | 11 +++++---- .../Entities/Mobs/NPCs/revenant.yml | 3 +++ 29 files changed, 86 insertions(+), 75 deletions(-) delete mode 100644 Content.Server/Visible/VisibilityFlags.cs create mode 100644 Content.Shared/Eye/VisibilityFlags.cs diff --git a/Content.Client/Clickable/ClickableComponent.cs b/Content.Client/Clickable/ClickableComponent.cs index 86b7a0c9f6..f436715d5e 100644 --- a/Content.Client/Clickable/ClickableComponent.cs +++ b/Content.Client/Clickable/ClickableComponent.cs @@ -2,6 +2,7 @@ using System.Numerics; 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 diff --git a/Content.Client/DragDrop/DragDropSystem.cs b/Content.Client/DragDrop/DragDropSystem.cs index 23bd662d82..a8c1a06686 100644 --- a/Content.Client/DragDrop/DragDropSystem.cs +++ b/Content.Client/DragDrop/DragDropSystem.cs @@ -112,7 +112,7 @@ public sealed class DragDropSystem : SharedDragDropSystem base.Initialize(); _sawmill = Logger.GetSawmill("drag_drop"); UpdatesOutsidePrediction = true; - UpdatesAfter.Add(typeof(EyeUpdateSystem)); + UpdatesAfter.Add(typeof(SharedEyeSystem)); _cfgMan.OnValueChanged(CCVars.DragDropDeadZone, SetDeadZone, true); diff --git a/Content.Client/Drugs/RainbowOverlay.cs b/Content.Client/Drugs/RainbowOverlay.cs index fbaab0dc5f..8372f7ea60 100644 --- a/Content.Client/Drugs/RainbowOverlay.cs +++ b/Content.Client/Drugs/RainbowOverlay.cs @@ -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; diff --git a/Content.Client/Drunk/DrunkOverlay.cs b/Content.Client/Drunk/DrunkOverlay.cs index 846c86b3be..a2adb6ecc7 100644 --- a/Content.Client/Drunk/DrunkOverlay.cs +++ b/Content.Client/Drunk/DrunkOverlay.cs @@ -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; diff --git a/Content.Client/Eye/Blinding/BlindOverlay.cs b/Content.Client/Eye/Blinding/BlindOverlay.cs index 1ade23c14d..83c6cd23e6 100644 --- a/Content.Client/Eye/Blinding/BlindOverlay.cs +++ b/Content.Client/Eye/Blinding/BlindOverlay.cs @@ -1,4 +1,3 @@ -using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Player; using Robust.Shared.Enums; diff --git a/Content.Client/Eye/Blinding/BlurryVisionOverlay.cs b/Content.Client/Eye/Blinding/BlurryVisionOverlay.cs index 34480544e9..94590b54a5 100644 --- a/Content.Client/Eye/Blinding/BlurryVisionOverlay.cs +++ b/Content.Client/Eye/Blinding/BlurryVisionOverlay.cs @@ -1,4 +1,3 @@ -using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Player; using Robust.Shared.Enums; diff --git a/Content.Client/Eye/EyeLerpingSystem.cs b/Content.Client/Eye/EyeLerpingSystem.cs index 8495f01c81..79af9e719b 100644 --- a/Content.Client/Eye/EyeLerpingSystem.cs +++ b/Content.Client/Eye/EyeLerpingSystem.cs @@ -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!; @@ -26,14 +27,14 @@ public sealed class EyeLerpingSystem : EntitySystem SubscribeLocalEvent(OnEyeStartup); SubscribeLocalEvent(OnEyeShutdown); - SubscribeLocalEvent(OnAttached); + SubscribeLocalEvent(OnAttached); SubscribeLocalEvent(HandleMapChange); SubscribeLocalEvent(OnDetached); UpdatesAfter.Add(typeof(TransformSystem)); UpdatesAfter.Add(typeof(PhysicsSystem)); - UpdatesBefore.Add(typeof(EyeUpdateSystem)); + UpdatesBefore.Add(typeof(SharedEyeSystem)); UpdatesOutsidePrediction = true; } @@ -64,8 +65,8 @@ public sealed class EyeLerpingSystem : EntitySystem 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); } } @@ -88,9 +89,9 @@ public sealed class EyeLerpingSystem : EntitySystem 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) @@ -182,11 +183,11 @@ public sealed class EyeLerpingSystem : EntitySystem 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 @@ -197,7 +198,7 @@ public sealed class EyeLerpingSystem : EntitySystem if (!NeedsLerp(mover)) { - eye.Rotation = lerpInfo.TargetRotation; + _eye.SetRotation(entity, lerpInfo.TargetRotation, eye); continue; } @@ -205,11 +206,11 @@ public sealed class EyeLerpingSystem : EntitySystem 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); } } } diff --git a/Content.Client/Flash/FlashOverlay.cs b/Content.Client/Flash/FlashOverlay.cs index 8b80a8a6af..f12ab3f5c9 100644 --- a/Content.Client/Flash/FlashOverlay.cs +++ b/Content.Client/Flash/FlashOverlay.cs @@ -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; diff --git a/Content.Client/Movement/Systems/ContentEyeSystem.cs b/Content.Client/Movement/Systems/ContentEyeSystem.cs index cb750ff234..4056f5fd85 100644 --- a/Content.Client/Movement/Systems/ContentEyeSystem.cs +++ b/Content.Client/Movement/Systems/ContentEyeSystem.cs @@ -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; diff --git a/Content.Client/Outline/InteractionOutlineSystem.cs b/Content.Client/Outline/InteractionOutlineSystem.cs index d48b8763f4..ce1945ed03 100644 --- a/Content.Client/Outline/InteractionOutlineSystem.cs +++ b/Content.Client/Outline/InteractionOutlineSystem.cs @@ -4,7 +4,6 @@ using Content.Client.Interactable.Components; 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; @@ -42,7 +41,7 @@ public sealed class InteractionOutlineSystem : EntitySystem base.Initialize(); _configManager.OnValueChanged(CCVars.OutlineEnabled, SetCvarEnabled); - UpdatesAfter.Add(typeof(EyeUpdateSystem)); + UpdatesAfter.Add(typeof(SharedEyeSystem)); } public override void Shutdown() diff --git a/Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs b/Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs index d9b3ac48a4..b10025f56f 100644 --- a/Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs +++ b/Content.Client/Radiation/Overlays/RadiationPulseOverlay.cs @@ -3,6 +3,7 @@ using System.Numerics; 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; diff --git a/Content.Client/SurveillanceCamera/UI/SurveillanceCameraMonitorWindow.xaml.cs b/Content.Client/SurveillanceCamera/UI/SurveillanceCameraMonitorWindow.xaml.cs index 1c6e18c7af..59ac435acf 100644 --- a/Content.Client/SurveillanceCamera/UI/SurveillanceCameraMonitorWindow.xaml.cs +++ b/Content.Client/SurveillanceCamera/UI/SurveillanceCameraMonitorWindow.xaml.cs @@ -9,6 +9,7 @@ using Robust.Client.ResourceManagement; 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; diff --git a/Content.Client/Tabletop/UI/TabletopWindow.xaml.cs b/Content.Client/Tabletop/UI/TabletopWindow.xaml.cs index 2b6730958b..11eb38708c 100644 --- a/Content.Client/Tabletop/UI/TabletopWindow.xaml.cs +++ b/Content.Client/Tabletop/UI/TabletopWindow.xaml.cs @@ -3,6 +3,7 @@ using Robust.Client.Graphics; 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 diff --git a/Content.Client/UserInterface/Systems/DamageOverlays/Overlays/DamageOverlay.cs b/Content.Client/UserInterface/Systems/DamageOverlays/Overlays/DamageOverlay.cs index 30608a986e..03d7a865f7 100644 --- a/Content.Client/UserInterface/Systems/DamageOverlays/Overlays/DamageOverlay.cs +++ b/Content.Client/UserInterface/Systems/DamageOverlays/Overlays/DamageOverlay.cs @@ -1,5 +1,4 @@ using Content.Shared.Mobs; -using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Player; using Robust.Shared.Enums; diff --git a/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs b/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs index d16b61317d..668c8f2d59 100644 --- a/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs +++ b/Content.Client/UserInterface/Systems/Viewport/ViewportUIController.cs @@ -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; diff --git a/Content.Client/Vehicle/VehicleSystem.cs b/Content.Client/Vehicle/VehicleSystem.cs index 4cc4b8732e..e1bb783872 100644 --- a/Content.Client/Vehicle/VehicleSystem.cs +++ b/Content.Client/Vehicle/VehicleSystem.cs @@ -7,6 +7,8 @@ namespace Content.Client.Vehicle; public sealed class VehicleSystem : SharedVehicleSystem { + [Dependency] private EyeSystem _eye = default!; + public override void Initialize() { base.Initialize(); @@ -21,14 +23,18 @@ public sealed class VehicleSystem : SharedVehicleSystem { // 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) @@ -39,7 +45,9 @@ public sealed class VehicleSystem : SharedVehicleSystem var entity = EnsureEntity(state.Entity, uid); if (TryComp(uid, out EyeComponent? eyeComp) && eyeComp.Target == component.Vehicle) - eyeComp.Target = entity; + { + _eye.SetTarget(uid, entity, eyeComp); + } component.Vehicle = entity; } diff --git a/Content.Client/Viewport/ScalingViewport.cs b/Content.Client/Viewport/ScalingViewport.cs index 4237679958..9271e010f3 100644 --- a/Content.Client/Viewport/ScalingViewport.cs +++ b/Content.Client/Viewport/ScalingViewport.cs @@ -5,6 +5,7 @@ using Robust.Client.Graphics; 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; diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index 0201de79ad..36262d1d1b 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -4,11 +4,11 @@ using Content.Server.GameTicking; 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; @@ -37,6 +37,7 @@ namespace Content.Server.Ghost [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!; @@ -106,7 +107,7 @@ namespace Content.Server.Ghost private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentStartup args) { // Allow this entity to be seen by other ghosts. - var visibility = EntityManager.EnsureComponent(component.Owner); + var visibility = EntityManager.EnsureComponent(uid); if (_ticker.RunLevel != GameRunLevel.PostRound) { @@ -115,9 +116,9 @@ namespace Content.Server.Ghost _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; @@ -142,7 +143,7 @@ namespace Content.Server.Ghost 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); @@ -150,9 +151,9 @@ namespace Content.Server.Ghost } // 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); @@ -334,9 +335,11 @@ namespace Content.Server.Ghost if (uid == null || !entityManager.HasComponent(uid) || !entityManager.TryGetComponent(uid, out var eyeComponent)) + { return; + } - eyeComponent.VisibilityMask ^= (uint) VisibilityFlags.Ghost; + entityManager.System().SetVisibilityMask(uid.Value, eyeComponent.VisibilityMask ^ (int) VisibilityFlags.Ghost, eyeComponent); } } } diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index 9d1eb466fc..dc610ef409 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -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; diff --git a/Content.Server/Revenant/EntitySystems/CorporealSystem.cs b/Content.Server/Revenant/EntitySystems/CorporealSystem.cs index bad5eb6100..350d082756 100644 --- a/Content.Server/Revenant/EntitySystems/CorporealSystem.cs +++ b/Content.Server/Revenant/EntitySystems/CorporealSystem.cs @@ -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; diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.cs index 4028f2dce2..3ff247d6f8 100644 --- a/Content.Server/Revenant/EntitySystems/RevenantSystem.cs +++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.cs @@ -3,11 +3,11 @@ using Content.Server.Actions; 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; @@ -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] private const string RevenantShopId = "ActionRevenantShop"; @@ -83,7 +84,9 @@ public sealed partial class RevenantSystem : EntitySystem //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) diff --git a/Content.Server/Tabletop/TabletopSystem.Session.cs b/Content.Server/Tabletop/TabletopSystem.Session.cs index 588c4f129d..ef96733a12 100644 --- a/Content.Server/Tabletop/TabletopSystem.Session.cs +++ b/Content.Server/Tabletop/TabletopSystem.Session.cs @@ -1,7 +1,6 @@ using System.Numerics; using Content.Server.Tabletop.Components; using Content.Shared.Tabletop.Events; -using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Utility; @@ -141,8 +140,8 @@ namespace Content.Server.Tabletop // Add an eye component and disable FOV var eyeComponent = camera.EnsureComponent(); - eyeComponent.DrawFov = false; - eyeComponent.Zoom = tabletop.CameraZoom; + _eye.SetDrawFov(camera, false, eyeComponent); + _eye.SetZoom(camera, tabletop.CameraZoom, eyeComponent); // Add the user to the view subscribers. If there is no player session, just skip this step _viewSubscriberSystem.AddViewSubscriber(camera, player); diff --git a/Content.Server/Tabletop/TabletopSystem.cs b/Content.Server/Tabletop/TabletopSystem.cs index 82a93f6d58..3b817c2c61 100644 --- a/Content.Server/Tabletop/TabletopSystem.cs +++ b/Content.Server/Tabletop/TabletopSystem.cs @@ -21,7 +21,7 @@ namespace Content.Server.Tabletop public sealed partial class TabletopSystem : SharedTabletopSystem { [Dependency] private readonly IMapManager _mapManager = default!; - [Dependency] private readonly IEntityManager _entityManager = default!; + [Dependency] private readonly EyeSystem _eye = default!; [Dependency] private readonly ViewSubscriberSystem _viewSubscriberSystem = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; @@ -69,7 +69,7 @@ namespace Content.Server.Tabletop // Find the entity, remove it from the session and set it's position to the tabletop session.Entities.TryGetValue(entity, out var result); session.Entities.Remove(result); - _entityManager.QueueDeleteEntity(result); + QueueDel(result); } private void OnInteractUsing(EntityUid uid, TabletopGameComponent component, InteractUsingEvent args) @@ -94,7 +94,7 @@ namespace Content.Server.Tabletop var meta = MetaData(handEnt); var protoId = meta.EntityPrototype?.ID; - var hologram = _entityManager.SpawnEntity(protoId, session.Position.Offset(-1, 0)); + var hologram = Spawn(protoId, session.Position.Offset(-1, 0)); // Make sure the entity can be dragged and can be removed, move it into the board game world and add it to the Entities hashmap EnsureComp(hologram); diff --git a/Content.Server/Visible/VisibilityFlags.cs b/Content.Server/Visible/VisibilityFlags.cs deleted file mode 100644 index 03c2022fea..0000000000 --- a/Content.Server/Visible/VisibilityFlags.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Content.Server.Visible -{ - [Flags] - public enum VisibilityFlags : uint - { - None = 0, - Normal = 1 << 0, - Ghost = 1 << 1, - } -} diff --git a/Content.Shared/Camera/SharedCameraRecoilSystem.cs b/Content.Shared/Camera/SharedCameraRecoilSystem.cs index ec57524c05..3507bf1023 100644 --- a/Content.Shared/Camera/SharedCameraRecoilSystem.cs +++ b/Content.Shared/Camera/SharedCameraRecoilSystem.cs @@ -28,19 +28,13 @@ public abstract class SharedCameraRecoilSystem : EntitySystem /// protected const float KickMagnitudeMax = 1f; - private ISawmill _log = default!; - - public override void Initialize() - { - base.Initialize(); - _log = Logger.GetSawmill($"ecs.systems.{nameof(SharedCameraRecoilSystem)}"); - } + [Dependency] private readonly SharedEyeSystem _eye = default!; /// /// Applies explosion/recoil/etc kickback to the view of the entity. /// /// - /// If the entity is missing and/or , + /// If the entity is missing and/or , /// this call will have no effect. It is safe to call this function on any entity. /// public abstract void KickCamera(EntityUid euid, Vector2 kickback, CameraRecoilComponent? component = null); @@ -49,15 +43,15 @@ public abstract class SharedCameraRecoilSystem : EntitySystem { base.FrameUpdate(frameTime); - foreach (var entity in EntityManager.EntityQuery(true)) + var query = AllEntityQuery(); + + while (query.MoveNext(out var uid, out var eye, out var recoil)) { - var recoil = entity.Item2; - var eye = entity.Item1; var magnitude = recoil.CurrentKick.Length(); if (magnitude <= 0.005f) { recoil.CurrentKick = Vector2.Zero; - eye.Offset = recoil.BaseOffset + recoil.CurrentKick; + _eye.SetOffset(uid, recoil.BaseOffset + recoil.CurrentKick, eye); } else // Continually restore camera to 0. { @@ -72,7 +66,7 @@ public abstract class SharedCameraRecoilSystem : EntitySystem recoil.CurrentKick = new Vector2(x, y); - eye.Offset = recoil.BaseOffset + recoil.CurrentKick; + _eye.SetOffset(uid, recoil.BaseOffset + recoil.CurrentKick, eye); } } } diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index cb4845498f..81fc016904 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -138,7 +138,7 @@ namespace Content.Shared.Examine /// public bool IsOccluded(EntityUid uid) { - return TryComp(uid, out var eye) && eye.DrawFov; + return TryComp(uid, out var eye) && eye.DrawFov; } public static bool InRangeUnOccluded(MapCoordinates origin, MapCoordinates other, float range, Ignored? predicate, bool ignoreInsideBlocker = true, IEntityManager? entMan = null) diff --git a/Content.Shared/Eye/VisibilityFlags.cs b/Content.Shared/Eye/VisibilityFlags.cs new file mode 100644 index 0000000000..a4037f2bd7 --- /dev/null +++ b/Content.Shared/Eye/VisibilityFlags.cs @@ -0,0 +1,13 @@ +using Robust.Shared.Serialization; + +namespace Content.Shared.Eye +{ + [Flags] + [FlagsFor(typeof(VisibilityMaskLayer))] + public enum VisibilityFlags : int + { + None = 0, + Normal = 1 << 0, + Ghost = 1 << 1, + } +} diff --git a/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs b/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs index df327ae35e..27e0080c87 100644 --- a/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs +++ b/Content.Shared/Movement/Systems/SharedContentEyeSystem.cs @@ -21,6 +21,8 @@ public abstract class SharedContentEyeSystem : EntitySystem public static readonly Vector2 DefaultZoom = Vector2.One; public static readonly Vector2 MinZoom = DefaultZoom * (float)Math.Pow(ZoomMod, -3); + [Dependency] private readonly SharedEyeSystem _eye = default!; + public override void Initialize() { base.Initialize(); @@ -82,7 +84,7 @@ public abstract class SharedContentEyeSystem : EntitySystem private void OnContentZoomRequest(RequestTargetZoomEvent msg, EntitySessionEventArgs args) { var ignoreLimit = msg.IgnoreLimit && _admin.HasAdminFlag(args.SenderSession, AdminFlags.Debug); - + if (TryComp(args.SenderSession.AttachedEntity, out var content)) SetZoom(args.SenderSession.AttachedEntity.Value, msg.TargetZoom, ignoreLimit, eye: content); } @@ -95,16 +97,15 @@ public abstract class SharedContentEyeSystem : EntitySystem if (!HasComp(player) && !_admin.IsAdmin(player)) return; - if (TryComp(player, out var eyeComp)) + if (TryComp(player, out var eyeComp)) { - eyeComp.DrawFov = msg.Fov; - Dirty(player, eyeComp); + _eye.SetDrawFov(player, msg.Fov, eyeComp); } } private void OnContentEyeStartup(EntityUid uid, ContentEyeComponent component, ComponentStartup args) { - if (!TryComp(uid, out var eyeComp)) + if (!TryComp(uid, out var eyeComp)) return; component.TargetZoom = eyeComp.Zoom; diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml b/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml index 923d5ea954..7ce409325c 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml @@ -43,6 +43,9 @@ - type: Actions - type: Eye drawFov: false + visMask: + - Normal + - Ghost - type: ContentEye maxZoom: 1.2, 1.2 - type: DoAfter -- 2.51.2