* mangleness adjustment * stable * empty fix * перебаламс * Обнова описаний * stable * Голо работабт как надо * fix * Fix fax * Update medicine.yml * Update blood_magic.yml * Update humanoid.yml * Update medicine.yml * Update ghost_roles.yml * Update mechs.yml * Update toxins.yml * Fish comments * F * Update hypospray.yml * Update hypospray.yml * Update hypospray.yml * фикс мозгов * истощение!!! * Обнова наборов медиков ОБР и ЯО * Частичный откат фикса факса * ФИКСЫ ПНТ * Ещё один нерф культа плоти? В этой экономике? А вообще исправлен баг бесконечных мясников * Автокрио вернулось на 15 минут, минимум для мажоров опущен до 35 игроков * Истощение теперь живёт у санрайза * Не работают комменты там * Возвращаем бугурт комментов + требование 100 часов СБ на ЭС * фикс линтера * Update hypospray.ftl * Update hypospray.yml * Считать не умею, фикс боевого медипена
74 lines
2.9 KiB
C#
74 lines
2.9 KiB
C#
using Content.Shared.Access.Systems;
|
|
using Content.Shared.DoAfter;
|
|
using Content.Shared.Doors.Components;
|
|
using Content.Shared.Doors.Systems;
|
|
using Content.Shared.Interaction;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Content.Shared._Fish.DelayedOpen;
|
|
|
|
public sealed class DelayedOpenSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
|
[Dependency] private readonly SharedDoorSystem _door = default!;
|
|
[Dependency] private readonly AccessReaderSystem _access = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<DelayedOpenComponent, ActivateInWorldEvent>(OnActivate);
|
|
SubscribeLocalEvent<DelayedOpenComponent, DelayedOpenDoAfterEvent>(OnDoAfter);
|
|
}
|
|
|
|
private void OnActivate(EntityUid uid, DelayedOpenComponent component, ActivateInWorldEvent args)
|
|
{
|
|
if (args.Handled || !component.Enabled)
|
|
return;
|
|
|
|
// If door is already open, do nothing or let default logic handle closing?
|
|
// User said "before door begins to open".
|
|
if (TryComp<DoorComponent>(uid, out var door) && door.State != DoorState.Closed && door.State != DoorState.Welded)
|
|
return; // Already open or opening
|
|
|
|
// Check Access
|
|
if (!_access.IsAllowed(args.User, uid))
|
|
return; // Let default access reader handle deny sound? Or should we handled it?
|
|
// Airlock system usually handles deny. If we don't set Handled = true, airlock might try to open and fail or play deny.
|
|
// But we want to BLOCK the immediate open.
|
|
// If we set Handled = true, we stop typical Airlock interaction.
|
|
// If access fails, we probably should let Airlock system play the deny sound.
|
|
// But Airlock system checks access too.
|
|
// If we return here, Airlock system runs. It checks access. Fails. Plays sound. Good.
|
|
|
|
|
|
// If Access OK:
|
|
// We want to PREVENT AirlockSystem from opening it immediately.
|
|
// So we must handle the event.
|
|
if (_access.IsAllowed(args.User, uid))
|
|
{
|
|
args.Handled = true;
|
|
|
|
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, TimeSpan.FromSeconds(component.Delay), new DelayedOpenDoAfterEvent(), uid, target: uid, used: uid)
|
|
{
|
|
BreakOnMove = true,
|
|
BreakOnDamage = true,
|
|
NeedHand = false
|
|
});
|
|
}
|
|
}
|
|
|
|
private void OnDoAfter(EntityUid uid, DelayedOpenComponent component, DelayedOpenDoAfterEvent args)
|
|
{
|
|
if (args.Cancelled || args.Handled)
|
|
return;
|
|
|
|
if (args.Target is not { } target)
|
|
return;
|
|
|
|
if (_door.TryOpen(target))
|
|
args.Handled = true;
|
|
}
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
public sealed partial class DelayedOpenDoAfterEvent : SimpleDoAfterEvent { }
|