* 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>
112 lines
3.3 KiB
C#
112 lines
3.3 KiB
C#
using Content.Server.Chat.Managers;
|
|
using Content.Shared.Chat;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Roles;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Server.Roles;
|
|
|
|
public sealed class RoleSystem : SharedRoleSystem
|
|
{
|
|
[Dependency] private readonly IChatManager _chat = default!;
|
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
|
|
|
public string? MindGetBriefing(EntityUid? mindId)
|
|
{
|
|
if (mindId == null)
|
|
{
|
|
Log.Error($"MingGetBriefing failed for mind {mindId}");
|
|
return null;
|
|
}
|
|
|
|
TryComp<MindComponent>(mindId.Value, out var mindComp);
|
|
|
|
if (mindComp is null)
|
|
{
|
|
Log.Error($"MingGetBriefing failed for mind {mindId}");
|
|
return null;
|
|
}
|
|
|
|
var ev = new GetBriefingEvent();
|
|
|
|
// This is on the event because while this Entity<T> is also present on every Mind Role Entity's MindRoleComp
|
|
// getting to there from a GetBriefing event subscription can be somewhat boilerplate
|
|
// and this needs to be looked up for the event anyway so why calculate it again later
|
|
ev.Mind = (mindId.Value, mindComp);
|
|
|
|
// Briefing is no longer raised on the mind entity itself
|
|
// because all the components that briefings subscribe to should be on Mind Role Entities
|
|
foreach(var role in mindComp.MindRoles)
|
|
{
|
|
RaiseLocalEvent(role, ref ev);
|
|
}
|
|
|
|
return ev.Briefing;
|
|
}
|
|
|
|
public void RoleUpdateMessage(MindComponent mind)
|
|
{
|
|
if (mind.Session is null)
|
|
return;
|
|
|
|
if (!_proto.TryIndex(mind.RoleType, out var proto))
|
|
return;
|
|
|
|
var roleText = Loc.GetString(proto.Name);
|
|
var color = proto.Color;
|
|
|
|
var session = mind.Session;
|
|
|
|
//TODO add audio? Would need to be optional so it does not play on role changes that already come with their own audio
|
|
// _audio.PlayGlobal(Sound, session);
|
|
|
|
var message = Loc.GetString("role-type-update-message", ("color", color), ("role", roleText));
|
|
var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", message));
|
|
_chat.ChatMessageToOne(ChatChannel.Server,
|
|
message,
|
|
wrappedMessage,
|
|
default,
|
|
false,
|
|
session.Channel);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Event raised on the mind to get its briefing.
|
|
/// Handlers can either replace or append to the briefing, whichever is more appropriate.
|
|
/// </summary>
|
|
[ByRefEvent]
|
|
public sealed class GetBriefingEvent
|
|
{
|
|
/// <summary>
|
|
/// The text that will be shown on the Character Screen
|
|
/// </summary>
|
|
public string? Briefing;
|
|
|
|
/// <summary>
|
|
/// The Mind to whose Mind Role Entities the briefing is sent to
|
|
/// </summary>
|
|
public Entity<MindComponent> Mind;
|
|
|
|
public GetBriefingEvent(string? briefing = null)
|
|
{
|
|
Briefing = briefing;
|
|
}
|
|
|
|
/// <summary>
|
|
/// If there is no briefing, sets it to the string.
|
|
/// If there is a briefing, adds a new line to separate it from the appended string.
|
|
/// </summary>
|
|
public void Append(string text)
|
|
{
|
|
if (Briefing == null)
|
|
{
|
|
Briefing = text;
|
|
}
|
|
else
|
|
{
|
|
Briefing += "\n" + text;
|
|
}
|
|
}
|
|
}
|