mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 14:07:53 +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.
69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
using Content.Shared.Stealth;
|
|
using Content.Shared.Stealth.Components;
|
|
using Robust.Shared.Physics.Events;
|
|
using Robust.Shared.Physics.Systems;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Server.Psionics
|
|
{
|
|
/// <summary>
|
|
/// Allows an entity to become psionically invisible when touching certain entities.
|
|
/// </summary>
|
|
public sealed class PsionicInvisibleContactsSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedStealthSystem _stealth = default!;
|
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<PsionicInvisibleContactsComponent, StartCollideEvent>(OnEntityEnter);
|
|
SubscribeLocalEvent<PsionicInvisibleContactsComponent, EndCollideEvent>(OnEntityExit);
|
|
|
|
UpdatesAfter.Add(typeof(SharedPhysicsSystem));
|
|
}
|
|
|
|
private void OnEntityEnter(EntityUid uid, PsionicInvisibleContactsComponent component, ref StartCollideEvent args)
|
|
{
|
|
var otherUid = args.OtherEntity;
|
|
var ourEntity = args.OurEntity;
|
|
|
|
if (!component.Whitelist.IsValid(otherUid))
|
|
return;
|
|
|
|
// This will go up twice per web hit, since webs also have a flammable fixture.
|
|
// It goes down twice per web exit, so everything's fine.
|
|
++component.Stages;
|
|
|
|
if (HasComp<PsionicallyInvisibleComponent>(ourEntity))
|
|
return;
|
|
|
|
EnsureComp<PsionicallyInvisibleComponent>(ourEntity);
|
|
var stealth = EnsureComp<StealthComponent>(ourEntity);
|
|
_stealth.SetVisibility(ourEntity, 0.66f, stealth);
|
|
}
|
|
|
|
private void OnEntityExit(EntityUid uid, PsionicInvisibleContactsComponent component, ref EndCollideEvent args)
|
|
{
|
|
var otherUid = args.OtherEntity;
|
|
var ourEntity = args.OurEntity;
|
|
|
|
if (!component.Whitelist.IsValid(otherUid))
|
|
return;
|
|
|
|
if (!HasComp<PsionicallyInvisibleComponent>(ourEntity))
|
|
return;
|
|
|
|
if (--component.Stages > 0)
|
|
return;
|
|
|
|
RemComp<PsionicallyInvisibleComponent>(ourEntity);
|
|
var stealth = EnsureComp<StealthComponent>(ourEntity);
|
|
// Just to be sure...
|
|
_stealth.SetVisibility(ourEntity, 1f, stealth);
|
|
|
|
RemComp<StealthComponent>(ourEntity);
|
|
}
|
|
}
|
|
}
|