2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Examine;
|
2020-10-09 18:57:09 +02:00
|
|
|
using Robust.Client.Graphics;
|
2021-01-04 09:17:44 +01:00
|
|
|
using Robust.Client.Player;
|
2020-10-09 18:57:09 +02:00
|
|
|
using Robust.Client.ResourceManagement;
|
2021-09-20 08:40:22 +02:00
|
|
|
using Robust.Shared.Containers;
|
2021-03-09 04:33:41 -06:00
|
|
|
using Robust.Shared.Enums;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-01-04 09:17:44 +01:00
|
|
|
using Robust.Shared.IoC;
|
2020-10-09 18:57:09 +02:00
|
|
|
using Robust.Shared.Localization;
|
|
|
|
|
using Robust.Shared.Maths;
|
2021-03-08 04:09:59 +11:00
|
|
|
using Robust.Shared.Physics;
|
2020-10-09 18:57:09 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Suspicion
|
2020-10-09 18:57:09 +02:00
|
|
|
{
|
|
|
|
|
public class TraitorOverlay : Overlay
|
|
|
|
|
{
|
|
|
|
|
private readonly IEntityManager _entityManager;
|
|
|
|
|
private readonly IEyeManager _eyeManager;
|
2021-01-04 09:17:44 +01:00
|
|
|
private readonly IPlayerManager _playerManager;
|
2020-10-09 18:57:09 +02:00
|
|
|
|
|
|
|
|
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
|
|
|
|
private readonly Font _font;
|
|
|
|
|
|
2021-06-21 02:13:54 +02:00
|
|
|
private readonly string _traitorText = Loc.GetString("traitor-overlay-traitor-text");
|
2020-10-09 18:57:09 +02:00
|
|
|
|
|
|
|
|
public TraitorOverlay(
|
|
|
|
|
IEntityManager entityManager,
|
|
|
|
|
IResourceCache resourceCache,
|
|
|
|
|
IEyeManager eyeManager)
|
|
|
|
|
{
|
2021-01-04 09:17:44 +01:00
|
|
|
_playerManager = IoCManager.Resolve<IPlayerManager>();
|
|
|
|
|
|
2020-10-09 18:57:09 +02:00
|
|
|
_entityManager = entityManager;
|
|
|
|
|
_eyeManager = eyeManager;
|
|
|
|
|
|
|
|
|
|
_font = new VectorFont(resourceCache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-19 09:52:40 +02:00
|
|
|
protected override void Draw(in OverlayDrawArgs args)
|
2020-10-09 18:57:09 +02:00
|
|
|
{
|
|
|
|
|
var viewport = _eyeManager.GetWorldViewport();
|
|
|
|
|
|
2021-01-04 09:17:44 +01:00
|
|
|
var ent = _playerManager.LocalPlayer?.ControlledEntity;
|
2021-03-10 14:48:29 +01:00
|
|
|
if (ent == null || ent.TryGetComponent(out SuspicionRoleComponent? sus) != true)
|
2021-01-04 09:17:44 +01:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var (_, uid) in sus.Allies)
|
2020-10-09 18:57:09 +02:00
|
|
|
{
|
|
|
|
|
// Otherwise the entity can not exist yet
|
|
|
|
|
if (!_entityManager.TryGetEntity(uid, out var ally))
|
|
|
|
|
{
|
2021-01-10 15:50:04 -08:00
|
|
|
continue;
|
2020-10-09 18:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
2021-03-10 14:48:29 +01:00
|
|
|
if (!ally.TryGetComponent(out IPhysBody? physics))
|
2020-10-09 18:57:09 +02:00
|
|
|
{
|
2021-01-10 15:50:04 -08:00
|
|
|
continue;
|
2020-10-09 18:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-04 09:17:44 +01:00
|
|
|
if (!ExamineSystemShared.InRangeUnOccluded(ent.Transform.MapPosition, ally.Transform.MapPosition, 15,
|
|
|
|
|
entity => entity == ent || entity == ally))
|
2020-10-09 18:57:09 +02:00
|
|
|
{
|
2021-01-10 15:50:04 -08:00
|
|
|
continue;
|
2020-10-09 18:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if not on the same map, continue
|
2021-09-20 08:40:22 +02:00
|
|
|
if (physics.Owner.Transform.MapID != _eyeManager.CurrentMap || physics.Owner.IsInContainer())
|
2020-10-09 18:57:09 +02:00
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-08 04:09:59 +11:00
|
|
|
var worldBox = physics.GetWorldAABB();
|
2020-10-09 18:57:09 +02:00
|
|
|
|
|
|
|
|
// if not on screen, or too small, continue
|
|
|
|
|
if (!worldBox.Intersects(in viewport) || worldBox.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-19 09:52:40 +02:00
|
|
|
var screenCoordinates = args.ViewportControl!.WorldToScreen(physics.GetWorldAABB().TopLeft + (0, 0.5f));
|
2021-06-26 03:26:57 +02:00
|
|
|
args.ScreenHandle.DrawString(_font, screenCoordinates, _traitorText, Color.OrangeRed);
|
2020-10-09 18:57:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|