forked from wylab/wylab-station-14
46d58bf22a
* 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>
98 lines
3.3 KiB
C#
98 lines
3.3 KiB
C#
using Content.Server.Roles;
|
|
using Content.Shared.Containers.ItemSlots;
|
|
using Content.Shared.Mind.Components;
|
|
using Content.Shared.Roles;
|
|
using Content.Shared.Silicons.Borgs.Components;
|
|
using Robust.Shared.Containers;
|
|
|
|
namespace Content.Server.Silicons.Borgs;
|
|
|
|
/// <inheritdoc/>
|
|
public sealed partial class BorgSystem
|
|
{
|
|
|
|
[Dependency] private readonly SharedRoleSystem _roles = default!;
|
|
|
|
public void InitializeMMI()
|
|
{
|
|
SubscribeLocalEvent<MMIComponent, ComponentInit>(OnMMIInit);
|
|
SubscribeLocalEvent<MMIComponent, EntInsertedIntoContainerMessage>(OnMMIEntityInserted);
|
|
SubscribeLocalEvent<MMIComponent, MindAddedMessage>(OnMMIMindAdded);
|
|
SubscribeLocalEvent<MMIComponent, MindRemovedMessage>(OnMMIMindRemoved);
|
|
|
|
SubscribeLocalEvent<MMILinkedComponent, MindAddedMessage>(OnMMILinkedMindAdded);
|
|
SubscribeLocalEvent<MMILinkedComponent, EntGotRemovedFromContainerMessage>(OnMMILinkedRemoved);
|
|
}
|
|
|
|
private void OnMMIInit(EntityUid uid, MMIComponent component, ComponentInit args)
|
|
{
|
|
if (!TryComp<ItemSlotsComponent>(uid, out var itemSlots))
|
|
return;
|
|
|
|
if (ItemSlots.TryGetSlot(uid, component.BrainSlotId, out var slot, itemSlots))
|
|
component.BrainSlot = slot;
|
|
else
|
|
ItemSlots.AddItemSlot(uid, component.BrainSlotId, component.BrainSlot, itemSlots);
|
|
}
|
|
|
|
private void OnMMIEntityInserted(EntityUid uid, MMIComponent component, EntInsertedIntoContainerMessage args)
|
|
{
|
|
if (args.Container.ID != component.BrainSlotId)
|
|
return;
|
|
|
|
var ent = args.Entity;
|
|
var linked = EnsureComp<MMILinkedComponent>(ent);
|
|
linked.LinkedMMI = uid;
|
|
Dirty(uid, component);
|
|
|
|
if (_mind.TryGetMind(ent, out var mindId, out var mind))
|
|
{
|
|
_mind.TransferTo(mindId, uid, true, mind: mind);
|
|
|
|
if (!_roles.MindHasRole<SiliconBrainRoleComponent>(mindId))
|
|
_roles.MindAddRole(mindId, "MindRoleSiliconBrain", silent: true);
|
|
}
|
|
|
|
_appearance.SetData(uid, MMIVisuals.BrainPresent, true);
|
|
}
|
|
|
|
private void OnMMIMindAdded(EntityUid uid, MMIComponent component, MindAddedMessage args)
|
|
{
|
|
_appearance.SetData(uid, MMIVisuals.HasMind, true);
|
|
}
|
|
|
|
private void OnMMIMindRemoved(EntityUid uid, MMIComponent component, MindRemovedMessage args)
|
|
{
|
|
_appearance.SetData(uid, MMIVisuals.HasMind, false);
|
|
}
|
|
|
|
private void OnMMILinkedMindAdded(EntityUid uid, MMILinkedComponent component, MindAddedMessage args)
|
|
{
|
|
if (!_mind.TryGetMind(uid, out var mindId, out var mind) ||
|
|
component.LinkedMMI == null)
|
|
return;
|
|
|
|
_mind.TransferTo(mindId, component.LinkedMMI, true, mind: mind);
|
|
}
|
|
|
|
private void OnMMILinkedRemoved(EntityUid uid, MMILinkedComponent component, EntGotRemovedFromContainerMessage args)
|
|
{
|
|
if (Terminating(uid))
|
|
return;
|
|
|
|
if (component.LinkedMMI is not { } linked)
|
|
return;
|
|
RemComp(uid, component);
|
|
|
|
if (_mind.TryGetMind(linked, out var mindId, out var mind))
|
|
{
|
|
if (_roles.MindHasRole<SiliconBrainRoleComponent>(mindId))
|
|
_roles.MindRemoveRole<SiliconBrainRoleComponent>(mindId);
|
|
|
|
_mind.TransferTo(mindId, uid, true, mind: mind);
|
|
}
|
|
|
|
_appearance.SetData(linked, MMIVisuals.BrainPresent, false);
|
|
}
|
|
}
|