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
base.Initialize();
_sawmill = Logger.GetSawmill("drag_drop");
UpdatesOutsidePrediction = true;
- UpdatesAfter.Add(typeof(EyeUpdateSystem));
+ UpdatesAfter.Add(typeof(SharedEyeSystem));
_cfgMan.OnValueChanged(CCVars.DragDropDeadZone, SetDeadZone, true);
using Content.Shared.Drugs;
using Content.Shared.StatusEffect;
-using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Content.Shared.Drunk;
using Content.Shared.StatusEffect;
-using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
-using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
-using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
{
[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!;
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;
}
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);
}
}
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)
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
if (!NeedsLerp(mover))
{
- eye.Rotation = lerpInfo.TargetRotation;
+ _eye.SetRotation(entity, lerpInfo.TargetRotation, eye);
continue;
}
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);
}
}
}
using System.Numerics;
using Content.Client.Viewport;
-using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.State;
using Robust.Client.Player;
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;
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;
base.Initialize();
_configManager.OnValueChanged(CCVars.OutlineEnabled, SetCvarEnabled);
- UpdatesAfter.Add(typeof(EyeUpdateSystem));
+ UpdatesAfter.Add(typeof(SharedEyeSystem));
}
public override void Shutdown()
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;
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;
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
using Content.Shared.Mobs;
-using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
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;
public sealed class VehicleSystem : SharedVehicleSystem
{
+ [Dependency] private EyeSystem _eye = default!;
+
public override void Initialize()
{
base.Initialize();
{
// 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)
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;
}
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;
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;
[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!;
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)
{
_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;
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);
}
// 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);
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);
}
}
}
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;
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;
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;
[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";
//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)
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;
// Add an eye component and disable FOV
var eyeComponent = camera.EnsureComponent<EyeComponent>();
- 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);
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!;
// 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)
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<TabletopDraggableComponent>(hologram);
+++ /dev/null
-namespace Content.Server.Visible
-{
- [Flags]
- public enum VisibilityFlags : uint
- {
- None = 0,
- Normal = 1 << 0,
- Ghost = 1 << 1,
- }
-}
/// </summary>
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!;
/// <summary>
/// Applies explosion/recoil/etc kickback to the view of the entity.
/// </summary>
/// <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.
/// </remarks>
public abstract void KickCamera(EntityUid euid, Vector2 kickback, CameraRecoilComponent? component = null);
{
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();
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.
{
recoil.CurrentKick = new Vector2(x, y);
- eye.Offset = recoil.BaseOffset + recoil.CurrentKick;
+ _eye.SetOffset(uid, recoil.BaseOffset + recoil.CurrentKick, eye);
}
}
}
/// </summary>
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)
--- /dev/null
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.Eye
+{
+ [Flags]
+ [FlagsFor(typeof(VisibilityMaskLayer))]
+ public enum VisibilityFlags : int
+ {
+ None = 0,
+ Normal = 1 << 0,
+ Ghost = 1 << 1,
+ }
+}
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();
private void OnContentZoomRequest(RequestTargetZoomEvent msg, EntitySessionEventArgs args)
{
var ignoreLimit = msg.IgnoreLimit && _admin.HasAdminFlag(args.SenderSession, AdminFlags.Debug);
-
+
if (TryComp<ContentEyeComponent>(args.SenderSession.AttachedEntity, out var content))
SetZoom(args.SenderSession.AttachedEntity.Value, msg.TargetZoom, ignoreLimit, eye: content);
}
if (!HasComp<GhostComponent>(player) && !_admin.IsAdmin(player))
return;
- if (TryComp<SharedEyeComponent>(player, out var eyeComp))
+ if (TryComp<EyeComponent>(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<SharedEyeComponent>(uid, out var eyeComp))
+ if (!TryComp<EyeComponent>(uid, out var eyeComp))
return;
component.TargetZoom = eyeComp.Zoom;
- type: Actions
- type: Eye
drawFov: false
+ visMask:
+ - Normal
+ - Ghost
- type: ContentEye
maxZoom: 1.2, 1.2
- type: DoAfter