public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
Vector2 zoom;
- if (args.Length is not (1 or 2))
+ if (args.Length is not (1 or 2 or 3))
{
shell.WriteLine(Help);
return;
}
}
+ var scalePvs = true;
+ if (args.Length == 3 && !bool.TryParse(args[2], out scalePvs))
+ {
+ shell.WriteError(LocalizationManager.GetString("cmd-parse-failure-bool", ("arg", args[2])));
+ return;
+ }
+
var player = _playerManager.LocalSession?.AttachedEntity;
if (_entityManager.TryGetComponent<ContentEyeComponent>(player, out var content))
{
- _entityManager.System<ContentEyeSystem>().RequestZoom(player.Value, zoom, true, content);
+ _entityManager.System<ContentEyeSystem>().RequestZoom(player.Value, zoom, true, scalePvs, content);
return;
}
{
[Dependency] private readonly IPlayerManager _player = default!;
- public void RequestZoom(EntityUid uid, Vector2 zoom, bool ignoreLimit, ContentEyeComponent? content = null)
+ public void RequestZoom(EntityUid uid, Vector2 zoom, bool ignoreLimit, bool scalePvs, ContentEyeComponent? content = null)
{
if (!Resolve(uid, ref content, false))
return;
TargetZoom = zoom,
IgnoreLimit = ignoreLimit,
});
+
+ if (scalePvs)
+ RequestPvsScale(Math.Max(zoom.X, zoom.Y));
+ }
+
+ public void RequestPvsScale(float scale)
+ {
+ RaiseNetworkEvent(new RequestPvsScaleEvent(scale));
}
public void RequestToggleFov()
[NetworkedComponent]
public sealed partial class CameraRecoilComponent : Component
{
+ [ViewVariables(VVAccess.ReadWrite)]
public Vector2 CurrentKick { get; set; }
+
+ [ViewVariables(VVAccess.ReadWrite)]
public Vector2 LastKick { get; set; }
+
+ [ViewVariables(VVAccess.ReadWrite)]
public float LastKickTime { get; set; }
/// <summary>
/// Basically I needed a way to chain this effect for the attack lunge animation. Sorry!
/// </summary>
+ ///
+ [ViewVariables(VVAccess.ReadWrite)]
public Vector2 BaseOffset { get; set; }
}
private void UpdateEyes(float frameTime)
{
- var query = AllEntityQuery<EyeComponent, CameraRecoilComponent>();
+ var query = AllEntityQuery<CameraRecoilComponent, EyeComponent>();
- while (query.MoveNext(out var uid, out var eye, out var recoil))
+ while (query.MoveNext(out var uid, out var recoil, out var eye))
{
var magnitude = recoil.CurrentKick.Length();
if (magnitude <= 0.005f)
{
[Dependency] private readonly ISharedAdminManager _admin = default!;
+ // Admin flags required to ignore normal eye restrictions.
+ public const AdminFlags EyeFlag = AdminFlags.Debug;
+
public const float ZoomMod = 1.5f;
public static readonly Vector2 DefaultZoom = Vector2.One;
public static readonly Vector2 MinZoom = DefaultZoom * (float)Math.Pow(ZoomMod, -3);
base.Initialize();
SubscribeLocalEvent<ContentEyeComponent, ComponentStartup>(OnContentEyeStartup);
SubscribeAllEvent<RequestTargetZoomEvent>(OnContentZoomRequest);
+ SubscribeAllEvent<RequestPvsScaleEvent>(OnPvsScale);
SubscribeAllEvent<RequestEyeEvent>(OnRequestEye);
CommandBinds.Builder
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, EyeFlag);
if (TryComp<ContentEyeComponent>(args.SenderSession.AttachedEntity, out var content))
SetZoom(args.SenderSession.AttachedEntity.Value, msg.TargetZoom, ignoreLimit, eye: content);
}
+ private void OnPvsScale(RequestPvsScaleEvent ev, EntitySessionEventArgs args)
+ {
+ if (args.SenderSession.AttachedEntity is {} uid && _admin.HasAdminFlag(args.SenderSession, EyeFlag))
+ _eye.SetPvsScale(uid, ev.Scale);
+ }
+
private void OnRequestEye(RequestEyeEvent msg, EntitySessionEventArgs args)
{
if (args.SenderSession.AttachedEntity is not { } player)
public void ResetZoom(EntityUid uid, ContentEyeComponent? component = null)
{
+ _eye.SetPvsScale(uid, 1);
SetZoom(uid, DefaultZoom, eye: component);
}
public bool IgnoreLimit;
}
+ /// <summary>
+ /// Client->Server request for new PVS scale.
+ /// </summary>
+ [Serializable, NetSerializable]
+ public sealed class RequestPvsScaleEvent(float scale) : EntityEventArgs
+ {
+ public float Scale = scale;
+ }
+
/// <summary>
/// Sendable from client to server to request changing fov.
/// </summary>
-cmd-zoom-desc = Sets the zoom of the main eye.
-cmd-zoom-help = zoom ( <scale> | <X-scale> <Y-scale> )
+cmd-zoom-desc = Sets the zoom of the main eye. Optionally also changes the eye's PVS range.
+cmd-zoom-help = zoom ( <scale> | <X-scale> <Y-scale> [bool])
cmd-zoom-error = scale has to be greater than 0