mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-02-14 23:14:45 +01:00
Station AI ghost role (#40607)
* Initial commit * API * review --------- Co-authored-by: ScarKy0 <scarky0@onet.eu>
This commit is contained in:
@@ -49,15 +49,23 @@ public sealed class ToggleableGhostRoleSystem : EntitySystem
|
||||
|
||||
UpdateAppearance(uid, ToggleableGhostRoleStatus.Searching);
|
||||
|
||||
var ghostRole = EnsureComp<GhostRoleComponent>(uid);
|
||||
EnsureComp<GhostTakeoverAvailableComponent>(uid);
|
||||
ActivateGhostRole((uid, component));
|
||||
}
|
||||
|
||||
//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;
|
||||
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)
|
||||
|
||||
@@ -2,6 +2,8 @@ using Content.Server.Chat.Systems;
|
||||
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;
|
||||
@@ -47,6 +49,7 @@ public sealed class StationAiSystem : SharedStationAiSystem
|
||||
[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!;
|
||||
@@ -97,14 +100,30 @@ public sealed class StationAiSystem : SharedStationAiSystem
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
|
||||
@@ -9,6 +9,10 @@ station-ai-is-too-damaged-for-upload = Upload failed - the AI core must be repai
|
||||
station-ai-core-losing-power = Your AI core is now running on reserve battery power.
|
||||
station-ai-core-critical-power = Your AI core is critically low on power. External power must be re-established or severe data corruption may occur!
|
||||
|
||||
# Ghost role
|
||||
station-ai-ghost-role-name = Station AI
|
||||
station-ai-ghost-role-description = Serve the station crew as its ever watchful AI.
|
||||
|
||||
# Radial actions
|
||||
ai-open = Open actions
|
||||
ai-close = Close actions
|
||||
|
||||
@@ -457,6 +457,13 @@
|
||||
state: ai_female
|
||||
- type: NameIdentifier
|
||||
group: StationAi
|
||||
- type: ToggleableGhostRole
|
||||
roleName: station-ai-ghost-role-name
|
||||
roleDescription: station-ai-ghost-role-description
|
||||
roleRules: ghost-role-information-silicon-rules
|
||||
mindRoles:
|
||||
- MindRoleGhostRoleSilicon
|
||||
job: StationAi
|
||||
|
||||
# Hologram projection that the AI's eye tracks.
|
||||
- type: entity
|
||||
|
||||
Reference in New Issue
Block a user