-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Content.Server.Ghost.Roles.Components | ||
{ | ||
/// <summary> | ||
/// Allows a ghost to take this role, spawning their selected character. | ||
/// </summary> | ||
[RegisterComponent] | ||
[Access(typeof(GhostRoleSystem))] | ||
public sealed partial class GhostRoleCharacterSpawnerComponent : Component | ||
{ | ||
[ViewVariables(VVAccess.ReadWrite)] [DataField("deleteOnSpawn")] | ||
public bool DeleteOnSpawn = true; | ||
|
||
[ViewVariables(VVAccess.ReadWrite)] [DataField("availableTakeovers")] | ||
public int AvailableTakeovers = 1; | ||
|
||
[ViewVariables] | ||
public int CurrentTakeovers = 0; | ||
|
||
[ViewVariables(VVAccess.ReadWrite)] [DataField("outfitPrototype")] | ||
public string OutfitPrototype = "PassengerGear"; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using Content.Server.Administration.Commands; | ||
using Content.Server.Ghost.Roles.Components; | ||
using Content.Server.Ghost.Roles.Events; | ||
using Content.Server.Preferences.Managers; | ||
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 | ||
{ | ||
public sealed partial class GhostRoleSystem | ||
{ | ||
[Dependency] private readonly IServerPreferencesManager _prefs = default!; | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
|
||
private void OnSpawnerTakeCharacter( EntityUid uid, GhostRoleCharacterSpawnerComponent component, | ||
ref TakeGhostRoleEvent args) | ||
{ | ||
if (!TryComp(uid, out GhostRoleComponent? ghostRole) || | ||
ghostRole.Taken) | ||
{ | ||
args.TookRole = false; | ||
return; | ||
} | ||
|
||
var character = (HumanoidCharacterProfile) _prefs.GetPreferences(args.Player.UserId).SelectedCharacter; | ||
|
||
var mob = _entityManager.System<StationSpawningSystem>() | ||
.SpawnPlayerMob(Transform(uid).Coordinates, null, character, null); | ||
_transform.AttachToGridOrMap(mob); | ||
|
||
string? outfit = null; | ||
if (_prototypeManager.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.CurrentTakeovers < component.AvailableTakeovers) | ||
{ | ||
args.TookRole = true; | ||
return; | ||
} | ||
|
||
ghostRole.Taken = true; | ||
|
||
if (component.DeleteOnSpawn) | ||
QueueDel(uid); | ||
|
||
args.TookRole = true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
- type: entity | ||
id: SpawnPointPlayerCharacter | ||
name: ghost role spawn point | ||
suffix: player character, DO NOT MAP | ||
parent: MarkerBase | ||
components: | ||
- type: GhostRole | ||
name: Roleplay Ghost Role | ||
description: Placeholder | ||
rules: Placeholder | ||
- type: GhostRoleCharacterSpawner | ||
- type: Sprite | ||
sprite: Markers/jobs.rsi | ||
layers: | ||
- state: green | ||
- sprite: Mobs/Species/Human/parts.rsi | ||
state: full |