forked from DeltaV-Station/Delta-v
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
paradox anomaly antag rework (DeltaV-Station#1206)
* move paradox code around and update it * make MidRoundAntagRule just give spawn locations * update the yaml * give anom and listening post raffles --------- Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: Null <[email protected]>
- Loading branch information
1 parent
6a1749a
commit 94d3fda
Showing
10 changed files
with
195 additions
and
250 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
Content.Server/DeltaV/ParadoxAnomaly/Components/ParadoxAnomalySpawner.cs
This file was deleted.
Oops, something went wrong.
164 changes: 0 additions & 164 deletions
164
Content.Server/DeltaV/ParadoxAnomaly/Systems/ParadoxAnomalySystem.cs
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
Content.Server/DeltaV/StationEvents/Components/ParadoxClonerRuleComponent.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,7 @@ | ||
namespace Content.Server.StationEvents.Components; | ||
|
||
/// <summary> | ||
/// Creates a paradox anomaly of a random person when taken by a player. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class ParadoxClonerRuleComponent : Component; |
104 changes: 104 additions & 0 deletions
104
Content.Server/DeltaV/StationEvents/Events/ParadoxClonerRule.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,104 @@ | ||
using Content.Server.Antag; | ||
using Content.Server.GameTicking.Rules; | ||
using Content.Server.Psionics; | ||
using Content.Server.Station.Systems; | ||
using Content.Server.StationEvents.Components; | ||
using Content.Server.StationEvents.Events; | ||
using Content.Server.Terminator.Systems; | ||
using Content.Shared.Humanoid; | ||
using Content.Shared.Humanoid.Prototypes; | ||
using Content.Shared.Mind; | ||
using Content.Shared.Mind.Components; | ||
using Content.Shared.Preferences; | ||
using Content.Shared.Roles; | ||
using Content.Shared.Roles.Jobs; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
using Robust.Shared.Utility; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Content.Server.StationEvents.Events; | ||
|
||
/// <summary> | ||
/// Creates clones of random players to make into selected antags. | ||
/// 90% of the actual antag's work is done by exterminator (rip) since its a reskin. | ||
/// </summary> | ||
public sealed class ParadoxClonerRule : StationEventSystem<ParadoxClonerRuleComponent> | ||
{ | ||
[Dependency] private readonly IPrototypeManager _proto = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly PsionicsSystem _psionics = default!; | ||
[Dependency] private readonly SharedMindSystem _mind = default!; | ||
[Dependency] private readonly SharedRoleSystem _role = default!; | ||
[Dependency] private readonly StationSystem _station = default!; | ||
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!; | ||
[Dependency] private readonly TerminatorSystem _terminator = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<ParadoxClonerRuleComponent, AntagSelectEntityEvent>(OnSelectEntity); | ||
} | ||
|
||
private void OnSelectEntity(Entity<ParadoxClonerRuleComponent> ent, ref AntagSelectEntityEvent args) | ||
{ | ||
if (args.Session?.AttachedEntity is not {} spawner) | ||
return; | ||
|
||
Log.Debug($"Rule {ToPrettyString(ent)} creating a paradox anomaly using spawner {spawner}"); | ||
if (!TrySpawnParadoxAnomaly(spawner, out var clone)) | ||
return; | ||
|
||
Log.Info($"Created paradox anomaly {ToPrettyString(clone):clone}"); | ||
args.Entity = clone; | ||
} | ||
|
||
private bool TrySpawnParadoxAnomaly(EntityUid spawner, [NotNullWhen(true)] out EntityUid? clone) | ||
{ | ||
clone = null; | ||
|
||
// Get a list of potential candidates | ||
var candidates = new List<(EntityUid, Entity<JobComponent>, HumanoidCharacterProfile)>(); | ||
var query = EntityQueryEnumerator<MindContainerComponent, HumanoidAppearanceComponent>(); | ||
while (query.MoveNext(out var uid, out var mindContainer, out var humanoid)) | ||
{ | ||
if (humanoid.LastProfileLoaded is {} profile && | ||
_mind.GetMind(uid, mindContainer) is {} mindId && | ||
TryComp<JobComponent>(mindId, out var job) && | ||
!_role.MindIsAntagonist(mindId)) | ||
{ | ||
candidates.Add((uid, (mindId, job), profile)); | ||
} | ||
} | ||
|
||
if (candidates.Count == 0) | ||
{ | ||
Log.Warning("Found no eligible players to paradox clone!"); | ||
return false; | ||
} | ||
|
||
clone = SpawnParadoxAnomaly(spawner, candidates); | ||
return true; | ||
} | ||
|
||
private EntityUid SpawnParadoxAnomaly(EntityUid spawner, List<(EntityUid, Entity<JobComponent>, HumanoidCharacterProfile)> candidates) | ||
{ | ||
// Select a candidate. | ||
var (uid, (mindId, job), profile) = _random.Pick(candidates); | ||
|
||
// Spawn the clone. | ||
var coords = Transform(spawner).Coordinates; | ||
var station = _station.GetOwningStation(uid); | ||
var spawned = _stationSpawning.SpawnPlayerMob(coords, job, profile, station); | ||
|
||
// Set the kill target to the chosen player | ||
_terminator.SetTarget(spawned, mindId); | ||
|
||
// guaranteed psionic power | ||
var psi = EnsureComp<PotentialPsionicComponent>(spawned); | ||
_psionics.RollPsionics(spawned, psi, false, 100); | ||
|
||
return spawned; | ||
} | ||
} |
19 changes: 6 additions & 13 deletions
19
Content.Server/Nyanotrasen/StationEvents/Components/MidRoundAntagRuleComponent.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 |
---|---|---|
@@ -1,15 +1,8 @@ | ||
using Content.Server.Nyanotrasen.StationEvents.Events; | ||
using Content.Server.StationEvents.Events; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.StationEvents.Components; | ||
|
||
[RegisterComponent, Access(typeof(MidRoundAntagRule))] | ||
public sealed partial class MidRoundAntagRuleComponent : Component | ||
{ | ||
/// <summary> | ||
/// Spawner to create at a random mid round antag marker. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public EntProtoId Spawner = string.Empty; | ||
} | ||
/// <summary> | ||
/// Spawns any antags at random midround antag spawnpoints, falls back to vent critter spawners. | ||
/// Requires <c>AntagSelection</c>. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class MidRoundAntagRuleComponent : Component; |
10 changes: 3 additions & 7 deletions
10
Content.Server/Nyanotrasen/StationEvents/Components/MidRoundAntagSpawnLocationComponent.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 |
---|---|---|
@@ -1,8 +1,4 @@ | ||
namespace Content.Server.StationEvents | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class MidRoundAntagSpawnLocationComponent : Component | ||
{ | ||
namespace Content.Server.StationEvents; | ||
|
||
} | ||
} | ||
[RegisterComponent] | ||
public sealed partial class MidRoundAntagSpawnLocationComponent : Component; |
Oops, something went wrong.