fish-station/Content.Server/Terminator/Systems/TerminatorSystem.cs
pacable 556d234b0a
Терминатор (#333)
* Revert Revert Exterminator pending newmed/redesign (#26978)

This reverts commit f544c912

Signed-off-by: pacable <igor.mamaev1@gmail.com>

* Revert "remove GenericAntag completely (#28218)"

This reverts commit 489efeb717.

* Revert "remove TerminatorRoleComponent (#30733)"

This reverts commit 0a4b220854.

* fix broken tag

Signed-off-by: pacable <igor.mamaev1@gmail.com>

* delete invisible symbol

Signed-off-by: pacable <igor.mamaev1@gmail.com>

* ru locale

Signed-off-by: pacable <igor.mamaev1@gmail.com>

---------

Signed-off-by: pacable <igor.mamaev1@gmail.com>
2024-08-29 16:07:25 +03:00

66 lines
2.1 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);
}
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>
/// 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;
}
}