mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 22:18:52 +03:00
# Description Due to some inherent limitations of maintenance, code review, and me having both severely crippling ADHD and a lifelong adderal dependency, I've made the executive decision to break apart the Psionic Refactor into a multitude of smaller, bite sized PRs. I'm keeping the original Psionic Refactor PR open, because I'm going to need it for code reference to keep track of the changes I had originally worked on, but I need to essentially restart the entire refactor from scratch, and approach it from a new angle that's going to make everything actually way easier. I also need to be able to work on each available system individually wherever possible, and this fact is most readily shown by how the Lightning Refactor and Oracle Refactor were both done separately. To start off, this PR is ONLY moving all of the relevant psionics code to core folders, and nothing more. I'm doing this first so that I can immediately cut down massively on the "Files Changed" with the simplest, most basic change necessary to start my work. No changelog because this isn't player facing, and no media because there's literally nothing to show.
82 lines
3.4 KiB
C#
82 lines
3.4 KiB
C#
using Content.Shared.Inventory.Events;
|
|
using Content.Shared.Clothing.Components;
|
|
using Content.Shared.StatusEffect;
|
|
|
|
namespace Content.Shared.Abilities.Psionics
|
|
{
|
|
public sealed class PsionicItemsSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
|
|
[Dependency] private readonly IComponentFactory _componentFactory = default!;
|
|
[Dependency] private readonly SharedPsionicAbilitiesSystem _psiAbilities = default!;
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<TinfoilHatComponent, GotEquippedEvent>(OnTinfoilEquipped);
|
|
SubscribeLocalEvent<TinfoilHatComponent, GotUnequippedEvent>(OnTinfoilUnequipped);
|
|
SubscribeLocalEvent<ClothingGrantPsionicPowerComponent, GotEquippedEvent>(OnGranterEquipped);
|
|
SubscribeLocalEvent<ClothingGrantPsionicPowerComponent, GotUnequippedEvent>(OnGranterUnequipped);
|
|
}
|
|
private void OnTinfoilEquipped(EntityUid uid, TinfoilHatComponent component, GotEquippedEvent args)
|
|
{
|
|
// This only works on clothing
|
|
if (!TryComp<ClothingComponent>(uid, out var clothing))
|
|
return;
|
|
// Is the clothing in its actual slot?
|
|
if (!clothing.Slots.HasFlag(args.SlotFlags))
|
|
return;
|
|
|
|
var insul = EnsureComp<PsionicInsulationComponent>(args.Equipee);
|
|
insul.Passthrough = component.Passthrough;
|
|
component.IsActive = true;
|
|
_psiAbilities.SetPsionicsThroughEligibility(args.Equipee);
|
|
}
|
|
|
|
private void OnTinfoilUnequipped(EntityUid uid, TinfoilHatComponent component, GotUnequippedEvent args)
|
|
{
|
|
if (!component.IsActive)
|
|
return;
|
|
|
|
if (!_statusEffects.HasStatusEffect(uid, "PsionicallyInsulated"))
|
|
RemComp<PsionicInsulationComponent>(args.Equipee);
|
|
|
|
component.IsActive = false;
|
|
_psiAbilities.SetPsionicsThroughEligibility(args.Equipee);
|
|
}
|
|
|
|
private void OnGranterEquipped(EntityUid uid, ClothingGrantPsionicPowerComponent component, GotEquippedEvent args)
|
|
{
|
|
// This only works on clothing
|
|
if (!TryComp<ClothingComponent>(uid, out var clothing))
|
|
return;
|
|
// Is the clothing in its actual slot?
|
|
if (!clothing.Slots.HasFlag(args.SlotFlags))
|
|
return;
|
|
// does the user already has this power?
|
|
var componentType = _componentFactory.GetRegistration(component.Power).Type;
|
|
if (EntityManager.HasComponent(args.Equipee, componentType)) return;
|
|
|
|
|
|
var newComponent = (Component) _componentFactory.GetComponent(componentType);
|
|
newComponent.Owner = args.Equipee;
|
|
|
|
EntityManager.AddComponent(args.Equipee, newComponent);
|
|
|
|
component.IsActive = true;
|
|
}
|
|
|
|
private void OnGranterUnequipped(EntityUid uid, ClothingGrantPsionicPowerComponent component, GotUnequippedEvent args)
|
|
{
|
|
if (!component.IsActive)
|
|
return;
|
|
|
|
component.IsActive = false;
|
|
var componentType = _componentFactory.GetRegistration(component.Power).Type;
|
|
if (EntityManager.HasComponent(args.Equipee, componentType))
|
|
{
|
|
EntityManager.RemoveComponent(args.Equipee, componentType);
|
|
}
|
|
}
|
|
}
|
|
}
|