using Content.Server.Actions; using Content.Server.Stunnable; using Content.Shared._EE.Nightmare.Components; using Content.Shared._EE.Shadowling; using Content.Shared._EE.Shadowling.Components; using Content.Shared.Actions; using Content.Shared.Weapons.Reflect; using Content.Shared.WhiteDream.BloodCult.Constructs.PhaseShift; namespace Content.Server._EE.Nightmare.Systems; /// /// This handles nightmare logic /// public sealed class NightmareSystem : EntitySystem { [Dependency] private readonly ActionsSystem _actionsSystem = default!; [Dependency] private readonly StunSystem _stunSystem = default!; /// public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnComponentStartup); } public override void Update(float frameTime) { base.Update(frameTime); // Nightmares reflect shots while in the dark var nightmare = EntityQueryEnumerator(); while (nightmare.MoveNext(out var uid, out var nightmareComponent)) { if (!TryComp(uid, out var lightDet)) continue; if (lightDet.IsOnLight && HasComp(uid)) { RemComp(uid); _stunSystem.TryKnockdown(uid, TimeSpan.FromSeconds(3), false); _actionsSystem.SetCooldown(nightmareComponent.ActionPlaneShiftEntity, TimeSpan.FromSeconds(3)); } if (!TryComp(uid, out var reflect)) continue; if (lightDet.IsOnLight) { reflect.ReflectProb = 0f; } else { reflect.ReflectProb = 1f; } } } private void OnComponentStartup(EntityUid uid, NightmareComponent component, ComponentStartup args) { if (!TryComp(uid, out var actions)) return; if (TryComp(uid, out var lesser)) { _actionsSystem.RemoveAction(uid, lesser.ShadowWalkActionId); } if (TryComp(uid, out var thrall) && !HasComp(uid)) { _actionsSystem.RemoveAction(uid, thrall.ActionGuiseEntity); _actionsSystem.RemoveAction(uid, thrall.ActionThrallDarksightEntity); } // Shadowling Checks - END EnsureComp(uid); EnsureComp(uid); EnsureComp(uid); EnsureComp(uid); EnsureComp(uid); _actionsSystem.AddAction(uid, ref component.ActionLightEntity, component.ActionLightEater, component: actions); _actionsSystem.AddAction(uid, ref component.ActionPlaneShiftEntity, component.ActionPlaneShift, component: actions); } }