From 46d58bf22a071f57efaeb7ad50396c8d86d578e6 Mon Sep 17 00:00:00 2001 From: Errant <35878406+Errant-4@users.noreply.github.com> Date: Sat, 11 Jan 2025 22:17:26 +0100 Subject: [PATCH] Role Types (#33420) * 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> --- .../Administration/AdminNameOverlay.cs | 36 ++++- .../UI/Tabs/PlayerTab/PlayerTab.xaml.cs | 1 + .../UI/Tabs/PlayerTab/PlayerTabEntry.xaml | 5 + .../UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs | 2 + .../UI/Tabs/PlayerTab/PlayerTabHeader.xaml | 7 + .../UI/Tabs/PlayerTab/PlayerTabHeader.xaml.cs | 10 ++ .../Character/CharacterUIController.cs | 54 ++++++- .../Character/Windows/CharacterWindow.xaml | 1 + .../Administration/Systems/AdminSystem.cs | 17 ++- .../Components/AntagSelectionComponent.cs | 2 +- .../GameTicking/GameTicker.Spawning.cs | 5 +- Content.Server/Ghost/ObserverRoleComponent.cs | 6 +- .../Roles/Components/GhostRoleComponent.cs | 13 +- .../ToggleableGhostRoleComponent.cs | 66 +++++++-- .../Roles/GhostRoleMarkerRoleComponent.cs | 8 +- Content.Server/Ghost/Roles/GhostRoleSystem.cs | 11 +- .../Ghost/Roles/ToggleableGhostRoleSystem.cs | 3 + .../PlayTimeTrackingSystem.cs | 12 +- Content.Server/Roles/Jobs/JobSystem.cs | 19 ++- Content.Server/Roles/RoleBriefingComponent.cs | 8 +- Content.Server/Roles/RoleSystem.cs | 32 +++++ .../Silicons/Borgs/BorgSystem.MMI.cs | 17 ++- Content.Server/Silicons/Borgs/BorgSystem.cs | 1 - .../Silicons/Laws/SiliconLawSystem.cs | 2 +- Content.Shared/Administration/PlayerInfo.cs | 2 + Content.Shared/CCVar/CCVars.Interface.cs | 21 +++ Content.Shared/Mind/MindComponent.cs | 7 + Content.Shared/Mind/RoleTypePrototype.cs | 25 ++++ Content.Shared/Roles/MindIsAntagonistEvent.cs | 2 +- Content.Shared/Roles/MindRoleAddedEvent.cs | 8 -- Content.Shared/Roles/MindRoleComponent.cs | 8 +- Content.Shared/Roles/RoleAddedEvent.cs | 8 +- Content.Shared/Roles/RoleEvent.cs | 6 +- Content.Shared/Roles/RoleRemovedEvent.cs | 9 +- Content.Shared/Roles/SharedRoleSystem.cs | 134 +++++++++++++++--- .../Roles/SiliconBrainRoleComponent.cs | 9 ++ .../Roles/StartingMindRoleComponent.cs | 27 ++++ .../Locale/en-US/administration/antag.ftl | 2 + .../administration/ui/tabs/player-tab.ftl | 1 + Resources/Locale/en-US/mind/role-types.ftl | 9 ++ .../Entities/Markers/Spawners/ghost_roles.yml | 20 +++ .../Mobs/Cyborgs/base_borg_chassis.yml | 1 + .../Prototypes/Entities/Mobs/NPCs/animals.yml | 11 ++ .../Entities/Mobs/NPCs/behonker.yml | 2 + .../Prototypes/Entities/Mobs/NPCs/carp.yml | 2 + .../Entities/Mobs/NPCs/elemental.yml | 2 + .../Entities/Mobs/NPCs/hellspawn.yml | 2 + .../Entities/Mobs/NPCs/regalrat.yml | 2 + .../Entities/Mobs/NPCs/revenant.yml | 2 + .../Prototypes/Entities/Mobs/NPCs/silicon.yml | 6 + .../Prototypes/Entities/Mobs/NPCs/slimes.yml | 6 + .../Prototypes/Entities/Mobs/NPCs/space.yml | 2 + .../Entities/Mobs/Player/dragon.yml | 4 +- .../Entities/Mobs/Player/familiars.yml | 4 + .../Entities/Mobs/Player/guardian.yml | 2 + .../Entities/Mobs/Player/humanoid.yml | 2 + .../Entities/Mobs/Player/silicon.yml | 8 +- .../Entities/Mobs/Player/skeleton.yml | 6 + .../reinforcement_teleporter.yml | 10 ++ .../Prototypes/Entities/Objects/Fun/pai.yml | 6 + .../Objects/Specific/Robotics/mmi.yml | 2 + Resources/Prototypes/GameRules/roundstart.yml | 2 +- .../Prototypes/Roles/MindRoles/mind_roles.yml | 91 +++++++++++- Resources/Prototypes/Roles/role_types.yml | 37 +++++ .../XenoArch/Effects/utility_effects.yml | 2 + 65 files changed, 744 insertions(+), 106 deletions(-) create mode 100644 Content.Shared/Mind/RoleTypePrototype.cs delete mode 100644 Content.Shared/Roles/MindRoleAddedEvent.cs create mode 100644 Content.Shared/Roles/SiliconBrainRoleComponent.cs create mode 100644 Content.Shared/Roles/StartingMindRoleComponent.cs create mode 100644 Resources/Locale/en-US/mind/role-types.ftl create mode 100644 Resources/Prototypes/Roles/role_types.yml diff --git a/Content.Client/Administration/AdminNameOverlay.cs b/Content.Client/Administration/AdminNameOverlay.cs index e2db7a8d6b..47d251910c 100644 --- a/Content.Client/Administration/AdminNameOverlay.cs +++ b/Content.Client/Administration/AdminNameOverlay.cs @@ -1,16 +1,21 @@ +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; -using Robust.Shared.Enums; 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; @@ -18,8 +23,16 @@ internal sealed class AdminNameOverlay : Overlay private readonly IUserInterfaceManager _userInterfaceManager; private readonly Font _font; + //TODO make this adjustable via GUI + private readonly ProtoId[] _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; @@ -35,6 +48,9 @@ internal sealed class AdminNameOverlay : Overlay { 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); @@ -64,12 +80,20 @@ internal sealed class AdminNameOverlay : Overlay var screenCoordinates = _eyeManager.WorldToScreen(aabb.Center + new Angle(-_eyeManager.CurrentEye.Rotation).RotateVec( aabb.TopRight - aabb.Center)) + new Vector2(1f, 7f); - if (playerInfo.Antag) + + if (classic && playerInfo.Antag) { - args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), "ANTAG", uiScale, Color.OrangeRed); -; + args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), _antagLabelClassic, uiScale, _antagColorClassic); } - args.ScreenHandle.DrawString(_font, screenCoordinates+lineoffset, playerInfo.Username, uiScale, playerInfo.Connected ? Color.Yellow : Color.White); + 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); } } diff --git a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs index 043bf343ec..b7231869c9 100644 --- a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs @@ -197,6 +197,7 @@ public sealed partial class PlayerTab : Control Header.Character => Compare(x.CharacterName, y.CharacterName), Header.Job => Compare(x.StartingJob, y.StartingJob), Header.Antagonist => x.Antag.CompareTo(y.Antag), + Header.RoleType => Compare(x.RoleProto.Name , y.RoleProto.Name), Header.Playtime => TimeSpan.Compare(x.OverallPlaytime ?? default, y.OverallPlaytime ?? default), _ => 1 }; diff --git a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml index e1371ec6f7..54e51747fb 100644 --- a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml +++ b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml @@ -24,6 +24,11 @@ HorizontalExpand="True" ClipText="True"/> +