Skip to content

Commit

Permalink
StartingMindRoleComponent, unhardcode roundstart silicon
Browse files Browse the repository at this point in the history
  • Loading branch information
Errant-4 committed Jan 11, 2025
1 parent a254a03 commit c326482
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 34 deletions.
11 changes: 11 additions & 0 deletions Content.Shared/Roles/SharedRoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
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;
Expand All @@ -31,6 +33,15 @@ public override void Initialize()
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 _))
return;

MindAddRole(mindId, component.MindRole , silent:component.Silent);
}

private void SetRequirementOverride(string value)
Expand Down
27 changes: 27 additions & 0 deletions Content.Shared/Roles/StartingMindRoleComponent.cs
Original file line number Diff line number Diff line change
@@ -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;
}
24 changes: 0 additions & 24 deletions Content.Shared/Silicons/Borgs/SharedBorgSystem.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using Content.Shared.Containers.ItemSlots;
using Content.Shared.GameTicking;
using Content.Shared.IdentityManagement;
using Content.Shared.Item.ItemToggle;
using Content.Shared.Mind;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Popups;
using Content.Shared.PowerCell.Components;
using Content.Shared.Roles;
using Content.Shared.Silicons.Borgs.Components;
using Content.Shared.UserInterface;
using Content.Shared.Wires;
Expand All @@ -21,8 +18,6 @@ namespace Content.Shared.Silicons.Borgs;
public abstract partial class SharedBorgSystem : EntitySystem
{
[Dependency] protected readonly SharedContainerSystem Container = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly SharedRoleSystem _roles = default!;
[Dependency] protected readonly ItemSlotsSystem ItemSlots = default!;
[Dependency] protected readonly ItemToggleSystem Toggle = default!;
[Dependency] protected readonly SharedPopupSystem Popup = default!;
Expand All @@ -37,32 +32,13 @@ public override void Initialize()
SubscribeLocalEvent<BorgChassisComponent, ItemSlotEjectAttemptEvent>(OnItemSlotEjectAttempt);
SubscribeLocalEvent<BorgChassisComponent, EntInsertedIntoContainerMessage>(OnInserted);
SubscribeLocalEvent<BorgChassisComponent, EntRemovedFromContainerMessage>(OnRemoved);
SubscribeLocalEvent<BorgChassisComponent, PlayerSpawnCompleteEvent>(OnSpawn);
SubscribeLocalEvent<BorgChassisComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeedModifiers);
SubscribeLocalEvent<BorgChassisComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);

SubscribeLocalEvent<TryGetIdentityShortInfoEvent>(OnTryGetIdentityShortInfo);

InitializeRelay();
}

private void OnSpawn(EntityUid uid, BorgChassisComponent component, PlayerSpawnCompleteEvent args)
{
RoundStartSilicon(args.Mob);
}

/// <summary>
/// Borgs and AI that enter the game through the normal StationSpawningSystem get their Silicon mindrole here
/// </summary>
public void RoundStartSilicon(EntityUid uid)
{
if (!_mind.TryGetMind(uid, out var mindId, out _))
return;

if (!_roles.MindHasRole<SiliconBrainRoleComponent>(mindId))
_roles.MindAddRole(mindId, "MindRoleSiliconBrain", silent: true);
}

private void OnTryGetIdentityShortInfo(TryGetIdentityShortInfoEvent args)
{
if (args.Handled)
Expand Down
9 changes: 0 additions & 9 deletions Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Content.Shared.Doors.Systems;
using Content.Shared.DoAfter;
using Content.Shared.Electrocution;
using Content.Shared.GameTicking;
using Content.Shared.Intellicard;
using Content.Shared.Interaction;
using Content.Shared.Item.ItemToggle;
Expand All @@ -16,7 +15,6 @@
using Content.Shared.Popups;
using Content.Shared.Power;
using Content.Shared.Power.EntitySystems;
using Content.Shared.Silicons.Borgs;
using Content.Shared.StationAi;
using Content.Shared.Verbs;
using Robust.Shared.Audio;
Expand Down Expand Up @@ -46,7 +44,6 @@ public abstract partial class SharedStationAiSystem : EntitySystem
[Dependency] private readonly SharedAirlockSystem _airlocks = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedBorgSystem _borg = default!;
[Dependency] private readonly SharedContainerSystem _containers = default!;
[Dependency] private readonly SharedDoorSystem _doors = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
Expand Down Expand Up @@ -92,7 +89,6 @@ public override void Initialize()
SubscribeLocalEvent<StationAiOverlayComponent, AccessibleOverrideEvent>(OnAiAccessible);
SubscribeLocalEvent<StationAiOverlayComponent, InRangeOverrideEvent>(OnAiInRange);
SubscribeLocalEvent<StationAiOverlayComponent, MenuVisibilityEvent>(OnAiMenu);
SubscribeLocalEvent<StationAiOverlayComponent, PlayerSpawnCompleteEvent>(OnSpawn);

SubscribeLocalEvent<StationAiHolderComponent, ComponentInit>(OnHolderInit);
SubscribeLocalEvent<StationAiHolderComponent, ComponentRemove>(OnHolderRemove);
Expand All @@ -110,11 +106,6 @@ public override void Initialize()
SubscribeLocalEvent<StationAiCoreComponent, GetVerbsEvent<Verb>>(OnCoreVerbs);
}

private void OnSpawn(EntityUid uid, StationAiOverlayComponent component, PlayerSpawnCompleteEvent args)
{
_borg.RoundStartSilicon(args.Mob);
}

private void OnCoreVerbs(Entity<StationAiCoreComponent> ent, ref GetVerbsEvent<Verb> args)
{
if (!_admin.IsAdmin(args.User) ||
Expand Down
8 changes: 7 additions & 1 deletion Resources/Prototypes/Entities/Mobs/Player/silicon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
unlistedNumber: true
requiresPower: false
- type: Holopad
- type: StationAiWhitelist
- type: StationAiWhitelist
- type: UserInterface
interfaces:
enum.HolopadUiKey.AiRequestWindow:
Expand Down Expand Up @@ -441,6 +441,9 @@
- HideContextMenu
- StationAi
- NoConsoleSound
- type: StartingMindRole
mindRole: "MindRoleSiliconBrain"
silent: true

# Hologram projection that the AI's eye tracks.
- type: entity
Expand Down Expand Up @@ -504,6 +507,9 @@
cell_slot:
name: power-cell-slot-component-slot-name-default
startingItem: PowerCellMedium
- type: StartingMindRole
mindRole: "MindRoleSiliconBrain"
silent: true

- type: entity
id: PlayerBorgSyndicateAssaultBattery
Expand Down

0 comments on commit c326482

Please sign in to comment.