Esempio n. 1
0
        /// <summary>
        /// Updates the auto close timer.
        /// </summary>
        public void UpdateAutoClose(EntityUid uid, AirlockComponent?airlock = null, DoorComponent?door = null)
        {
            if (!Resolve(uid, ref airlock, ref door))
            {
                return;
            }

            if (door.State != DoorState.Open)
            {
                return;
            }

            if (!airlock.CanChangeState())
            {
                return;
            }

            var autoev = new BeforeDoorAutoCloseEvent();

            RaiseLocalEvent(uid, autoev, false);
            if (autoev.Cancelled)
            {
                return;
            }

            DoorSystem.SetNextStateChange(uid, airlock.AutoCloseDelay * airlock.AutoCloseDelayModifier);
        }
Esempio n. 2
0
        private void OnPowerChanged(EntityUid uid, AirlockComponent component, PowerChangedEvent args)
        {
            if (TryComp <AppearanceComponent>(uid, out var appearanceComponent))
            {
                appearanceComponent.SetData(DoorVisuals.Powered, args.Powered);
            }

            if (!TryComp(uid, out DoorComponent? door))
            {
                return;
            }

            if (!args.Powered)
            {
                // stop any scheduled auto-closing
                if (door.State == DoorState.Open)
                {
                    DoorSystem.SetNextStateChange(uid, null);
                }
            }
            else
            {
                UpdateAutoClose(uid, door: door);
            }

            // BoltLights also got out
            component.UpdateBoltLightStatus();
        }