Skip to content

Commit

Permalink
guh
Browse files Browse the repository at this point in the history
  • Loading branch information
MilonPL committed Nov 5, 2024
1 parent 4611d54 commit 0b716b6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Content.Server.Ghost.Roles.Components
using Content.Shared.Roles;
using Robust.Shared.Prototypes;

namespace Content.Server.Ghost.Roles.Components
{
/// <summary>
/// Allows a ghost to take this role, spawning their selected character.
Expand All @@ -17,18 +20,12 @@ public sealed partial class GhostRoleCharacterSpawnerComponent : Component
public int CurrentTakeovers = 0;

[DataField]
public string OutfitPrototype = "PassengerGear";

/// <summary>
/// Whether to give the MindShield and AntagImmune components on spawn.
/// </summary>
[DataField]
public bool MindShield;
public ProtoId<StartingGearPrototype> OutfitPrototype = "PassengerGear";

/// <summary>
/// Whether to give the TargetObjectiveImmune component on spawn.
/// Components to give on spawn.
/// </summary>
[DataField]
public bool TargetObjectiveImmune;
public ComponentRegistry Components = new();
}
}
25 changes: 6 additions & 19 deletions Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using Content.Server.Administration.Commands;
using Content.Server.Antag.Components;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Ghost.Roles.Events;
using Content.Server.Objectives.Components;
using Content.Server.Preferences.Managers;
using Content.Server.Station.Systems;
using Content.Shared.Mind.Components;
using Content.Shared.Mindshield.Components;
using Content.Shared.Preferences;
using Content.Shared.Roles;

namespace Content.Server.Ghost.Roles
{
Expand All @@ -17,9 +13,12 @@ public sealed partial class GhostRoleSystem
[Dependency] private readonly IServerPreferencesManager _prefs = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;

private void OnSpawnerTakeCharacter( EntityUid uid, GhostRoleCharacterSpawnerComponent component,
private void OnSpawnerTakeCharacter(Entity<GhostRoleCharacterSpawnerComponent> ent,
ref TakeGhostRoleEvent args)
{
var uid = ent.Owner;
var component = ent.Comp;

if (!TryComp(uid, out GhostRoleComponent? ghostRole) ||
ghostRole.Taken)
{
Expand All @@ -33,28 +32,16 @@ private void OnSpawnerTakeCharacter( EntityUid uid, GhostRoleCharacterSpawnerCom
.SpawnPlayerMob(Transform(uid).Coordinates, null, character, null);
_transform.AttachToGridOrMap(mob);

string? outfit = null;
if (_prototype.TryIndex<StartingGearPrototype>(component.OutfitPrototype, out var outfitProto))
outfit = outfitProto.ID;

var spawnedEvent = new GhostRoleSpawnerUsedEvent(uid, mob);
RaiseLocalEvent(mob, spawnedEvent);

EnsureComp<MindContainerComponent>(mob);

GhostRoleInternalCreateMindAndTransfer(args.Player, uid, mob, ghostRole);

if (outfit != null)
SetOutfitCommand.SetOutfit(mob, outfit, _entityManager);

if (component.MindShield)
{
EnsureComp<MindShieldComponent>(mob);
EnsureComp<AntagImmuneComponent>(mob);
}
SetOutfitCommand.SetOutfit(mob, component.OutfitPrototype, _entityManager);

if (component.TargetObjectiveImmune)
EnsureComp<TargetObjectiveImmuneComponent>(mob);
EntityManager.AddComponents(mob, component.Components);

if (++component.CurrentTakeovers < component.AvailableTakeovers)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
suffix: mindshielded, player character
components:
- type: GhostRoleCharacterSpawner
mindShield: true
components:
- MindShield

- type: entity
parent: SpawnPointPlayerCharacter
Expand All @@ -33,8 +34,9 @@
suffix: mindshielded, KillObjectiveImmune, player character
components:
- type: GhostRoleCharacterSpawner
mindShield: true
targetObjectiveImmune: true
components:
- MindShield
- AntagImmune

- type: entity # Part of ListeningPost
categories: [ HideSpawnMenu, Spawner ]
Expand Down

0 comments on commit 0b716b6

Please sign in to comment.