Remove SharedEye (but content) (#19481)

This commit is contained in:
metalgearsloth
2023-09-11 16:15:23 +10:00
committed by GitHub
parent c477e5b0c2
commit 28bf3a6240
29 changed files with 86 additions and 75 deletions

View File

@@ -2,6 +2,7 @@ using System.Numerics;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Utility; using Robust.Client.Utility;
using Robust.Shared.Graphics;
using static Robust.Client.GameObjects.SpriteComponent; using static Robust.Client.GameObjects.SpriteComponent;
namespace Content.Client.Clickable namespace Content.Client.Clickable

View File

@@ -112,7 +112,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
base.Initialize(); base.Initialize();
_sawmill = Logger.GetSawmill("drag_drop"); _sawmill = Logger.GetSawmill("drag_drop");
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
UpdatesAfter.Add(typeof(EyeUpdateSystem)); UpdatesAfter.Add(typeof(SharedEyeSystem));
_cfgMan.OnValueChanged(CCVars.DragDropDeadZone, SetDeadZone, true); _cfgMan.OnValueChanged(CCVars.DragDropDeadZone, SetDeadZone, true);

View File

@@ -1,6 +1,5 @@
using Content.Shared.Drugs; using Content.Shared.Drugs;
using Content.Shared.StatusEffect; using Content.Shared.StatusEffect;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.Enums; using Robust.Shared.Enums;

View File

@@ -1,6 +1,5 @@
using Content.Shared.Drunk; using Content.Shared.Drunk;
using Content.Shared.StatusEffect; using Content.Shared.StatusEffect;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.Enums; using Robust.Shared.Enums;

View File

@@ -1,4 +1,3 @@
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.Enums; using Robust.Shared.Enums;

View File

@@ -1,4 +1,3 @@
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.Enums; using Robust.Shared.Enums;

View File

@@ -13,6 +13,7 @@ public sealed class EyeLerpingSystem : EntitySystem
{ {
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly SharedEyeSystem _eye = default!;
[Dependency] private readonly SharedMoverController _mover = default!; [Dependency] private readonly SharedMoverController _mover = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly SharedTransformSystem _transform = default!;
@@ -26,14 +27,14 @@ public sealed class EyeLerpingSystem : EntitySystem
SubscribeLocalEvent<EyeComponent, ComponentStartup>(OnEyeStartup); SubscribeLocalEvent<EyeComponent, ComponentStartup>(OnEyeStartup);
SubscribeLocalEvent<EyeComponent, ComponentShutdown>(OnEyeShutdown); SubscribeLocalEvent<EyeComponent, ComponentShutdown>(OnEyeShutdown);
SubscribeLocalEvent<EyeComponent, PlayerAttachedEvent>(OnAttached); SubscribeLocalEvent<EyeAttachedEvent>(OnAttached);
SubscribeLocalEvent<LerpingEyeComponent, EntParentChangedMessage>(HandleMapChange); SubscribeLocalEvent<LerpingEyeComponent, EntParentChangedMessage>(HandleMapChange);
SubscribeLocalEvent<LerpingEyeComponent, PlayerDetachedEvent>(OnDetached); SubscribeLocalEvent<LerpingEyeComponent, PlayerDetachedEvent>(OnDetached);
UpdatesAfter.Add(typeof(TransformSystem)); UpdatesAfter.Add(typeof(TransformSystem));
UpdatesAfter.Add(typeof(PhysicsSystem)); UpdatesAfter.Add(typeof(PhysicsSystem));
UpdatesBefore.Add(typeof(EyeUpdateSystem)); UpdatesBefore.Add(typeof(SharedEyeSystem));
UpdatesOutsidePrediction = true; UpdatesOutsidePrediction = true;
} }
@@ -64,8 +65,8 @@ public sealed class EyeLerpingSystem : EntitySystem
if (component.Eye != null) if (component.Eye != null)
{ {
component.Eye.Rotation = lerpInfo.TargetRotation; _eye.SetRotation(uid, lerpInfo.TargetRotation, component);
component.Eye.Zoom = lerpInfo.TargetZoom; _eye.SetZoom(uid, lerpInfo.TargetZoom, component);
} }
} }
@@ -88,9 +89,9 @@ public sealed class EyeLerpingSystem : EntitySystem
component.LastRotation = GetRotation(uid, args.Transform); 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) private void OnDetached(EntityUid uid, LerpingEyeComponent component, PlayerDetachedEvent args)
@@ -182,11 +183,11 @@ public sealed class EyeLerpingSystem : EntitySystem
if ((zoomDiff - lerpInfo.TargetZoom).Length() < lerpMinimum) if ((zoomDiff - lerpInfo.TargetZoom).Length() < lerpMinimum)
{ {
eye.Zoom = lerpInfo.TargetZoom; _eye.SetZoom(entity, lerpInfo.TargetZoom, eye);
} }
else else
{ {
eye.Zoom = zoomDiff; _eye.SetZoom(entity, zoomDiff, eye);
} }
// Handle Rotation // Handle Rotation
@@ -197,7 +198,7 @@ public sealed class EyeLerpingSystem : EntitySystem
if (!NeedsLerp(mover)) if (!NeedsLerp(mover))
{ {
eye.Rotation = lerpInfo.TargetRotation; _eye.SetRotation(entity, lerpInfo.TargetRotation, eye);
continue; continue;
} }
@@ -205,11 +206,11 @@ public sealed class EyeLerpingSystem : EntitySystem
if (Math.Abs(shortest.Theta) < lerpMinimum) if (Math.Abs(shortest.Theta) < lerpMinimum)
{ {
eye.Rotation = lerpInfo.TargetRotation; _eye.SetRotation(entity, lerpInfo.TargetRotation, eye);
continue; continue;
} }
eye.Rotation = shortest * tickFraction + lerpInfo.LastRotation; _eye.SetRotation(entity, shortest * tickFraction + lerpInfo.LastRotation, eye);
} }
} }
} }

View File

@@ -1,6 +1,5 @@
using System.Numerics; using System.Numerics;
using Content.Client.Viewport; using Content.Client.Viewport;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.State; using Robust.Client.State;
using Robust.Client.Player; using Robust.Client.Player;

View File

@@ -1,7 +1,6 @@
using System.Numerics; using System.Numerics;
using Content.Shared.Movement.Components; using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems; using Content.Shared.Movement.Systems;
using Robust.Client.GameObjects;
using Robust.Client.Player; using Robust.Client.Player;
namespace Content.Client.Movement.Systems; namespace Content.Client.Movement.Systems;

View File

@@ -4,7 +4,6 @@ using Content.Client.Interactable.Components;
using Content.Client.Viewport; using Content.Client.Viewport;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Input; using Robust.Client.Input;
using Robust.Client.Player; using Robust.Client.Player;
@@ -42,7 +41,7 @@ public sealed class InteractionOutlineSystem : EntitySystem
base.Initialize(); base.Initialize();
_configManager.OnValueChanged(CCVars.OutlineEnabled, SetCvarEnabled); _configManager.OnValueChanged(CCVars.OutlineEnabled, SetCvarEnabled);
UpdatesAfter.Add(typeof(EyeUpdateSystem)); UpdatesAfter.Add(typeof(SharedEyeSystem));
} }
public override void Shutdown() public override void Shutdown()

View File

@@ -3,6 +3,7 @@ using System.Numerics;
using Content.Shared.Radiation.Components; using Content.Shared.Radiation.Components;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Graphics;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timing; using Robust.Shared.Timing;

View File

@@ -9,6 +9,7 @@ using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML; using Robust.Client.UserInterface.XAML;
using Robust.Shared.Graphics;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Client.SurveillanceCamera.UI; namespace Content.Client.SurveillanceCamera.UI;

View File

@@ -3,6 +3,7 @@ using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML; using Robust.Client.UserInterface.XAML;
using Robust.Shared.Graphics;
using Robust.Shared.Maths; using Robust.Shared.Maths;
namespace Content.Client.Tabletop.UI namespace Content.Client.Tabletop.UI

View File

@@ -1,5 +1,4 @@
using Content.Shared.Mobs; using Content.Shared.Mobs;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Shared.Enums; using Robust.Shared.Enums;

View File

@@ -1,7 +1,6 @@
using Content.Client.UserInterface.Controls; using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Gameplay; using Content.Client.UserInterface.Systems.Gameplay;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.Player; using Robust.Client.Player;
using Robust.Client.UserInterface.Controllers; using Robust.Client.UserInterface.Controllers;

View File

@@ -7,6 +7,8 @@ namespace Content.Client.Vehicle;
public sealed class VehicleSystem : SharedVehicleSystem public sealed class VehicleSystem : SharedVehicleSystem
{ {
[Dependency] private EyeSystem _eye = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -21,14 +23,18 @@ public sealed class VehicleSystem : SharedVehicleSystem
{ {
// Center the player's eye on the vehicle // Center the player's eye on the vehicle
if (TryComp(uid, out EyeComponent? eyeComp)) 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) private void OnRiderShutdown(EntityUid uid, RiderComponent component, ComponentShutdown args)
{ {
// reset the riders eye centering. // reset the riders eye centering.
if (TryComp(uid, out EyeComponent? eyeComp) && eyeComp.Target == component.Vehicle) 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) private void OnRiderHandleState(EntityUid uid, RiderComponent component, ref ComponentHandleState args)
@@ -39,7 +45,9 @@ public sealed class VehicleSystem : SharedVehicleSystem
var entity = EnsureEntity<RiderComponent>(state.Entity, uid); var entity = EnsureEntity<RiderComponent>(state.Entity, uid);
if (TryComp(uid, out EyeComponent? eyeComp) && eyeComp.Target == component.Vehicle) if (TryComp(uid, out EyeComponent? eyeComp) && eyeComp.Target == component.Vehicle)
eyeComp.Target = entity; {
_eye.SetTarget(uid, entity, eyeComp);
}
component.Vehicle = entity; component.Vehicle = entity;
} }

View File

@@ -5,6 +5,7 @@ using Robust.Client.Graphics;
using Robust.Client.Input; using Robust.Client.Input;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Graphics;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;

View File

@@ -4,11 +4,11 @@ using Content.Server.GameTicking;
using Content.Server.Ghost.Components; using Content.Server.Ghost.Components;
using Content.Server.Mind; using Content.Server.Mind;
using Content.Server.Roles.Jobs; using Content.Server.Roles.Jobs;
using Content.Server.Visible;
using Content.Server.Warps; using Content.Server.Warps;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Eye;
using Content.Shared.Follower; using Content.Shared.Follower;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.Mind; using Content.Shared.Mind;
@@ -37,6 +37,7 @@ namespace Content.Server.Ghost
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly FollowerSystem _followerSystem = default!; [Dependency] private readonly FollowerSystem _followerSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!; [Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedEyeSystem _eye = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly MindSystem _minds = default!; [Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly JobSystem _jobs = default!; [Dependency] private readonly JobSystem _jobs = default!;
@@ -106,7 +107,7 @@ namespace Content.Server.Ghost
private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentStartup args) private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentStartup args)
{ {
// Allow this entity to be seen by other ghosts. // 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) if (_ticker.RunLevel != GameRunLevel.PostRound)
{ {
@@ -115,9 +116,9 @@ namespace Content.Server.Ghost
_visibilitySystem.RefreshVisibility(visibility); _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; var time = _gameTiming.CurTime;
@@ -142,7 +143,7 @@ namespace Content.Server.Ghost
if (!Terminating(uid)) if (!Terminating(uid))
{ {
// Entity can't be seen by ghosts anymore. // 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.RemoveLayer(visibility, (int) VisibilityFlags.Ghost, false);
_visibilitySystem.AddLayer(visibility, (int) VisibilityFlags.Normal, false); _visibilitySystem.AddLayer(visibility, (int) VisibilityFlags.Normal, false);
@@ -150,9 +151,9 @@ namespace Content.Server.Ghost
} }
// Entity can't see ghosts anymore. // 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); _actions.RemoveAction(uid, component.ActionEntity);
@@ -334,9 +335,11 @@ namespace Content.Server.Ghost
if (uid == null if (uid == null
|| !entityManager.HasComponent<GhostComponent>(uid) || !entityManager.HasComponent<GhostComponent>(uid)
|| !entityManager.TryGetComponent<EyeComponent>(uid, out var eyeComponent)) || !entityManager.TryGetComponent<EyeComponent>(uid, out var eyeComponent))
{
return; return;
}
eyeComponent.VisibilityMask ^= (uint) VisibilityFlags.Ghost; entityManager.System<EyeSystem>().SetVisibilityMask(uid.Value, eyeComponent.VisibilityMask ^ (int) VisibilityFlags.Ghost, eyeComponent);
} }
} }
} }

View File

@@ -1,9 +1,9 @@
using System.Linq; using System.Linq;
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.Pointing.Components; using Content.Server.Pointing.Components;
using Content.Server.Visible;
using Content.Shared.Bed.Sleep; using Content.Shared.Bed.Sleep;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Eye;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.IdentityManagement; using Content.Shared.IdentityManagement;
using Content.Shared.Input; using Content.Shared.Input;

View File

@@ -1,5 +1,5 @@
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Visible; using Content.Shared.Eye;
using Content.Shared.Revenant.Components; using Content.Shared.Revenant.Components;
using Content.Shared.Revenant.EntitySystems; using Content.Shared.Revenant.EntitySystems;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;

View File

@@ -3,11 +3,11 @@ using Content.Server.Actions;
using Content.Server.GameTicking; using Content.Server.GameTicking;
using Content.Server.Store.Components; using Content.Server.Store.Components;
using Content.Server.Store.Systems; using Content.Server.Store.Systems;
using Content.Server.Visible;
using Content.Shared.Alert; using Content.Shared.Alert;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.DoAfter; using Content.Shared.DoAfter;
using Content.Shared.Examine; using Content.Shared.Examine;
using Content.Shared.Eye;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Maps; using Content.Shared.Maps;
@@ -31,18 +31,19 @@ public sealed partial class RevenantSystem : EntitySystem
[Dependency] private readonly ActionsSystem _action = default!; [Dependency] private readonly ActionsSystem _action = default!;
[Dependency] private readonly AlertsSystem _alerts = default!; [Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly DamageableSystem _damage = default!; [Dependency] private readonly DamageableSystem _damage = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly MobStateSystem _mobState = default!; [Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly PhysicsSystem _physics = 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 StatusEffectsSystem _statusEffects = default!;
[Dependency] private readonly SharedInteractionSystem _interact = default!; [Dependency] private readonly SharedInteractionSystem _interact = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedStunSystem _stun = default!; [Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly StoreSystem _store = default!; [Dependency] private readonly StoreSystem _store = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly VisibilitySystem _visibility = default!; [Dependency] private readonly VisibilitySystem _visibility = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[ValidatePrototypeId<EntityPrototype>] [ValidatePrototypeId<EntityPrototype>]
private const string RevenantShopId = "ActionRevenantShop"; private const string RevenantShopId = "ActionRevenantShop";
@@ -83,7 +84,9 @@ public sealed partial class RevenantSystem : EntitySystem
//ghost vision //ghost vision
if (TryComp(uid, out EyeComponent? eye)) 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) private void OnMapInit(EntityUid uid, RevenantComponent component, MapInitEvent args)

View File

@@ -1,7 +1,6 @@
using System.Numerics; using System.Numerics;
using Content.Server.Tabletop.Components; using Content.Server.Tabletop.Components;
using Content.Shared.Tabletop.Events; using Content.Shared.Tabletop.Events;
using Robust.Server.GameObjects;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -141,8 +140,8 @@ namespace Content.Server.Tabletop
// Add an eye component and disable FOV // Add an eye component and disable FOV
var eyeComponent = camera.EnsureComponent<EyeComponent>(); var eyeComponent = camera.EnsureComponent<EyeComponent>();
eyeComponent.DrawFov = false; _eye.SetDrawFov(camera, false, eyeComponent);
eyeComponent.Zoom = tabletop.CameraZoom; _eye.SetZoom(camera, tabletop.CameraZoom, eyeComponent);
// Add the user to the view subscribers. If there is no player session, just skip this step // Add the user to the view subscribers. If there is no player session, just skip this step
_viewSubscriberSystem.AddViewSubscriber(camera, player); _viewSubscriberSystem.AddViewSubscriber(camera, player);

View File

@@ -21,7 +21,7 @@ namespace Content.Server.Tabletop
public sealed partial class TabletopSystem : SharedTabletopSystem public sealed partial class TabletopSystem : SharedTabletopSystem
{ {
[Dependency] private readonly IMapManager _mapManager = default!; [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 ViewSubscriberSystem _viewSubscriberSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = 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 // 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.TryGetValue(entity, out var result);
session.Entities.Remove(result); session.Entities.Remove(result);
_entityManager.QueueDeleteEntity(result); QueueDel(result);
} }
private void OnInteractUsing(EntityUid uid, TabletopGameComponent component, InteractUsingEvent args) private void OnInteractUsing(EntityUid uid, TabletopGameComponent component, InteractUsingEvent args)
@@ -94,7 +94,7 @@ namespace Content.Server.Tabletop
var meta = MetaData(handEnt); var meta = MetaData(handEnt);
var protoId = meta.EntityPrototype?.ID; 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 // 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<TabletopDraggableComponent>(hologram); EnsureComp<TabletopDraggableComponent>(hologram);

View File

@@ -1,10 +0,0 @@
namespace Content.Server.Visible
{
[Flags]
public enum VisibilityFlags : uint
{
None = 0,
Normal = 1 << 0,
Ghost = 1 << 1,
}
}

View File

@@ -28,19 +28,13 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
/// </summary> /// </summary>
protected const float KickMagnitudeMax = 1f; protected const float KickMagnitudeMax = 1f;
private ISawmill _log = default!; [Dependency] private readonly SharedEyeSystem _eye = default!;
public override void Initialize()
{
base.Initialize();
_log = Logger.GetSawmill($"ecs.systems.{nameof(SharedCameraRecoilSystem)}");
}
/// <summary> /// <summary>
/// Applies explosion/recoil/etc kickback to the view of the entity. /// Applies explosion/recoil/etc kickback to the view of the entity.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// If the entity is missing <see cref="CameraRecoilComponent" /> and/or <see cref="SharedEyeComponent" />, /// If the entity is missing <see cref="CameraRecoilComponent" /> and/or <see cref="EyeComponent" />,
/// this call will have no effect. It is safe to call this function on any entity. /// this call will have no effect. It is safe to call this function on any entity.
/// </remarks> /// </remarks>
public abstract void KickCamera(EntityUid euid, Vector2 kickback, CameraRecoilComponent? component = null); public abstract void KickCamera(EntityUid euid, Vector2 kickback, CameraRecoilComponent? component = null);
@@ -49,15 +43,15 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
{ {
base.FrameUpdate(frameTime); base.FrameUpdate(frameTime);
foreach (var entity in EntityManager.EntityQuery<SharedEyeComponent, CameraRecoilComponent>(true)) var query = AllEntityQuery<EyeComponent, CameraRecoilComponent>();
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(); var magnitude = recoil.CurrentKick.Length();
if (magnitude <= 0.005f) if (magnitude <= 0.005f)
{ {
recoil.CurrentKick = Vector2.Zero; recoil.CurrentKick = Vector2.Zero;
eye.Offset = recoil.BaseOffset + recoil.CurrentKick; _eye.SetOffset(uid, recoil.BaseOffset + recoil.CurrentKick, eye);
} }
else // Continually restore camera to 0. else // Continually restore camera to 0.
{ {
@@ -72,7 +66,7 @@ public abstract class SharedCameraRecoilSystem : EntitySystem
recoil.CurrentKick = new Vector2(x, y); recoil.CurrentKick = new Vector2(x, y);
eye.Offset = recoil.BaseOffset + recoil.CurrentKick; _eye.SetOffset(uid, recoil.BaseOffset + recoil.CurrentKick, eye);
} }
} }
} }

View File

@@ -138,7 +138,7 @@ namespace Content.Shared.Examine
/// </summary> /// </summary>
public bool IsOccluded(EntityUid uid) public bool IsOccluded(EntityUid uid)
{ {
return TryComp<SharedEyeComponent>(uid, out var eye) && eye.DrawFov; return TryComp<EyeComponent>(uid, out var eye) && eye.DrawFov;
} }
public static bool InRangeUnOccluded(MapCoordinates origin, MapCoordinates other, float range, Ignored? predicate, bool ignoreInsideBlocker = true, IEntityManager? entMan = null) public static bool InRangeUnOccluded(MapCoordinates origin, MapCoordinates other, float range, Ignored? predicate, bool ignoreInsideBlocker = true, IEntityManager? entMan = null)

View File

@@ -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,
}
}

View File

@@ -21,6 +21,8 @@ public abstract class SharedContentEyeSystem : EntitySystem
public static readonly Vector2 DefaultZoom = Vector2.One; public static readonly Vector2 DefaultZoom = Vector2.One;
public static readonly Vector2 MinZoom = DefaultZoom * (float)Math.Pow(ZoomMod, -3); public static readonly Vector2 MinZoom = DefaultZoom * (float)Math.Pow(ZoomMod, -3);
[Dependency] private readonly SharedEyeSystem _eye = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -82,7 +84,7 @@ public abstract class SharedContentEyeSystem : EntitySystem
private void OnContentZoomRequest(RequestTargetZoomEvent msg, EntitySessionEventArgs args) private void OnContentZoomRequest(RequestTargetZoomEvent msg, EntitySessionEventArgs args)
{ {
var ignoreLimit = msg.IgnoreLimit && _admin.HasAdminFlag(args.SenderSession, AdminFlags.Debug); var ignoreLimit = msg.IgnoreLimit && _admin.HasAdminFlag(args.SenderSession, AdminFlags.Debug);
if (TryComp<ContentEyeComponent>(args.SenderSession.AttachedEntity, out var content)) if (TryComp<ContentEyeComponent>(args.SenderSession.AttachedEntity, out var content))
SetZoom(args.SenderSession.AttachedEntity.Value, msg.TargetZoom, ignoreLimit, eye: content); SetZoom(args.SenderSession.AttachedEntity.Value, msg.TargetZoom, ignoreLimit, eye: content);
} }
@@ -95,16 +97,15 @@ public abstract class SharedContentEyeSystem : EntitySystem
if (!HasComp<GhostComponent>(player) && !_admin.IsAdmin(player)) if (!HasComp<GhostComponent>(player) && !_admin.IsAdmin(player))
return; return;
if (TryComp<SharedEyeComponent>(player, out var eyeComp)) if (TryComp<EyeComponent>(player, out var eyeComp))
{ {
eyeComp.DrawFov = msg.Fov; _eye.SetDrawFov(player, msg.Fov, eyeComp);
Dirty(player, eyeComp);
} }
} }
private void OnContentEyeStartup(EntityUid uid, ContentEyeComponent component, ComponentStartup args) private void OnContentEyeStartup(EntityUid uid, ContentEyeComponent component, ComponentStartup args)
{ {
if (!TryComp<SharedEyeComponent>(uid, out var eyeComp)) if (!TryComp<EyeComponent>(uid, out var eyeComp))
return; return;
component.TargetZoom = eyeComp.Zoom; component.TargetZoom = eyeComp.Zoom;

View File

@@ -43,6 +43,9 @@
- type: Actions - type: Actions
- type: Eye - type: Eye
drawFov: false drawFov: false
visMask:
- Normal
- Ghost
- type: ContentEye - type: ContentEye
maxZoom: 1.2, 1.2 maxZoom: 1.2, 1.2
- type: DoAfter - type: DoAfter