Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the return of player character spawners (feat. mindshield bullshit) #2072

Merged
merged 4 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -7,16 +10,22 @@
[Access(typeof(GhostRoleSystem))]
public sealed partial class GhostRoleCharacterSpawnerComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)] [DataField("deleteOnSpawn")]
[DataField]
public bool DeleteOnSpawn = true;

[ViewVariables(VVAccess.ReadWrite)] [DataField("availableTakeovers")]
[DataField]
public int AvailableTakeovers = 1;

[ViewVariables]
public int CurrentTakeovers = 0;

[ViewVariables(VVAccess.ReadWrite)] [DataField("outfitPrototype")]
public string OutfitPrototype = "PassengerGear";
[DataField]
public ProtoId<StartingGearPrototype> OutfitPrototype = "PassengerGear";

/// <summary>
/// Components to give on spawn.
/// </summary>
[DataField]
public ComponentRegistry AddedComponents = new();
}
}
16 changes: 7 additions & 9 deletions Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using Content.Server.Station.Systems;
using Content.Shared.Mind.Components;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Shared.Prototypes;

namespace Content.Server.Ghost.Roles
{
Expand All @@ -15,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 @@ -31,19 +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);
SetOutfitCommand.SetOutfit(mob, component.OutfitPrototype, _entityManager);

EntityManager.AddComponents(mob, component.AddedComponents);

if (++component.CurrentTakeovers < component.AvailableTakeovers)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
- type: entity
categories: [ HideSpawnMenu, Spawner ]
categories: [ Spawner ]
parent: MarkerBase
id: SpawnPointPlayerCharacter
name: ghost role spawn point
suffix: player character, DO NOT MAP
suffix: player character
components:
- type: GhostRole
name: Roleplay Ghost Role
description: Placeholder
rules: Placeholder
description: This is a custom event ghost role.
rules: ghost-role-component-default-rules
- type: GhostRoleCharacterSpawner
- type: Sprite
sprite: Markers/jobs.rsi
Expand All @@ -17,6 +17,28 @@
- sprite: Mobs/Species/Human/parts.rsi
state: full

- type: entity
parent: SpawnPointPlayerCharacter
id: SpawnPointPlayerCharacterMindShield
name: ghost role spawn point
suffix: mindshielded, player character
components:
- type: GhostRoleCharacterSpawner
addedComponents:
- type: MindShield

- type: entity
parent: SpawnPointPlayerCharacter
id: SpawnPointPlayerCharacterTargetImmune
name: ghost role spawn point
suffix: mindshielded, KillObjectiveImmune, player character
components:
- type: GhostRoleCharacterSpawner
addedComponents:
- type: MindShield
- type: AntagImmune
- type: TargetObjectiveImmune

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