UpdateAppearance(uid, ToggleableGhostRoleStatus.Searching);
- var ghostRole = EnsureComp<GhostRoleComponent>(uid);
- EnsureComp<GhostTakeoverAvailableComponent>(uid);
-
- //GhostRoleComponent inherits custom settings from the ToggleableGhostRoleComponent
- ghostRole.RoleName = Loc.GetString(component.RoleName);
- ghostRole.RoleDescription = Loc.GetString(component.RoleDescription);
- ghostRole.RoleRules = Loc.GetString(component.RoleRules);
- ghostRole.JobProto = component.JobProto;
- ghostRole.MindRoles = component.MindRoles;
+ ActivateGhostRole((uid, component));
+ }
+
+ public void ActivateGhostRole(Entity<ToggleableGhostRoleComponent?> ent)
+ {
+ if (!Resolve(ent, ref ent.Comp))
+ return;
+
+ var ghostRole = EnsureComp<GhostRoleComponent>(ent);
+ EnsureComp<GhostTakeoverAvailableComponent>(ent);
+
+ // GhostRoleComponent inherits custom settings from the ToggleableGhostRoleComponent
+ ghostRole.RoleName = Loc.GetString(ent.Comp.RoleName);
+ ghostRole.RoleDescription = Loc.GetString(ent.Comp.RoleDescription);
+ ghostRole.RoleRules = Loc.GetString(ent.Comp.RoleRules);
+ ghostRole.JobProto = ent.Comp.JobProto;
+ ghostRole.MindRoles = ent.Comp.MindRoles;
}
private void OnExamined(EntityUid uid, ToggleableGhostRoleComponent component, ExaminedEvent args)
using Content.Server.Construction;
using Content.Server.Destructible;
using Content.Server.Ghost;
+using Content.Server.Ghost.Roles;
+using Content.Server.Ghost.Roles.Components;
using Content.Server.Mind;
using Content.Server.Power.Components;
using Content.Server.Roles;
[Dependency] private readonly RoleSystem _roles = default!;
[Dependency] private readonly ItemSlotsSystem _slots = default!;
[Dependency] private readonly GhostSystem _ghost = default!;
+ [Dependency] private readonly ToggleableGhostRoleSystem _ghostrole = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly DestructibleSystem _destructible = default!;
[Dependency] private readonly SharedBatterySystem _battery = default!;
}
var brain = container.ContainedEntities[0];
+ var hasMind = _mind.TryGetMind(brain, out var mindId, out var mind);
- if (_mind.TryGetMind(brain, out var mindId, out var mind))
+ if (hasMind || HasComp<GhostRoleComponent>(brain))
{
- // Found an existing mind to transfer into the AI core
var aiBrain = Spawn(_stationAiBrain, Transform(ent.Owner).Coordinates);
- _roles.MindAddJobRole(mindId, mind, false, _stationAiJob);
- _mind.TransferTo(mindId, aiBrain);
+ if (hasMind)
+ {
+ // Found an existing mind to transfer into the AI core
+ _roles.MindAddJobRole(mindId, mind, false, _stationAiJob);
+ _mind.TransferTo(mindId, aiBrain);
+ }
+ else
+ {
+ // If the brain had a ghost role attached, activate the station AI ghost role
+ _ghostrole.ActivateGhostRole(aiBrain);
+
+ // Set the new AI brain to the 'rebooting' state
+ if (TryComp<StationAiCustomizationComponent>(aiBrain, out var customization))
+ SetStationAiState((aiBrain, customization), StationAiState.Rebooting);
+
+ }
+
+ // Delete the new AI brain if it cannot be inserted into the core
if (!TryComp<StationAiHolderComponent>(ent, out var targetHolder) ||
!_slots.TryInsert(ent, targetHolder.Slot, aiBrain, null))
{