Files
wwdpublic/Content.Shared/Friends/Systems/PettableFriendSystem.cs
dootythefrooty 717f8404f0 Abductor Port (#2234)
<!--
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]?
-->

Ports the lone abductor and possibly(?) the duo abductors.

---

# 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] Figure out why abductors aren't spawning as the abductor race.
- [X] Make sure it's not a buggy mess.

---

<!--
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>

![image](https://github.com/user-attachments/assets/81292bde-ad96-4d08-a30e-87c9bc2df8aa)
</p>
</details>

---
# Credits
Thank to [Starlight ](https://discord.com/invite/wAyQKB78fH)for the
original version!
Darkrell, Rinary, and Landosaur made the funny little guys.

![image](https://github.com/user-attachments/assets/1c62afe9-7fb9-458e-bc61-5745ba3a2a6b)

# 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
-->

🆑 Darkrell, Rinary, Landosaur
- add: The Abductors are here to replace your organs. Gleep Glorp!

---------

Co-authored-by: gluesniffler <159397573+gluesniffler@users.noreply.github.com>
Co-authored-by: Solstice <solsticeofthewinter@gmail.com>
Co-authored-by: SX_7 <sn1.test.preria.2002@gmail.com>
Co-authored-by: Theodore Lukin <66275205+pheenty@users.noreply.github.com>
Co-authored-by: Piras314 <p1r4s@proton.me>
Co-authored-by: Ilya246 <57039557+ilya246@users.noreply.github.com>

(cherry picked from commit ea9f1526868289d20832989cb02f79c76c240918)
2025-04-19 01:45:58 +03:00

74 lines
2.7 KiB
C#

using Content.Shared.Chemistry.Components;
using Content.Shared.Friends.Components;
using Content.Shared.Interaction.Events;
using Content.Shared.NPC.Components;
using Content.Shared.NPC.Systems;
using Content.Shared.Popups;
using Content.Shared.Timing;
using Content.Shared._Shitmed.Spawners.EntitySystems; // Shitmed Change
namespace Content.Shared.Friends.Systems;
public sealed class PettableFriendSystem : EntitySystem
{
[Dependency] private readonly NpcFactionSystem _factionException = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!;
private EntityQuery<FactionExceptionComponent> _exceptionQuery;
private EntityQuery<UseDelayComponent> _useDelayQuery;
public override void Initialize()
{
base.Initialize();
_exceptionQuery = GetEntityQuery<FactionExceptionComponent>();
_useDelayQuery = GetEntityQuery<UseDelayComponent>();
SubscribeLocalEvent<PettableFriendComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<PettableFriendComponent, GotRehydratedEvent>(OnRehydrated);
SubscribeLocalEvent<PettableFriendComponent, SpawnerSpawnedEvent>(OnSpawned); // Shitmed Change
}
private void OnUseInHand(Entity<PettableFriendComponent> ent, ref UseInHandEvent args)
{
var (uid, comp) = ent;
var user = args.User;
if (args.Handled || !_exceptionQuery.TryGetComponent(uid, out var exceptionComp))
return;
if (_useDelayQuery.TryGetComponent(uid, out var useDelay) && !_useDelay.TryResetDelay((uid, useDelay), true))
return;
var exception = (uid, exceptionComp);
if (_factionException.IsIgnored(exception, user))
{
_popup.PopupClient(Loc.GetString(comp.FailureString, ("target", uid)), user, user);
return;
}
// you have made a new friend :)
_popup.PopupClient(Loc.GetString(comp.SuccessString, ("target", uid)), user, user);
_factionException.IgnoreEntity(exception, user);
args.Handled = true;
}
private void OnRehydrated(Entity<PettableFriendComponent> ent, ref GotRehydratedEvent args)
{
// can only pet before hydrating, after that the fish cannot be negotiated with
if (!TryComp<FactionExceptionComponent>(ent, out var comp))
return;
_factionException.IgnoreEntities(args.Target, comp.Ignored);
}
// Shitmed Change
private void OnSpawned(Entity<PettableFriendComponent> ent, ref SpawnerSpawnedEvent args)
{
if (!TryComp<FactionExceptionComponent>(ent, out var comp))
return;
_factionException.IgnoreEntities(args.Entity, comp.Ignored);
}
}