Files
wwdpublic/Content.Shared/Item/ItemToggle/ComponentTogglerSystem.cs
Eris d6f3265e83 MODsuits (Port From Goob #1242) (#1640)
# Description

Ports MODsuits from Goobstation PR
https://github.com/Goob-Station/Goob-Station/pull/1242. The PR author
has confirmed that he is okay with me doing this.

---

# TODO

- [X] Port in sprites
- [x] Port in YMLs
- [X] Port code
- [x] Port code PATCHES
- [x] Update EE with required fixes

---

<details><summary><h1>Media</h1></summary>
<p>

## Modsuit crafting

https://github.com/user-attachments/assets/8ff03d3a-0fc1-4818-b710-bfc43f0e2a68

## Modsuit sealing

https://github.com/user-attachments/assets/6671459a-7767-499b-8678-062fc1db7134

</p>
</details>

---

# Changelog

🆑
- add: Modsuits have been ported from Goobstation!

---------

Signed-off-by: Eris <erisfiregamer1@gmail.com>
Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>

(cherry picked from commit cb06c41fc07275e1f15af916babb44368c0c26c2)
2025-01-29 20:09:26 +03:00

36 lines
1.1 KiB
C#

using Content.Shared.Item.ItemToggle.Components;
namespace Content.Shared.Item.ItemToggle;
/// <summary>
/// Handles <see cref="ComponentTogglerComponent"/> component manipulation.
/// </summary>
public sealed class ComponentTogglerSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ComponentTogglerComponent, ItemToggledEvent>(OnToggled);
}
private void OnToggled(Entity<ComponentTogglerComponent> ent, ref ItemToggledEvent args)
{
ToggleComponent(ent, args.Activated);
}
// Goobstation - Make this system more flexible
public void ToggleComponent(EntityUid uid, bool activate)
{
if (!TryComp<ComponentTogglerComponent>(uid, out var component))
return;
var target = component.Parent ? Transform(uid).ParentUid : uid;
if (activate)
EntityManager.AddComponents(target, component.Components);
else
EntityManager.RemoveComponents(target, component.RemoveComponents ?? component.Components);
}
}