Files
wwdpublic/Content.Server/Terminator/Systems/TerminatorSystem.cs
deltanedas 9985ee9788 bring back paradox anomaly (#825)
* refactor and add log

* add api needed for objective

* backport LastProfileLoaded

* fix midround antag rule

* evil twin spawning code

* evil twin yml and stuff

* m

* hopefully fully rename it

* fixy

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
2024-02-13 16:55:35 +01:00

76 lines
2.4 KiB
C#

using Content.Server.Body.Components;
using Content.Server.GenericAntag;
using Content.Server.Ghost.Roles.Events;
using Content.Server.Roles;
using Content.Server.Terminator.Components;
using Content.Shared.Roles;
using Robust.Shared.Map;
namespace Content.Server.Terminator.Systems;
public sealed class TerminatorSystem : EntitySystem
{
[Dependency] private readonly SharedRoleSystem _role = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<TerminatorComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<TerminatorComponent, GhostRoleSpawnerUsedEvent>(OnSpawned);
SubscribeLocalEvent<TerminatorComponent, GenericAntagCreatedEvent>(OnCreated);
}
private void OnMapInit(EntityUid uid, TerminatorComponent comp, MapInitEvent args)
{
// cyborg doesn't need to breathe
//RemComp<RespiratorComponent>(uid); // DeltaV - paradox anomaly does actually need to breathe
}
private void OnSpawned(EntityUid uid, TerminatorComponent comp, GhostRoleSpawnerUsedEvent args)
{
if (!TryComp<TerminatorTargetComponent>(args.Spawner, out var target))
return;
comp.Target = target.Target;
}
private void OnCreated(EntityUid uid, TerminatorComponent comp, ref GenericAntagCreatedEvent args)
{
var mindId = args.MindId;
var mind = args.Mind;
_role.MindAddRole(mindId, new RoleBriefingComponent
{
Briefing = Loc.GetString("terminator-role-briefing")
}, mind);
_role.MindAddRole(mindId, new TerminatorRoleComponent(), mind);
}
/// <summary>
/// DeltaV - used for paradox anomaly.
/// </summary>
public void SetTarget(Entity<TerminatorComponent?> ent, EntityUid mindId)
{
ent.Comp ??= EnsureComp<TerminatorComponent>(ent);
ent.Comp.Target = mindId;
}
/// <summary>
/// Create a spawner at a position and return it.
/// </summary>
/// <param name="coords">Coordinates to create the spawner at</param>
/// <param name="target">Optional target mind to force the terminator to target</param>
public EntityUid CreateSpawner(EntityCoordinates coords, EntityUid? target)
{
var uid = Spawn("SpawnPointGhostTerminator", coords);
if (target != null)
{
var comp = EnsureComp<TerminatorTargetComponent>(uid);
comp.Target = target;
}
return uid;
}
}