Fix ghost FOV bug (#21614)
This commit is contained in:
@@ -14,8 +14,8 @@ namespace Content.Client.Ghost
|
||||
[Dependency] private readonly IClientConsoleHost _console = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
||||
[Dependency] private readonly ILightManager _lightManager = default!;
|
||||
[Dependency] private readonly ContentEyeSystem _contentEye = default!;
|
||||
[Dependency] private readonly EyeSystem _eye = default!;
|
||||
|
||||
public int AvailableGhostRoleCount { get; private set; }
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Content.Client.Ghost
|
||||
var query = AllEntityQuery<GhostComponent, SpriteComponent>();
|
||||
while (query.MoveNext(out var uid, out _, out var sprite))
|
||||
{
|
||||
sprite.Visible = value || uid == _playerManager.LocalPlayer?.ControlledEntity;
|
||||
sprite.Visible = value || uid == _playerManager.LocalEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,39 +62,37 @@ namespace Content.Client.Ghost
|
||||
SubscribeLocalEvent<GhostComponent, LocalPlayerAttachedEvent>(OnGhostPlayerAttach);
|
||||
SubscribeLocalEvent<GhostComponent, LocalPlayerDetachedEvent>(OnGhostPlayerDetach);
|
||||
|
||||
SubscribeLocalEvent<LocalPlayerAttachedEvent>(OnPlayerAttach);
|
||||
|
||||
SubscribeNetworkEvent<GhostWarpsResponseEvent>(OnGhostWarpsResponse);
|
||||
SubscribeNetworkEvent<GhostUpdateGhostRoleCountEvent>(OnUpdateGhostRoleCount);
|
||||
|
||||
SubscribeLocalEvent<GhostComponent, ToggleLightingActionEvent>(OnToggleLighting);
|
||||
SubscribeLocalEvent<GhostComponent, ToggleFoVActionEvent>(OnToggleFoV);
|
||||
SubscribeLocalEvent<EyeComponent, ToggleLightingActionEvent>(OnToggleLighting);
|
||||
SubscribeLocalEvent<EyeComponent, ToggleFoVActionEvent>(OnToggleFoV);
|
||||
SubscribeLocalEvent<GhostComponent, ToggleGhostsActionEvent>(OnToggleGhosts);
|
||||
}
|
||||
|
||||
private void OnStartup(EntityUid uid, GhostComponent component, ComponentStartup args)
|
||||
{
|
||||
if (TryComp(uid, out SpriteComponent? sprite))
|
||||
sprite.Visible = GhostVisibility;
|
||||
sprite.Visible = GhostVisibility || uid == _playerManager.LocalEntity;
|
||||
}
|
||||
|
||||
private void OnToggleLighting(EntityUid uid, GhostComponent component, ToggleLightingActionEvent args)
|
||||
private void OnToggleLighting(EntityUid uid, EyeComponent component, ToggleLightingActionEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-lighting-manager-popup"), args.Performer);
|
||||
_lightManager.Enabled = !_lightManager.Enabled;
|
||||
_contentEye.RequestToggleLight(uid, component);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnToggleFoV(EntityUid uid, GhostComponent component, ToggleFoVActionEvent args)
|
||||
private void OnToggleFoV(EntityUid uid, EyeComponent component, ToggleFoVActionEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-fov-popup"), args.Performer);
|
||||
_contentEye.RequestToggleFov(uid);
|
||||
_contentEye.RequestToggleFov(uid, component);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
@@ -105,7 +103,7 @@ namespace Content.Client.Ghost
|
||||
|
||||
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-ghost-visibility-popup"), args.Performer);
|
||||
|
||||
if (uid == _playerManager.LocalPlayer?.ControlledEntity)
|
||||
if (uid == _playerManager.LocalEntity)
|
||||
ToggleGhostVisibility();
|
||||
|
||||
args.Handled = true;
|
||||
@@ -118,26 +116,16 @@ namespace Content.Client.Ghost
|
||||
_actions.RemoveAction(uid, component.ToggleGhostsActionEntity);
|
||||
_actions.RemoveAction(uid, component.ToggleGhostHearingActionEntity);
|
||||
|
||||
if (uid != _playerManager.LocalPlayer?.ControlledEntity)
|
||||
if (uid != _playerManager.LocalEntity)
|
||||
return;
|
||||
|
||||
_lightManager.Enabled = true;
|
||||
|
||||
if (component.IsAttached)
|
||||
{
|
||||
GhostVisibility = false;
|
||||
}
|
||||
|
||||
GhostVisibility = false;
|
||||
PlayerRemoved?.Invoke(component);
|
||||
}
|
||||
|
||||
private void OnGhostPlayerAttach(EntityUid uid, GhostComponent component, LocalPlayerAttachedEvent localPlayerAttachedEvent)
|
||||
{
|
||||
if (uid != _playerManager.LocalPlayer?.ControlledEntity)
|
||||
return;
|
||||
|
||||
GhostVisibility = true;
|
||||
component.IsAttached = true;
|
||||
PlayerAttached?.Invoke(component);
|
||||
}
|
||||
|
||||
@@ -146,32 +134,16 @@ namespace Content.Client.Ghost
|
||||
if (TryComp<SpriteComponent>(uid, out var sprite))
|
||||
sprite.LayerSetColor(0, component.color);
|
||||
|
||||
if (uid != _playerManager.LocalPlayer?.ControlledEntity)
|
||||
if (uid != _playerManager.LocalEntity)
|
||||
return;
|
||||
|
||||
PlayerUpdated?.Invoke(component);
|
||||
}
|
||||
|
||||
private bool PlayerDetach(EntityUid uid)
|
||||
{
|
||||
if (uid != _playerManager.LocalPlayer?.ControlledEntity)
|
||||
return false;
|
||||
|
||||
GhostVisibility = false;
|
||||
PlayerDetached?.Invoke();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnGhostPlayerDetach(EntityUid uid, GhostComponent component, LocalPlayerDetachedEvent args)
|
||||
{
|
||||
if (PlayerDetach(uid))
|
||||
component.IsAttached = false;
|
||||
}
|
||||
|
||||
private void OnPlayerAttach(LocalPlayerAttachedEvent ev)
|
||||
{
|
||||
if (!HasComp<GhostComponent>(ev.Entity))
|
||||
PlayerDetach(ev.Entity);
|
||||
GhostVisibility = false;
|
||||
PlayerDetached?.Invoke();
|
||||
}
|
||||
|
||||
private void OnGhostWarpsResponse(GhostWarpsResponseEvent msg)
|
||||
|
||||
Reference in New Issue
Block a user