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>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Mind;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
@@ -10,6 +11,7 @@ public sealed record PlayerInfo(
|
||||
string IdentityName,
|
||||
string StartingJob,
|
||||
bool Antag,
|
||||
RoleTypePrototype RoleProto,
|
||||
NetEntity? NetEntity,
|
||||
NetUserId SessionId,
|
||||
bool Connected,
|
||||
|
||||
@@ -4,21 +4,42 @@ namespace Content.Shared.CCVar;
|
||||
|
||||
public sealed partial class CCVars
|
||||
{
|
||||
/// <summary>
|
||||
/// The sound played when clicking a UI button
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> UIClickSound =
|
||||
CVarDef.Create("interface.click_sound", "/Audio/UserInterface/click.ogg", CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// The sound played when the mouse hovers over a clickable UI element
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> UIHoverSound =
|
||||
CVarDef.Create("interface.hover_sound", "/Audio/UserInterface/hover.ogg", CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// The layout style of the UI
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> UILayout =
|
||||
CVarDef.Create("ui.layout", "Default", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
/// <summary>
|
||||
/// The dimensions for the chat window in Default UI mode
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> DefaultScreenChatSize =
|
||||
CVarDef.Create("ui.default_chat_size", "", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
/// <summary>
|
||||
/// The width of the chat panel in Separated UI mode
|
||||
/// </summary>
|
||||
public static readonly CVarDef<string> SeparatedScreenChatSize =
|
||||
CVarDef.Create("ui.separated_chat_size", "0.6,0", CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
|
||||
public static readonly CVarDef<bool> OutlineEnabled =
|
||||
CVarDef.Create("outline.enabled", true, CVar.CLIENTONLY);
|
||||
|
||||
/// <summary>
|
||||
/// If true, the admin overlay will be displayed in the old style (showing only "ANTAG")
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> AdminOverlayClassic =
|
||||
CVarDef.Create("ui.admin_overlay_classic", false, CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Shared.Mind.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Mind;
|
||||
|
||||
@@ -101,6 +102,12 @@ public sealed partial class MindComponent : Component
|
||||
[DataField, AutoNetworkedField]
|
||||
public List<EntityUid> MindRoles = new List<EntityUid>();
|
||||
|
||||
/// <summary>
|
||||
/// The mind's current antagonist/special role, or lack thereof;
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public ProtoId<RoleTypePrototype> RoleType = "Neutral";
|
||||
|
||||
/// <summary>
|
||||
/// The session of the player owning this mind.
|
||||
/// Can be null, in which case the player is currently not logged in.
|
||||
|
||||
25
Content.Shared/Mind/RoleTypePrototype.cs
Normal file
25
Content.Shared/Mind/RoleTypePrototype.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Mind;
|
||||
|
||||
/// <summary>
|
||||
/// The core properties of Role Types
|
||||
/// </summary>
|
||||
[Prototype, Serializable]
|
||||
public sealed class RoleTypePrototype : IPrototype
|
||||
{
|
||||
[IdDataField]
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The role's name as displayed on the UI.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId Name = "role-type-crew-aligned-name";
|
||||
|
||||
/// <summary>
|
||||
/// The role's displayed color.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public Color Color { get; private set; } = Color.FromHex("#eeeeee");
|
||||
}
|
||||
@@ -5,6 +5,6 @@ namespace Content.Shared.Roles;
|
||||
/// depending on their roles.
|
||||
/// </summary>
|
||||
/// <param name="IsAntagonist">Whether or not the player is an antagonist.</param>
|
||||
/// <param name="IsExclusiveAntagonist">Whether or not AntagSelectionSystem should exclude this player from other antag roles</param
|
||||
/// <param name="IsExclusiveAntagonist">Whether or not AntagSelectionSystem should exclude this player from other antag roles</param>
|
||||
[ByRefEvent]
|
||||
public record struct MindIsAntagonistEvent(bool IsAntagonist, bool IsExclusiveAntagonist);
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace Content.Shared.Roles;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on mind entities when a role is added to them.
|
||||
/// <see cref="RoleAddedEvent"/> for the one raised on player entities.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public readonly record struct MindRoleAddedEvent(bool Silent);
|
||||
@@ -1,5 +1,4 @@
|
||||
using Content.Shared.Mind;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -18,6 +17,12 @@ public sealed partial class MindRoleComponent : BaseMindRoleComponent
|
||||
[DataField]
|
||||
public bool Antag { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// The mind's current antagonist/special role, or lack thereof;
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public ProtoId<RoleTypePrototype>? RoleType;
|
||||
|
||||
/// <summary>
|
||||
/// True if this mindrole is an exclusive antagonist. Antag setting is not checked if this is True.
|
||||
/// </summary>
|
||||
@@ -43,6 +48,7 @@ public sealed partial class MindRoleComponent : BaseMindRoleComponent
|
||||
}
|
||||
|
||||
// Why does this base component actually exist? It does make auto-categorization easy, but before that it was useless?
|
||||
// I used it for easy organisation/bookkeeping of what components are for mindroles
|
||||
[EntityCategory("Roles")]
|
||||
public abstract partial class BaseMindRoleComponent : Component
|
||||
{
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
namespace Content.Shared.Roles;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on player entities when a role is added to them.
|
||||
/// <see cref="RoleAddedEvent"/> for the one raised on mind entities.
|
||||
/// Raised on mind entities when a mind role is added to them.
|
||||
/// </summary>
|
||||
/// <param name="MindId">The mind id associated with the player.</param>
|
||||
/// <param name="Mind">The mind component associated with the mind id.</param>
|
||||
/// <param name="Antagonist">Whether or not the role makes the player an antagonist.</param>
|
||||
public sealed record RoleAddedEvent(EntityUid MindId, MindComponent Mind, bool Antagonist, bool Silent = false) : RoleEvent(MindId, Mind, Antagonist);
|
||||
/// <param name="RoleTypeUpdate">True if this update has changed the mind's role type</param>
|
||||
/// <param name="Silent">If true, Job greeting/intro will not be sent to the player's chat</param>
|
||||
public sealed record RoleAddedEvent(EntityUid MindId, MindComponent Mind, bool RoleTypeUpdate, bool Silent = false) : RoleEvent(MindId, Mind, RoleTypeUpdate);
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace Content.Shared.Roles;
|
||||
|
||||
/// <summary>
|
||||
/// Base event raised on player entities to indicate that something changed about one of their roles.
|
||||
/// Base event raised on mind entities to indicate that a mind role was either added or removed.
|
||||
/// </summary>
|
||||
/// <param name="MindId">The mind id associated with the player.</param>
|
||||
/// <param name="Mind">The mind component associated with the mind id.</param>
|
||||
/// <param name="Antagonist">Whether or not the role makes the player an antagonist.</param>
|
||||
public abstract record RoleEvent(EntityUid MindId, MindComponent Mind, bool Antagonist);
|
||||
/// <param name="RoleTypeUpdate">True if this update has changed the mind's role type</param>
|
||||
public abstract record RoleEvent(EntityUid MindId, MindComponent Mind, bool RoleTypeUpdate);
|
||||
|
||||
@@ -3,12 +3,9 @@
|
||||
namespace Content.Shared.Roles;
|
||||
|
||||
/// <summary>
|
||||
/// Event raised on player entities to indicate that a role was removed from their mind.
|
||||
/// Raised on mind entities when a mind role is removed from them.
|
||||
/// </summary>
|
||||
/// <param name="MindId">The mind id associated with the player.</param>
|
||||
/// <param name="Mind">The mind component associated with the mind id.</param>
|
||||
/// <param name="Antagonist">
|
||||
/// Whether or not the role made the player an antagonist.
|
||||
/// They may still be one due to one of their other roles.
|
||||
/// </param>
|
||||
public sealed record RoleRemovedEvent(EntityUid MindId, MindComponent Mind, bool Antagonist) : RoleEvent(MindId, Mind, Antagonist);
|
||||
/// <param name="RoleTypeUpdate">True if this update has changed the mind's role type</param>
|
||||
public sealed record RoleRemovedEvent(EntityUid MindId, MindComponent Mind, bool RoleTypeUpdate) : RoleEvent(MindId, Mind, RoleTypeUpdate);
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Roles.Jobs;
|
||||
using Content.Shared.Silicons.Borgs.Components;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Roles;
|
||||
@@ -19,6 +23,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly SharedMindSystem _minds = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypes = default!;
|
||||
|
||||
private JobRequirementOverridePrototype? _requirementOverride;
|
||||
@@ -28,6 +33,15 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
Subs.CVar(_cfg, CCVars.GameRoleTimerOverride, SetRequirementOverride, true);
|
||||
|
||||
SubscribeLocalEvent<MindRoleComponent, ComponentShutdown>(OnComponentShutdown);
|
||||
SubscribeLocalEvent<StartingMindRoleComponent, PlayerSpawnCompleteEvent>(OnSpawn);
|
||||
}
|
||||
|
||||
private void OnSpawn(EntityUid uid, StartingMindRoleComponent component, PlayerSpawnCompleteEvent args)
|
||||
{
|
||||
if (!_minds.TryGetMind(uid, out var mindId, out var mindComp))
|
||||
return;
|
||||
|
||||
MindAddRole(mindId, component.MindRole, mind: mindComp, silent: component.Silent);
|
||||
}
|
||||
|
||||
private void SetRequirementOverride(string value)
|
||||
@@ -50,7 +64,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
/// <param name="mind">If the mind component is provided, it will be checked if it belongs to the mind entity</param>
|
||||
/// <param name="silent">If true, no briefing will be generated upon receiving the mind role</param>
|
||||
public void MindAddRoles(EntityUid mindId,
|
||||
List<ProtoId<EntityPrototype>>? roles,
|
||||
List<EntProtoId>? roles,
|
||||
MindComponent? mind = null,
|
||||
bool silent = false)
|
||||
{
|
||||
@@ -71,7 +85,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
/// <param name="mind">If the mind component is provided, it will be checked if it belongs to the mind entity</param>
|
||||
/// <param name="silent">If true, no briefing will be generated upon receiving the mind role</param>
|
||||
public void MindAddRole(EntityUid mindId,
|
||||
ProtoId<EntityPrototype> protoId,
|
||||
EntProtoId protoId,
|
||||
MindComponent? mind = null,
|
||||
bool silent = false)
|
||||
{
|
||||
@@ -114,22 +128,20 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
/// Creates a Mind Role
|
||||
/// </summary>
|
||||
private void MindAddRoleDo(EntityUid mindId,
|
||||
ProtoId<EntityPrototype> protoId,
|
||||
EntProtoId protoId,
|
||||
MindComponent? mind = null,
|
||||
bool silent = false,
|
||||
string? jobPrototype = null)
|
||||
{
|
||||
if (!Resolve(mindId, ref mind))
|
||||
{
|
||||
Log.Error($"Failed to add role {protoId} to mind {mindId} : Mind does not match provided mind component");
|
||||
Log.Error($"Failed to add role {protoId} to {ToPrettyString(mindId)} : Mind does not match provided mind component");
|
||||
return;
|
||||
}
|
||||
|
||||
var antagonist = false;
|
||||
|
||||
if (!_prototypes.TryIndex(protoId, out var protoEnt))
|
||||
{
|
||||
Log.Error($"Failed to add role {protoId} to mind {mindId} : Role prototype does not exist");
|
||||
Log.Error($"Failed to add role {protoId} to {ToPrettyString(mindId)} : Role prototype does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,15 +163,14 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
DebugTools.Assert(!mindRoleComp.ExclusiveAntag);
|
||||
}
|
||||
|
||||
antagonist |= mindRoleComp.Antag;
|
||||
mind.MindRoles.Add(mindRoleId);
|
||||
|
||||
var mindEv = new MindRoleAddedEvent(silent);
|
||||
RaiseLocalEvent(mindId, ref mindEv);
|
||||
var update = MindRolesUpdate((mindId, mind));
|
||||
|
||||
var message = new RoleAddedEvent(mindId, mind, antagonist, silent);
|
||||
// RoleType refresh, Role time tracking, Update Admin playerlist
|
||||
if (mind.OwnedEntity != null)
|
||||
{
|
||||
var message = new RoleAddedEvent(mindId, mind, update, silent);
|
||||
RaiseLocalEvent(mind.OwnedEntity.Value, message, true);
|
||||
}
|
||||
|
||||
@@ -174,12 +185,91 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
{
|
||||
//TODO: This is not tied to the player on the Admin Log filters.
|
||||
//Probably only happens when Job Role is added on initial spawn, before the mind entity is put in a mob
|
||||
Log.Error($"{ToPrettyString(mindId)} does not have an OwnedEntity!");
|
||||
_adminLogger.Add(LogType.Mind,
|
||||
LogImpact.Low,
|
||||
$"{name} added to {ToPrettyString(mindId)}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Select the mind's currently "active" mind role entity, and update the mind's role type, if necessary
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// True if this changed the mind's role type
|
||||
/// </returns>>
|
||||
private bool MindRolesUpdate(Entity<MindComponent?> ent)
|
||||
{
|
||||
if(!Resolve(ent.Owner, ref ent.Comp))
|
||||
return false;
|
||||
|
||||
//get the most important/latest mind role
|
||||
var roleType = GetRoleTypeByTime(ent.Comp);
|
||||
|
||||
if (ent.Comp.RoleType == roleType)
|
||||
return false;
|
||||
|
||||
SetRoleType(ent.Owner, roleType);
|
||||
return true;
|
||||
}
|
||||
|
||||
private ProtoId<RoleTypePrototype> GetRoleTypeByTime(MindComponent mind)
|
||||
{
|
||||
// If any Mind Roles specify a Role Type, return the most recent. Otherwise return Neutral
|
||||
|
||||
var roles = new List<ProtoId<RoleTypePrototype>>();
|
||||
|
||||
foreach (var role in mind.MindRoles)
|
||||
{
|
||||
var comp = Comp<MindRoleComponent>(role);
|
||||
if (comp.RoleType is not null)
|
||||
roles.Add(comp.RoleType.Value);
|
||||
}
|
||||
|
||||
ProtoId<RoleTypePrototype> result = (roles.Count > 0) ? roles.LastOrDefault() : "Neutral";
|
||||
return (result);
|
||||
}
|
||||
|
||||
private void SetRoleType(EntityUid mind, ProtoId<RoleTypePrototype> roleTypeId)
|
||||
{
|
||||
if (!TryComp<MindComponent>(mind, out var comp))
|
||||
{
|
||||
Log.Error($"Failed to update Role Type of mind entity {ToPrettyString(mind)} to {roleTypeId}. MindComponent not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_prototypes.HasIndex(roleTypeId))
|
||||
{
|
||||
Log.Error($"Failed to change Role Type of {_minds.MindOwnerLoggingString(comp)} to {roleTypeId}. Invalid role");
|
||||
return;
|
||||
}
|
||||
|
||||
comp.RoleType = roleTypeId;
|
||||
Dirty(mind, comp);
|
||||
|
||||
// Update player character window
|
||||
if (_minds.TryGetSession(mind, out var session))
|
||||
RaiseNetworkEvent(new MindRoleTypeChangedEvent(), session.Channel);
|
||||
else
|
||||
{
|
||||
var error = $"The Character Window of {_minds.MindOwnerLoggingString(comp)} potentially did not update immediately : session error";
|
||||
_adminLogger.Add(LogType.Mind, LogImpact.High, $"{error}");
|
||||
}
|
||||
|
||||
if (comp.OwnedEntity is null)
|
||||
{
|
||||
Log.Error($"{ToPrettyString(mind)} does not have an OwnedEntity!");
|
||||
_adminLogger.Add(LogType.Mind,
|
||||
LogImpact.High,
|
||||
$"Role Type of {ToPrettyString(mind)} changed to {roleTypeId}");
|
||||
return;
|
||||
}
|
||||
|
||||
_adminLogger.Add(LogType.Mind,
|
||||
LogImpact.High,
|
||||
$"Role Type of {ToPrettyString(comp.OwnedEntity)} changed to {roleTypeId}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all instances of a specific role from this mind.
|
||||
/// </summary>
|
||||
@@ -195,20 +285,18 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
return false;
|
||||
|
||||
var found = false;
|
||||
var antagonist = false;
|
||||
var delete = new List<EntityUid>();
|
||||
foreach (var role in mind.Comp.MindRoles)
|
||||
{
|
||||
if (!HasComp<T>(role))
|
||||
continue;
|
||||
|
||||
if (!TryComp(role, out MindRoleComponent? roleComp))
|
||||
if (!HasComp<MindRoleComponent>(role))
|
||||
{
|
||||
Log.Error($"Encountered mind role entity {ToPrettyString(role)} without a {nameof(MindRoleComponent)}");
|
||||
continue;
|
||||
}
|
||||
|
||||
antagonist |= roleComp.Antag | roleComp.ExclusiveAntag;
|
||||
delete.Add(role);
|
||||
found = true;
|
||||
}
|
||||
@@ -221,9 +309,11 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
_entityManager.DeleteEntity(role);
|
||||
}
|
||||
|
||||
var update = MindRolesUpdate(mind);
|
||||
|
||||
if (mind.Comp.OwnedEntity != null)
|
||||
{
|
||||
var message = new RoleRemovedEvent(mind.Owner, mind.Comp, antagonist);
|
||||
var message = new RoleRemovedEvent(mind.Owner, mind.Comp, update);
|
||||
RaiseLocalEvent(mind.Comp.OwnedEntity.Value, message, true);
|
||||
}
|
||||
|
||||
@@ -267,10 +357,9 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
/// Finds the first mind role of a specific T type on a mind entity.
|
||||
/// Outputs entity components for the mind role's MindRoleComponent and for T
|
||||
/// </summary>
|
||||
/// <param name="mindId">The mind entity</param>
|
||||
/// <param name="mind">The mind entity</param>
|
||||
/// <typeparam name="T">The type of the role to find.</typeparam>
|
||||
/// <param name="role">The Mind Role entity component</param>
|
||||
/// <param name="roleT">The Mind Role's entity component for T</param>
|
||||
/// <returns>True if the role is found</returns>
|
||||
public bool MindHasRole<T>(Entity<MindComponent?> mind,
|
||||
[NotNullWhen(true)] out Entity<MindRoleComponent, T>? role) where T : IComponent
|
||||
@@ -467,7 +556,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
return CheckAntagonistStatus(mindId.Value).ExclusiveAntag;
|
||||
}
|
||||
|
||||
public (bool Antag, bool ExclusiveAntag) CheckAntagonistStatus(Entity<MindComponent?> mind)
|
||||
private (bool Antag, bool ExclusiveAntag) CheckAntagonistStatus(Entity<MindComponent?> mind)
|
||||
{
|
||||
if (!Resolve(mind.Owner, ref mind.Comp))
|
||||
return (false, false);
|
||||
@@ -537,3 +626,12 @@ public abstract class SharedRoleSystem : EntitySystem
|
||||
return antag.Requirements;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised on the client to update Role Type on the character window, in case it happened to be open.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class MindRoleTypeChangedEvent : EntityEventArgs
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
9
Content.Shared/Roles/SiliconBrainRoleComponent.cs
Normal file
9
Content.Shared/Roles/SiliconBrainRoleComponent.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Content.Shared.Roles;
|
||||
|
||||
/// <summary>
|
||||
/// Used on Silicon's minds to get the appropriate mind role
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class SiliconBrainRoleComponent : BaseMindRoleComponent
|
||||
{
|
||||
}
|
||||
27
Content.Shared/Roles/StartingMindRoleComponent.cs
Normal file
27
Content.Shared/Roles/StartingMindRoleComponent.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Roles;
|
||||
|
||||
/// <summary>
|
||||
/// This is most likely not the component you are looking for, almost nothing should be using this.
|
||||
/// Consider using GhostRoleComponent or AntagSelectionComponent instead.
|
||||
///
|
||||
/// The specified mind role will be added to the mob on spawn.
|
||||
///
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class StartingMindRoleComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The ID of the mind role to add
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public EntProtoId MindRole;
|
||||
|
||||
/// <summary>
|
||||
/// Add the mind role silently
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool Silent = true;
|
||||
}
|
||||
Reference in New Issue
Block a user