Fix arrow visibility for ghosts.
metacomming bad
This commit is contained in:
@@ -2,10 +2,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Server.GameObjects.Components.Pointing;
|
using Content.Server.GameObjects.Components.Pointing;
|
||||||
|
using Content.Server.Players;
|
||||||
|
using Content.Server.Utility;
|
||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||||
using Robust.Server.GameObjects.Components;
|
using Robust.Server.GameObjects.Components;
|
||||||
using Robust.Server.Interfaces.Player;
|
using Robust.Server.Interfaces.Player;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
@@ -40,6 +43,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Dictionary<ICommonSession, TimeSpan> _pointers = new Dictionary<ICommonSession, TimeSpan>();
|
private readonly Dictionary<ICommonSession, TimeSpan> _pointers = new Dictionary<ICommonSession, TimeSpan>();
|
||||||
|
|
||||||
|
private const float PointingRange = 15f;
|
||||||
|
|
||||||
private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)
|
private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.NewStatus != SessionStatus.Disconnected)
|
if (e.NewStatus != SessionStatus.Disconnected)
|
||||||
@@ -79,7 +84,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
|
|
||||||
public bool TryPoint(ICommonSession? session, GridCoordinates coords, EntityUid uid)
|
public bool TryPoint(ICommonSession? session, GridCoordinates coords, EntityUid uid)
|
||||||
{
|
{
|
||||||
var player = session?.AttachedEntity;
|
var player = (session as IPlayerSession)?.ContentData().Mind.CurrentEntity;
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -112,16 +117,27 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var viewers = _playerManager.GetPlayersInRange(player.Transform.GridPosition, 15);
|
|
||||||
|
|
||||||
var arrow = EntityManager.SpawnEntity("pointingarrow", coords);
|
var arrow = EntityManager.SpawnEntity("pointingarrow", coords);
|
||||||
|
|
||||||
|
var layer = (int)VisibilityFlags.Normal;
|
||||||
if (player.TryGetComponent(out VisibilityComponent? playerVisibility))
|
if (player.TryGetComponent(out VisibilityComponent? playerVisibility))
|
||||||
{
|
{
|
||||||
var arrowVisibility = arrow.EnsureComponent<VisibilityComponent>();
|
var arrowVisibility = arrow.EnsureComponent<VisibilityComponent>();
|
||||||
arrowVisibility.Layer = playerVisibility.Layer;
|
layer = arrowVisibility.Layer = playerVisibility.Layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get players that are in range and whose visibility layer matches the arrow's.
|
||||||
|
var viewers = _playerManager.GetPlayersBy((playerSession) =>
|
||||||
|
{
|
||||||
|
if ((playerSession.VisibilityMask & layer) == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var ent = playerSession.ContentData().Mind.CurrentEntity;
|
||||||
|
|
||||||
|
return ent != null
|
||||||
|
&& ent.Transform.MapPosition.InRange(player.Transform.MapPosition, PointingRange);
|
||||||
|
});
|
||||||
|
|
||||||
string selfMessage;
|
string selfMessage;
|
||||||
string viewerMessage;
|
string viewerMessage;
|
||||||
string? viewerPointedAtMessage = null;
|
string? viewerPointedAtMessage = null;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Content.Server.GameObjects
|
|||||||
[Flags]
|
[Flags]
|
||||||
public enum VisibilityFlags
|
public enum VisibilityFlags
|
||||||
{
|
{
|
||||||
|
Normal = 1,
|
||||||
Ghost = 2,
|
Ghost = 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user