mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Finally gets around to porting over Changelings from Goobstation, as well as a *certain evil PR* from FunkyStation (with the fixes it comes with). --- # TODO <!-- A list of everything you have to do before this PR is "complete" You probably won't have to complete everything before merging but it's good to leave future references --> - [x] Wait for #1856 to be merged - [x] Wait for #1860 to be merged - [x] Fix broken code to make it actually compile (right now is just porting prototypes, code, and locale) - [X] Port That Funky PR I Mentioned Earlier - [] Throw bricks at the codebase until it stops failing tests - [X] Maybe do some local testing --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p>  </p> </details> --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - add: Changelings have been ported! --------- Signed-off-by: Eris <erisfiregamer1@gmail.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> (cherry picked from commit ee4f7aa7097f260d07af3ab0583a2a5c14a38c74)
70 lines
2.6 KiB
C#
70 lines
2.6 KiB
C#
using Content.Server.Objectives.Components;
|
|
using Content.Server.Shuttles.Systems;
|
|
using Content.Shared.Cuffs.Components;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Objectives.Components;
|
|
|
|
namespace Content.Server.Objectives.Systems;
|
|
|
|
/// <summary>
|
|
/// Handles escaping on the shuttle while being another person detection.
|
|
/// </summary>
|
|
public sealed class ImpersonateConditionSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly TargetObjectiveSystem _target = default!;
|
|
[Dependency] private readonly EmergencyShuttleSystem _emergencyShuttle = default!;
|
|
[Dependency] private readonly SharedMindSystem _mind = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ImpersonateConditionComponent, ObjectiveAfterAssignEvent>(OnAfterAssign);
|
|
SubscribeLocalEvent<ImpersonateConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
|
|
}
|
|
|
|
public override void Update(float frameTime)
|
|
{
|
|
base.Update(frameTime);
|
|
|
|
var query = EntityQueryEnumerator<ImpersonateConditionComponent>();
|
|
while (query.MoveNext(out var _, out var comp))
|
|
{
|
|
if (comp.Name == null || comp.MindId == null
|
|
|| !TryComp<MindComponent>(comp.MindId, out var mind) || mind.OwnedEntity == null
|
|
|| !TryComp<MetaDataComponent>(mind.CurrentEntity, out var metaData))
|
|
continue;
|
|
|
|
comp.Completed = metaData.EntityName == comp.Name;
|
|
}
|
|
}
|
|
|
|
private void OnAfterAssign(EntityUid uid, ImpersonateConditionComponent comp, ref ObjectiveAfterAssignEvent args)
|
|
{
|
|
if (!_target.GetTarget(uid, out var target)
|
|
|| !TryComp<MindComponent>(target, out var targetMind) || targetMind.CharacterName == null)
|
|
return;
|
|
|
|
comp.Name = targetMind.CharacterName;
|
|
comp.MindId = args.MindId;
|
|
}
|
|
|
|
// copypasta from escape shittle objective. eh.
|
|
private void OnGetProgress(EntityUid uid, ImpersonateConditionComponent comp, ref ObjectiveGetProgressEvent args)
|
|
{
|
|
args.Progress = GetProgress(args.Mind, comp);
|
|
}
|
|
|
|
public float GetProgress(MindComponent mind, ImpersonateConditionComponent comp)
|
|
{
|
|
// not escaping alive if you're deleted/dead
|
|
if (mind.OwnedEntity == null || _mind.IsCharacterDeadIc(mind))
|
|
return 0f;
|
|
// You're not escaping if you're restrained!
|
|
if (TryComp<CuffableComponent>(mind.OwnedEntity, out var cuffed) && cuffed.CuffedHandCount > 0)
|
|
return 0f;
|
|
|
|
return (_emergencyShuttle.IsTargetEscaping(mind.OwnedEntity.Value) ? .5f : 0f) + (comp.Completed ? .5f : 0f);
|
|
}
|
|
}
|