mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Refactor DeviceNetwork * Singleton * NetworkPayloads refactor * Reorganize DeviceNetworkSystem * Surveillance cameras * Fix code * Fix build * Fix test fail by rewriting entire singleton logic * Properly predict examine * Update DeviceNetworkSystem.API.cs * Update EntityTest.cs * Update DeviceNetworkSystem.cs * Alright I'll do this expensive check fine * Fix disposals debug assert * Implement device network static events support * Use frozen dictionaries for performance * Update SharedDeviceNetworkSystem.Payloads.cs * Parallel payload handling support * Fix some spagetti-code * Optimize NetworkPayload cancellation * Parallel payloads are now cancellable * Fix screens * Fix robotics console * Allow new methods for shared * Mail fix * Turret fix * Fix network system method usage + signal and borg fix * finally fix atmos devices OH MY GOOOD * Remove stupid parallelism from fax * Fix surveiollance cameras * Working on a single thing for 2 days straight award * Fix the test? * Update units.yml * Add IDevice interface because why not * Add more device network suffixes * Fix camera router failing test * yaml linter peak * Improve docs for DeviceNetworkHandlers * fix build * Update CartridgeLoaderSystem.Relay.cs * Remove parallel system and EntitySystem post init * Add more docs and also events * Remove unnecessary caching * Update DevicePayloadComponentSystem.cs * Back to entity events * Implement DeviceData * Remove serializable from payloads * Update DeviceData.cs * Add a prototype for a singleton * Fix tests * Fix air alarms * Update DeviceNetworkSystem.cs * Fix cameras * Make camera router event-less * Fix atmos sync payloads, add more docs * Remove singleton + instant packets * oops remove public access * Fix tests? * Why the hell overload effect makes puddle sparks * Apparently it was redundant * Update gates.yml * Finish documentation * Review * Mark relay properties as obsolete * Struct payloads support (#blazinglyfastmemorysafe) * Update DeviceNetworkTest.cs * Make device structs stuff better * Move address prefix to DeviceNetworkComponent * Locale fixes * Fix tests * Doesn't know boolean logic award * Update AtmosAlarmableSystem.cs * Fix address predicted examine * Partial fix to air alarmables * Fix deployable turrets UI * Fix firelocks, maybe * Apparently Activatable UI was enough lol * Fix surveillance cameras * Rename `QueuePacket` into `SendPacket` * Simplify DeviceData as much as possible * Update DeviceData.cs * Update FaxMachineComponent.cs * Remove DeviceData because its stupid * Update ScreenSystem.cs * Fix build (camera map broken still) * Fix map * fix usings * Review changes * Build fix
105 lines
4.3 KiB
C#
105 lines
4.3 KiB
C#
using Content.Server.Antag;
|
|
using Content.Server.Cloning;
|
|
using Content.Server.GameTicking.Rules.Components;
|
|
using Content.Server.Medical.SuitSensors;
|
|
using Content.Server.Objectives.Components;
|
|
using Content.Shared.GameTicking.Components;
|
|
using Content.Shared.Gibbing.Components;
|
|
using Content.Shared.Medical.SuitSensors;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Objectives.Systems;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.GameTicking.Rules;
|
|
|
|
public sealed partial class ParadoxCloneRuleSystem : GameRuleSystem<ParadoxCloneRuleComponent>
|
|
{
|
|
[Dependency] private IRobustRandom _random = default!;
|
|
[Dependency] private CloningSystem _cloning = default!;
|
|
[Dependency] private SharedMindSystem _mind = default!;
|
|
[Dependency] private SuitSensorSystem _sensor = default!;
|
|
[Dependency] private AliveHumanoidTargetSystem _target = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ParadoxCloneRuleComponent, AntagSelectEntityEvent>(OnAntagSelectEntity);
|
|
SubscribeLocalEvent<ParadoxCloneRuleComponent, AfterAntagEntitySelectedEvent>(AfterAntagEntitySelected);
|
|
}
|
|
|
|
protected override void Started(EntityUid uid, ParadoxCloneRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
|
|
{
|
|
base.Started(uid, component, gameRule, args);
|
|
|
|
// check if we got enough potential cloning targets, otherwise cancel the gamerule so that the ghost role does not show up
|
|
var allHumans = _target.GetMinds();
|
|
|
|
if (allHumans.Count == 0)
|
|
{
|
|
Log.Info("Could not find any alive players to create a paradox clone from! Ending gamerule.");
|
|
ForceEndSelf(uid, gameRule);
|
|
}
|
|
}
|
|
|
|
// we have to do the spawning here so we can transfer the mind to the correct entity and can assign the objectives correctly
|
|
private void OnAntagSelectEntity(Entity<ParadoxCloneRuleComponent> ent, ref AntagSelectEntityEvent args)
|
|
{
|
|
if (ent.Comp.OriginalBody != null) // target was overridden, for example by admin antag control
|
|
{
|
|
if (Deleted(ent.Comp.OriginalBody.Value) || !_mind.TryGetMind(ent.Comp.OriginalBody.Value, out var originalMindId, out var _))
|
|
{
|
|
Log.Warning("Could not find mind of target player to paradox clone!");
|
|
return;
|
|
}
|
|
ent.Comp.OriginalMind = originalMindId;
|
|
}
|
|
else
|
|
{
|
|
// get possible targets
|
|
var allAliveHumanoids = _target.GetMinds();
|
|
|
|
// we already checked when starting the gamerule, but someone might have died since then.
|
|
if (allAliveHumanoids.Count == 0)
|
|
{
|
|
Log.Warning("Could not find any alive players to create a paradox clone from!");
|
|
return;
|
|
}
|
|
|
|
// pick a random player
|
|
var randomHumanoidMind = _random.Pick(allAliveHumanoids);
|
|
ent.Comp.OriginalMind = randomHumanoidMind;
|
|
ent.Comp.OriginalBody = randomHumanoidMind.Comp.OwnedEntity;
|
|
|
|
}
|
|
|
|
if (ent.Comp.OriginalBody == null || !_cloning.TryCloning(ent.Comp.OriginalBody.Value, args.Coords, ent.Comp.Settings, out var clone))
|
|
{
|
|
Log.Error($"Unable to make a paradox clone of entity {ToPrettyString(ent.Comp.OriginalBody)}");
|
|
return;
|
|
}
|
|
|
|
var targetComp = EnsureComp<TargetOverrideComponent>(clone.Value);
|
|
targetComp.Target = ent.Comp.OriginalMind; // set the kill target
|
|
|
|
var gibComp = EnsureComp<GibOnRoundEndComponent>(clone.Value);
|
|
gibComp.SpawnProto = ent.Comp.GibProto;
|
|
gibComp.PreventGibbingObjectives = new() { "ParadoxCloneKillObjective" }; // don't gib them if they killed the original.
|
|
|
|
// turn their suit sensors off so they don't immediately get noticed
|
|
_sensor.SetAllSensors(clone.Value, SuitSensorMode.SensorOff);
|
|
|
|
args.Entity = clone;
|
|
}
|
|
|
|
private void AfterAntagEntitySelected(Entity<ParadoxCloneRuleComponent> ent, ref AfterAntagEntitySelectedEvent args)
|
|
{
|
|
if (ent.Comp.OriginalMind == null)
|
|
return;
|
|
|
|
if (!_mind.TryGetMind(args.EntityUid, out var cloneMindId, out var cloneMindComp))
|
|
return;
|
|
|
|
_mind.CopyObjectives(ent.Comp.OriginalMind.Value, (cloneMindId, cloneMindComp), ent.Comp.ObjectiveWhitelist, ent.Comp.ObjectiveBlacklist);
|
|
}
|
|
}
|