Fix ghost FOV bug (#21614)

This commit is contained in:
Leon Friedrich
2023-11-13 05:36:00 +11:00
committed by GitHub
parent b9b706bda9
commit c9e2a91f13
5 changed files with 50 additions and 58 deletions

View File

@@ -28,7 +28,7 @@ public abstract class SharedContentEyeSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent<ContentEyeComponent, ComponentStartup>(OnContentEyeStartup);
SubscribeAllEvent<RequestTargetZoomEvent>(OnContentZoomRequest);
SubscribeAllEvent<RequestFovEvent>(OnRequestFov);
SubscribeAllEvent<RequestEyeEvent>(OnRequestEye);
CommandBinds.Builder
.Bind(ContentKeyFunctions.ZoomIn, InputCmdHandler.FromDelegate(ZoomIn, handle:false))
@@ -89,7 +89,7 @@ public abstract class SharedContentEyeSystem : EntitySystem
SetZoom(args.SenderSession.AttachedEntity.Value, msg.TargetZoom, ignoreLimit, eye: content);
}
private void OnRequestFov(RequestFovEvent msg, EntitySessionEventArgs args)
private void OnRequestEye(RequestEyeEvent msg, EntitySessionEventArgs args)
{
if (args.SenderSession.AttachedEntity is not { } player)
return;
@@ -99,7 +99,8 @@ public abstract class SharedContentEyeSystem : EntitySystem
if (TryComp<EyeComponent>(player, out var eyeComp))
{
_eye.SetDrawFov(player, msg.Fov, eyeComp);
_eye.SetDrawFov(player, msg.DrawFov, eyeComp);
_eye.SetDrawLight((player, eyeComp), msg.DrawLight);
}
}
@@ -141,8 +142,15 @@ public abstract class SharedContentEyeSystem : EntitySystem
/// Sendable from client to server to request changing fov.
/// </summary>
[Serializable, NetSerializable]
public sealed class RequestFovEvent : EntityEventArgs
public sealed class RequestEyeEvent : EntityEventArgs
{
public bool Fov;
public readonly bool DrawFov;
public readonly bool DrawLight;
public RequestEyeEvent(bool drawFov, bool drawLight)
{
DrawFov = drawFov;
DrawLight = drawLight;
}
}
}