From 4611d54cb309f1391e8268b6e64f53f340e8fad8 Mon Sep 17 00:00:00 2001 From: Milon Date: Tue, 29 Oct 2024 13:04:08 +0100 Subject: [PATCH 1/4] aaaaaaaaaaa --- .../GhostRoleCharacterSpawnerComponent.cs | 18 ++++++++++--- .../Ghost/Roles/GhostRoleSystem.Character.cs | 13 ++++++++- .../Entities/Markers/Spawners/ghost_roles.yml | 27 ++++++++++++++++--- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs b/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs index e2aaa94d948f..53f523b2ecb5 100644 --- a/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs +++ b/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs @@ -7,16 +7,28 @@ [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")] + [DataField] public string OutfitPrototype = "PassengerGear"; + + /// + /// Whether to give the MindShield and AntagImmune components on spawn. + /// + [DataField] + public bool MindShield; + + /// + /// Whether to give the TargetObjectiveImmune component on spawn. + /// + [DataField] + public bool TargetObjectiveImmune; } } diff --git a/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs b/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs index e13050add487..7dca836f2f40 100644 --- a/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs +++ b/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs @@ -1,12 +1,14 @@ 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; -using Robust.Shared.Prototypes; namespace Content.Server.Ghost.Roles { @@ -45,6 +47,15 @@ private void OnSpawnerTakeCharacter( EntityUid uid, GhostRoleCharacterSpawnerCom if (outfit != null) SetOutfitCommand.SetOutfit(mob, outfit, _entityManager); + if (component.MindShield) + { + EnsureComp(mob); + EnsureComp(mob); + } + + if (component.TargetObjectiveImmune) + EnsureComp(mob); + if (++component.CurrentTakeovers < component.AvailableTakeovers) { args.TookRole = true; diff --git a/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml b/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml index a3cf33bf1f30..33012958febd 100644 --- a/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml +++ b/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml @@ -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 @@ -17,6 +17,25 @@ - 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 + mindShield: true + +- type: entity + parent: SpawnPointPlayerCharacter + id: SpawnPointPlayerCharacterTargetImmune + name: ghost role spawn point + suffix: mindshielded, KillObjectiveImmune, player character + components: + - type: GhostRoleCharacterSpawner + mindShield: true + targetObjectiveImmune: true + - type: entity # Part of ListeningPost categories: [ HideSpawnMenu, Spawner ] parent: BaseAntagSpawner From b5c3a3973ff6b5ca188dc988d4a8ce458e1a166b Mon Sep 17 00:00:00 2001 From: Milon Date: Tue, 5 Nov 2024 22:12:12 +0100 Subject: [PATCH 2/4] guh --- .../GhostRoleCharacterSpawnerComponent.cs | 17 ++++++------- .../Ghost/Roles/GhostRoleSystem.Character.cs | 25 +++++-------------- .../Entities/Markers/Spawners/ghost_roles.yml | 9 ++++--- 3 files changed, 19 insertions(+), 32 deletions(-) diff --git a/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs b/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs index 53f523b2ecb5..9e08fd17aebe 100644 --- a/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs +++ b/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs @@ -1,4 +1,7 @@ -namespace Content.Server.Ghost.Roles.Components +using Content.Shared.Roles; +using Robust.Shared.Prototypes; + +namespace Content.Server.Ghost.Roles.Components { /// /// Allows a ghost to take this role, spawning their selected character. @@ -17,18 +20,12 @@ public sealed partial class GhostRoleCharacterSpawnerComponent : Component public int CurrentTakeovers = 0; [DataField] - public string OutfitPrototype = "PassengerGear"; - - /// - /// Whether to give the MindShield and AntagImmune components on spawn. - /// - [DataField] - public bool MindShield; + public ProtoId OutfitPrototype = "PassengerGear"; /// - /// Whether to give the TargetObjectiveImmune component on spawn. + /// Components to give on spawn. /// [DataField] - public bool TargetObjectiveImmune; + public ComponentRegistry Components = new(); } } diff --git a/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs b/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs index 7dca836f2f40..300e95745306 100644 --- a/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs +++ b/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs @@ -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 { @@ -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 ent, ref TakeGhostRoleEvent args) { + var uid = ent.Owner; + var component = ent.Comp; + if (!TryComp(uid, out GhostRoleComponent? ghostRole) || ghostRole.Taken) { @@ -33,10 +32,6 @@ private void OnSpawnerTakeCharacter( EntityUid uid, GhostRoleCharacterSpawnerCom .SpawnPlayerMob(Transform(uid).Coordinates, null, character, null); _transform.AttachToGridOrMap(mob); - string? outfit = null; - if (_prototype.TryIndex(component.OutfitPrototype, out var outfitProto)) - outfit = outfitProto.ID; - var spawnedEvent = new GhostRoleSpawnerUsedEvent(uid, mob); RaiseLocalEvent(mob, spawnedEvent); @@ -44,17 +39,9 @@ private void OnSpawnerTakeCharacter( EntityUid uid, GhostRoleCharacterSpawnerCom GhostRoleInternalCreateMindAndTransfer(args.Player, uid, mob, ghostRole); - if (outfit != null) - SetOutfitCommand.SetOutfit(mob, outfit, _entityManager); - - if (component.MindShield) - { - EnsureComp(mob); - EnsureComp(mob); - } + SetOutfitCommand.SetOutfit(mob, component.OutfitPrototype, _entityManager); - if (component.TargetObjectiveImmune) - EnsureComp(mob); + EntityManager.AddComponents(mob, component.Components); if (++component.CurrentTakeovers < component.AvailableTakeovers) { diff --git a/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml b/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml index 33012958febd..2f8edf147b2b 100644 --- a/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml +++ b/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml @@ -24,7 +24,8 @@ suffix: mindshielded, player character components: - type: GhostRoleCharacterSpawner - mindShield: true + components: + - MindShield - type: entity parent: SpawnPointPlayerCharacter @@ -33,8 +34,10 @@ suffix: mindshielded, KillObjectiveImmune, player character components: - type: GhostRoleCharacterSpawner - mindShield: true - targetObjectiveImmune: true + components: + - MindShield + - AntagImmune + - TargetObjectiveImmune - type: entity # Part of ListeningPost categories: [ HideSpawnMenu, Spawner ] From e4e129c3e9c37615ad4a7dcdc1c0bf2b14858cf5 Mon Sep 17 00:00:00 2001 From: Milon Date: Tue, 5 Nov 2024 22:25:17 +0100 Subject: [PATCH 3/4] epic fail --- .../Roles/Components/GhostRoleCharacterSpawnerComponent.cs | 2 +- .../DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs | 2 +- .../DeltaV/Entities/Markers/Spawners/ghost_roles.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs b/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs index 9e08fd17aebe..63eb96f520af 100644 --- a/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs +++ b/Content.Server/DeltaV/Ghost/Roles/Components/GhostRoleCharacterSpawnerComponent.cs @@ -26,6 +26,6 @@ public sealed partial class GhostRoleCharacterSpawnerComponent : Component /// Components to give on spawn. /// [DataField] - public ComponentRegistry Components = new(); + public ComponentRegistry AddedComponents = new(); } } diff --git a/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs b/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs index 300e95745306..f8320f7514c1 100644 --- a/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs +++ b/Content.Server/DeltaV/Ghost/Roles/GhostRoleSystem.Character.cs @@ -41,7 +41,7 @@ private void OnSpawnerTakeCharacter(Entity e SetOutfitCommand.SetOutfit(mob, component.OutfitPrototype, _entityManager); - EntityManager.AddComponents(mob, component.Components); + EntityManager.AddComponents(mob, component.AddedComponents); if (++component.CurrentTakeovers < component.AvailableTakeovers) { diff --git a/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml b/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml index 2f8edf147b2b..ea504b2f8824 100644 --- a/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml +++ b/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml @@ -24,7 +24,7 @@ suffix: mindshielded, player character components: - type: GhostRoleCharacterSpawner - components: + addedComponents: - MindShield - type: entity @@ -34,7 +34,7 @@ suffix: mindshielded, KillObjectiveImmune, player character components: - type: GhostRoleCharacterSpawner - components: + addedComponents: - MindShield - AntagImmune - TargetObjectiveImmune From 1e2ed639ab4d6ac4846243eea96c2dff22b19a5f Mon Sep 17 00:00:00 2001 From: Milon Date: Wed, 6 Nov 2024 02:41:20 +0100 Subject: [PATCH 4/4] fuck it we ball --- .../DeltaV/Entities/Markers/Spawners/ghost_roles.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml b/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml index ea504b2f8824..0b822f9a1b46 100644 --- a/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml +++ b/Resources/Prototypes/DeltaV/Entities/Markers/Spawners/ghost_roles.yml @@ -25,7 +25,7 @@ components: - type: GhostRoleCharacterSpawner addedComponents: - - MindShield + - type: MindShield - type: entity parent: SpawnPointPlayerCharacter @@ -35,9 +35,9 @@ components: - type: GhostRoleCharacterSpawner addedComponents: - - MindShield - - AntagImmune - - TargetObjectiveImmune + - type: MindShield + - type: AntagImmune + - type: TargetObjectiveImmune - type: entity # Part of ListeningPost categories: [ HideSpawnMenu, Spawner ]