Allow zoom command to modify an eye's PVS range (#29245)
Allow zoom command to modify an eye's PVS range Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,9 @@ public abstract class SharedContentEyeSystem : EntitySystem
|
||||
{
|
||||
[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);
|
||||
@@ -29,6 +32,7 @@ public abstract class SharedContentEyeSystem : EntitySystem
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<ContentEyeComponent, ComponentStartup>(OnContentEyeStartup);
|
||||
SubscribeAllEvent<RequestTargetZoomEvent>(OnContentZoomRequest);
|
||||
SubscribeAllEvent<RequestPvsScaleEvent>(OnPvsScale);
|
||||
SubscribeAllEvent<RequestEyeEvent>(OnRequestEye);
|
||||
|
||||
CommandBinds.Builder
|
||||
@@ -84,12 +88,18 @@ public abstract class SharedContentEyeSystem : EntitySystem
|
||||
|
||||
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)
|
||||
@@ -116,6 +126,7 @@ public abstract class SharedContentEyeSystem : EntitySystem
|
||||
|
||||
public void ResetZoom(EntityUid uid, ContentEyeComponent? component = null)
|
||||
{
|
||||
_eye.SetPvsScale(uid, 1);
|
||||
SetZoom(uid, DefaultZoom, eye: component);
|
||||
}
|
||||
|
||||
@@ -146,6 +157,15 @@ public abstract class SharedContentEyeSystem : EntitySystem
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user