* mindcomponent namespace * wip MindRole stuff * admin player tab * mindroletype comment * mindRolePrototype redesign * broken param * wip RoleType implementation * basic role type switching for antags * traitor fix * fix AdminPanel update * the renameningTM * cleanup * feature uncreeping * roletypes on mind roles * update MindComponent.RoleType when MindRoles change * ghostrole configuration * ghostrole config improvements * live update of roleType on the character window * logging stuff and notes * remove thing no one asked for * weh * Mind Role Entities wip * headrev count fix * silicon stuff, cleanup * exclusive antag config, cleanup * jobroleadd overwerite * logging stuff * MindHasRole cleanup, admin log stuff * last second cleanup * ocd * move roletypeprototype to its own file, minor note stuff * remove Roletype.Created * log stuff * roletype setup for ghostroles and autotraitor reinforcements * ghostrole type configs * adjustable admin overlay * cleanup * fix this in its own PR * silicon antagonist * borg stuff * mmi roletype handling * spawnable borg roletype handling * weh * ghost role cleanup * weh * RoleEvent update * polish * log stuff * admin overlay config * ghostrolecomponent cleanup * weh * admin overlay code cleanup * minor cleanup * Obsolete MindRoleAddedEvent * comment * minor code cleanup * MindOnDoGreeting fix * Role update message * fix duplicate job greeting for cyborgs * fix emag job message dupe * nicer-looking role type update * crew aligned * syndicate assault borg role fix * fix test fail * fix a merge mistake * fix LoneOp role type * Update Content.Client/Administration/AdminNameOverlay.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Update Content.Shared/Roles/SharedRoleSystem.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * comment formatting Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * change logging category Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * fix a space Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * use MindAddRoles Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * get MindComponent from TryGetMind Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * move var declaration outside loop * remove TryComp * take RoleEnum behind the barn * don't use ensurecomp unnecessarily * cvar comments * toggleableghostrolecomponent documentation * skrek * use EntProtoId * mindrole config * merge baserolecomponent into basemindrolecomponent * ai and borg silicon role tweaks * formatting Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * I will end you (the color) Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * use LocId type for a locale id * update RoleEvent documentation * update RoleEvent documentation * remove obsolete MindRoleAddedEvent * refine MindRolesUpdate() * use dependency Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * inject dependency Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * roleType.Name no longer required * reformatted draw code logic * GhostRoleMarkerRoleComponent comment * minor SharedRoleSystem cleanup * StartingMindRoleComponent, unhardcode roundstart silicon * Update Content.Shared/Roles/SharedRoleSystem.cs * remove a whitespace --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
101 lines
4.0 KiB
C#
101 lines
4.0 KiB
C#
using System.Linq;
|
|
using System.Numerics;
|
|
using Content.Client.Administration.Systems;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.Mind;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.ResourceManagement;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.Administration;
|
|
|
|
internal sealed class AdminNameOverlay : Overlay
|
|
{
|
|
[Dependency] private readonly IConfigurationManager _config = default!;
|
|
|
|
private readonly AdminSystem _system;
|
|
private readonly IEntityManager _entityManager;
|
|
private readonly IEyeManager _eyeManager;
|
|
private readonly EntityLookupSystem _entityLookup;
|
|
private readonly IUserInterfaceManager _userInterfaceManager;
|
|
private readonly Font _font;
|
|
|
|
//TODO make this adjustable via GUI
|
|
private readonly ProtoId<RoleTypePrototype>[] _filter =
|
|
["SoloAntagonist", "TeamAntagonist", "SiliconAntagonist", "FreeAgent"];
|
|
private readonly string _antagLabelClassic = Loc.GetString("admin-overlay-antag-classic");
|
|
private readonly Color _antagColorClassic = Color.OrangeRed;
|
|
|
|
public AdminNameOverlay(AdminSystem system, IEntityManager entityManager, IEyeManager eyeManager, IResourceCache resourceCache, EntityLookupSystem entityLookup, IUserInterfaceManager userInterfaceManager)
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
_system = system;
|
|
_entityManager = entityManager;
|
|
_eyeManager = eyeManager;
|
|
_entityLookup = entityLookup;
|
|
_userInterfaceManager = userInterfaceManager;
|
|
ZIndex = 200;
|
|
_font = new VectorFont(resourceCache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
|
|
}
|
|
|
|
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
|
|
|
|
protected override void Draw(in OverlayDrawArgs args)
|
|
{
|
|
var viewport = args.WorldAABB;
|
|
|
|
//TODO make this adjustable via GUI
|
|
var classic = _config.GetCVar(CCVars.AdminOverlayClassic);
|
|
|
|
foreach (var playerInfo in _system.PlayerList)
|
|
{
|
|
var entity = _entityManager.GetEntity(playerInfo.NetEntity);
|
|
|
|
// Otherwise the entity can not exist yet
|
|
if (entity == null || !_entityManager.EntityExists(entity))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// if not on the same map, continue
|
|
if (_entityManager.GetComponent<TransformComponent>(entity.Value).MapID != args.MapId)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var aabb = _entityLookup.GetWorldAABB(entity.Value);
|
|
|
|
// if not on screen, continue
|
|
if (!aabb.Intersects(in viewport))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var uiScale = _userInterfaceManager.RootControl.UIScale;
|
|
var lineoffset = new Vector2(0f, 11f) * uiScale;
|
|
var screenCoordinates = _eyeManager.WorldToScreen(aabb.Center +
|
|
new Angle(-_eyeManager.CurrentEye.Rotation).RotateVec(
|
|
aabb.TopRight - aabb.Center)) + new Vector2(1f, 7f);
|
|
|
|
if (classic && playerInfo.Antag)
|
|
{
|
|
args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), _antagLabelClassic, uiScale, _antagColorClassic);
|
|
}
|
|
else if (!classic && _filter.Contains(playerInfo.RoleProto.ID))
|
|
{
|
|
var label = Loc.GetString(playerInfo.RoleProto.Name).ToUpper();
|
|
var color = playerInfo.RoleProto.Color;
|
|
|
|
args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), label, uiScale, color);
|
|
}
|
|
|
|
args.ScreenHandle.DrawString(_font, screenCoordinates + lineoffset, playerInfo.Username, uiScale, playerInfo.Connected ? Color.Yellow : Color.White);
|
|
args.ScreenHandle.DrawString(_font, screenCoordinates, playerInfo.CharacterName, uiScale, playerInfo.Connected ? Color.Aquamarine : Color.White);
|
|
}
|
|
}
|
|
}
|