mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Scope creep my ass * why was this shit not pushed???? * gone... * fix that * review plus buildd * asfsafsafsafsafas * grug * burber * I'll fix this later * shrimply die * also this * it's snerf or snuthin * assaads * round snend * aaaa * fix this shit for real * actually, don't start GameRules until MapInit now that I think aboot it. * forgot u * don't actually need this part nullable * Deffer comp removal * one liner * do that too * chungus * Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?) * deferred removal :V * aaaaaaaaaaaaaaa * whhop * Whoop * better * landmine that I placed for myself then forgot about lmao * cleanup * FUCKING `!` * gotovo * amogus * please don't check by metadata I beg * waawsasfdfsasfa * sfafsasfafsas * fdsaasffsasfa * code * fix * fasasffasfasfsad * chungaas * I may be stupid * gra * graaaaaaaaaaaaaaaaa * comment * gra * clearing is not predicted and would require major refactors, so don't cache on client. * lame shit :P * last holes * nukeopsfsafsasafsfafsa * why was that shit public bruh * bubrbgwahrghfaka * dynamic * revert change that did nothing lmao
100 lines
4.2 KiB
C#
100 lines
4.2 KiB
C#
using Content.Server.GameTicking.Rules;
|
|
using Content.Server.Silicons.Borgs;
|
|
using Content.Shared.Antag;
|
|
using Content.Shared.Destructible;
|
|
using Content.Shared.GameTicking.Rules.Components;
|
|
using Content.Shared.Mind.Components;
|
|
using Content.Shared.Roles;
|
|
using Content.Shared.Silicons.Borgs.Components;
|
|
using Content.Shared.Xenoborgs.Components;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Server.Xenoborgs;
|
|
|
|
public sealed partial class XenoborgSystem : EntitySystem
|
|
{
|
|
[Dependency] private AntagSelectionSystem _antag = default!;
|
|
[Dependency] private BorgSystem _borg = default!;
|
|
[Dependency] private SharedRoleSystem _roles = default!;
|
|
[Dependency] private ServerXenoborgsRuleSystem _xenoborgsRule = default!;
|
|
|
|
private static readonly Color XenoborgBriefingColor = Color.BlueViolet;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<XenoborgComponent, DestructionEventArgs>(OnXenoborgDestroyed);
|
|
SubscribeLocalEvent<MothershipCoreComponent, DestructionEventArgs>(OnCoreDestroyed);
|
|
|
|
SubscribeLocalEvent<XenoborgComponent, MindAddedMessage>(OnXenoborgMindAdded);
|
|
SubscribeLocalEvent<XenoborgComponent, MindRemovedMessage>(OnXenoborgMindRemoved);
|
|
}
|
|
|
|
private void OnXenoborgDestroyed(EntityUid uid, XenoborgComponent component, DestructionEventArgs args)
|
|
{
|
|
// if a xenoborg is destroyed, it will check to see if it was the last one
|
|
var xenoborgQuery = AllEntityQuery<XenoborgComponent>(); // paused xenoborgs still count
|
|
while (xenoborgQuery.MoveNext(out var xenoborg, out _))
|
|
{
|
|
if (xenoborg != uid)
|
|
return;
|
|
}
|
|
|
|
var mothershipCoreQuery = AllEntityQuery<MothershipCoreComponent>(); // paused mothership cores still count
|
|
var mothershipCoreAlive = mothershipCoreQuery.MoveNext(out _, out _);
|
|
|
|
var xenoborgsRuleQuery = EntityQueryEnumerator<XenoborgsRuleComponent>();
|
|
if (xenoborgsRuleQuery.MoveNext(out var xenoborgsRuleEnt, out var xenoborgsRuleComp))
|
|
_xenoborgsRule.SendXenoborgDeathAnnouncement((xenoborgsRuleEnt, xenoborgsRuleComp), mothershipCoreAlive);
|
|
}
|
|
|
|
private void OnCoreDestroyed(EntityUid ent, MothershipCoreComponent component, DestructionEventArgs args)
|
|
{
|
|
// if a mothership core is destroyed, it will see if there are any others
|
|
var mothershipCoreQuery = AllEntityQuery<MothershipCoreComponent>(); // paused mothership cores still count
|
|
while (mothershipCoreQuery.MoveNext(out var mothershipCoreEnt, out _))
|
|
{
|
|
// if it finds a mothership core that is different from the one just destroyed,
|
|
// it doesn't explode the xenoborgs
|
|
if (mothershipCoreEnt != ent)
|
|
return;
|
|
}
|
|
|
|
var xenoborgsRuleQuery = EntityQueryEnumerator<XenoborgsRuleComponent>();
|
|
if (xenoborgsRuleQuery.MoveNext(out var xenoborgsRuleEnt, out var xenoborgsRuleComp))
|
|
_xenoborgsRule.SendMothershipDeathAnnouncement((xenoborgsRuleEnt, xenoborgsRuleComp));
|
|
|
|
// explode all xenoborgs
|
|
var xenoborgQuery = AllEntityQuery<XenoborgComponent, BorgTransponderComponent>(); // paused xenoborgs still explode
|
|
while (xenoborgQuery.MoveNext(out var xenoborgEnt, out _, out _))
|
|
{
|
|
if (HasComp<MothershipCoreComponent>(xenoborgEnt))
|
|
continue;
|
|
|
|
// I got tired to trying to make this work via the device network.
|
|
// so brute force it is...
|
|
_borg.Destroy(xenoborgEnt);
|
|
}
|
|
}
|
|
|
|
private void OnXenoborgMindAdded(EntityUid ent, XenoborgComponent comp, MindAddedMessage args)
|
|
{
|
|
_roles.MindAddRole(args.Mind, comp.MindRole, silent: true);
|
|
|
|
if (!TryComp<ActorComponent>(ent, out var actorComp))
|
|
return;
|
|
|
|
_antag.SendBriefing(actorComp.PlayerSession,
|
|
Loc.GetString(comp.BriefingText),
|
|
XenoborgBriefingColor,
|
|
comp.BriefingSound
|
|
);
|
|
}
|
|
|
|
private void OnXenoborgMindRemoved(EntityUid ent, XenoborgComponent comp, MindRemovedMessage args)
|
|
{
|
|
// We don't need to update the mind if the mind is being fully detached!
|
|
if (args.TransferEntity != null)
|
|
_roles.MindRemoveRole(args.Mind.Owner, comp.MindRole);
|
|
}
|
|
}
|