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

@@ -301,6 +301,18 @@ namespace Content.Shared.Chemistry.Components
return total;
}
public FixedPoint2 GetTotalPrototypeQuantity(string id)
{
var total = FixedPoint2.Zero;
foreach (var (reagent, quantity) in Contents)
{
if (id == reagent.Prototype)
total += quantity;
}
return total;
}
public ReagentId? GetPrimaryReagentId()
{
if (Contents.Count == 0)

View File

@@ -8,10 +8,6 @@ namespace Content.Shared.Ghost;
[AutoGenerateComponentState(true)]
public sealed partial class GhostComponent : Component
{
// I have no idea what this means I just wanted to kill comp references.
[ViewVariables]
public bool IsAttached;
// Actions
[DataField]
public EntProtoId ToggleLightingAction = "ActionToggleLighting";

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;
}
}
}