private void OnDoorAutoCloseCheck(EntityUid uid, AirlockComponent component, BeforeDoorAutoCloseEvent args)
 {
     if (!component.AutoClose)
     {
         args.Cancel();
     }
 }
 private void OnBeforeDoorDenied(EntityUid uid, AirlockComponent component, BeforeDoorDeniedEvent args)
 {
     if (!component.CanChangeState())
     {
         args.Cancel();
     }
 }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
        public async Task AirlockBlockTest()
        {
            var server = StartServer();

            await server.WaitIdleAsync();

            var mapManager    = server.ResolveDependency <IMapManager>();
            var entityManager = server.ResolveDependency <IEntityManager>();

            IEntity          human            = null;
            IEntity          airlock          = null;
            TestController   controller       = null;
            AirlockComponent airlockComponent = null;

            var humanStartingX = -1;

            server.Assert(() =>
            {
                var mapId = new MapId(1);
                mapManager.CreateNewMapEntity(mapId);

                var humanCoordinates = new MapCoordinates((humanStartingX, 0), mapId);
                human = entityManager.SpawnEntity("HumanMob_Content", humanCoordinates);

                airlock = entityManager.SpawnEntity("Airlock", new MapCoordinates((0, 0), mapId));

                Assert.True(human.TryGetComponent(out IPhysicsComponent physics));

                controller = physics.EnsureController <TestController>();

                Assert.True(airlock.TryGetComponent(out airlockComponent));
                Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Closed));
            });

            await server.WaitIdleAsync();

            // Push the human towards the airlock
            controller.LinearVelocity = (0.5f, 0);

            for (var i = 0; i < 240; i += 10)
            {
                // Keep the airlock awake so they collide
                airlock.GetComponent <IPhysicsComponent>().WakeBody();

                // Ensure that it is still closed
                Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Closed));

                await server.WaitRunTicks(10);

                await server.WaitIdleAsync();
            }

            // Sanity check
            Assert.That(human.Transform.MapPosition.X, Is.GreaterThan(humanStartingX));

            // Blocked by the airlock
            Assert.That(human.Transform.MapPosition.X, Is.Negative.Or.Zero);
        }
Ejemplo n.º 5
0
        public async Task OpenCloseDestroyTest()
        {
            var server = StartServerDummyTicker();

            await server.WaitIdleAsync();

            var mapManager    = server.ResolveDependency <IMapManager>();
            var entityManager = server.ResolveDependency <IEntityManager>();

            IEntity          airlock          = null;
            AirlockComponent airlockComponent = null;

            server.Assert(() =>
            {
                mapManager.CreateNewMapEntity(MapId.Nullspace);

                airlock = entityManager.SpawnEntity("Airlock", MapCoordinates.Nullspace);

                Assert.True(airlock.TryGetComponent(out airlockComponent));
                Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Closed));
            });

            await server.WaitIdleAsync();

            server.Assert(() =>
            {
                airlockComponent.Open();
                Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Opening));
            });

            await server.WaitIdleAsync();

            await WaitUntil(server, () => airlockComponent.State == DoorState.Open);

            Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Open));

            server.Assert(() =>
            {
                airlockComponent.Close();
                Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Closing));
            });

            await WaitUntil(server, () => airlockComponent.State == DoorState.Closed);

            Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Closed));

            server.Assert(() =>
            {
                Assert.DoesNotThrow(() =>
                {
                    airlock.Delete();
                });
            });

            server.RunTicks(5);

            await server.WaitIdleAsync();
        }
 private void OnDoorClickShouldActivate(EntityUid uid, AirlockComponent component, DoorClickShouldActivateEvent args)
 {
     if (component.WiresComponent != null && component.WiresComponent.IsPanelOpen &&
         args.Args.User.TryGetComponent(out ActorComponent? actor))
     {
         component.WiresComponent.OpenInterface(actor.PlayerSession);
         args.Handled = true;
     }
 }
Ejemplo n.º 7
0
 private void OnDoorClickShouldActivate(EntityUid uid, AirlockComponent component, DoorClickShouldActivateEvent args)
 {
     if (TryComp <WiresComponent>(uid, out var wiresComponent) && wiresComponent.IsPanelOpen &&
         EntityManager.TryGetComponent(args.Args.User, out ActorComponent? actor))
     {
         wiresComponent.OpenInterface(actor.PlayerSession);
         args.Handled = true;
     }
 }
 private void OnActivate(EntityUid uid, AirlockComponent component, ActivateInWorldEvent args)
 {
     if (TryComp <WiresComponent>(uid, out var wiresComponent) && wiresComponent.IsPanelOpen &&
         EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
     {
         _wiresSystem.OpenUserInterface(uid, actor.PlayerSession);
         args.Handled = true;
     }
 }
        private void OnPowerChanged(EntityUid uid, AirlockComponent component, PowerChangedEvent args)
        {
            if (component.AppearanceComponent != null)
            {
                component.AppearanceComponent.SetData(DoorVisuals.Powered, args.Powered);
            }

            // BoltLights also got out
            component.UpdateBoltLightStatus();
        }
 private void OnStateChanged(EntityUid uid, AirlockComponent component, DoorStateChangedEvent args)
 {
     // Only show the maintenance panel if the airlock is closed
     if (component.WiresComponent != null)
     {
         component.WiresComponent.IsPanelVisible =
             component.OpenPanelVisible ||
             args.State != SharedDoorComponent.DoorState.Open;
     }
     // If the door is closed, we should look if the bolt was locked while closing
     component.UpdateBoltLightStatus();
 }
 private void OnDoorPry(EntityUid uid, AirlockComponent component, BeforeDoorPryEvent args)
 {
     if (component.IsBolted())
     {
         component.Owner.PopupMessage(args.Args.User, Loc.GetString("airlock-component-cannot-pry-is-bolted-message"));
         args.Cancel();
     }
     if (component.IsPowered())
     {
         component.Owner.PopupMessage(args.Args.User, Loc.GetString("airlock-component-cannot-pry-is-powered-message"));
         args.Cancel();
     }
 }
Ejemplo n.º 12
0
        private void OnStateChanged(EntityUid uid, AirlockComponent component, DoorStateChangedEvent args)
        {
            // TODO move to shared? having this be server-side, but having client-side door opening/closing & prediction
            // means that sometimes the panels & bolt lights may be visible despite a door being completely open.

            // Only show the maintenance panel if the airlock is closed
            if (TryComp <WiresComponent>(uid, out var wiresComponent))
            {
                wiresComponent.IsPanelVisible =
                    component.OpenPanelVisible ||
                    args.State != DoorState.Open;
            }
            // If the door is closed, we should look if the bolt was locked while closing
            component.UpdateBoltLightStatus();

            UpdateAutoClose(uid, component);
        }
 private void OnDoorCloseTimeModifier(EntityUid uid, AirlockComponent component, DoorGetCloseTimeModifierEvent args)
 {
     args.CloseTimeModifier *= component.AutoCloseDelayModifier;
 }
 private void OnDoorSafetyCheck(EntityUid uid, AirlockComponent component, DoorSafetyEnabledEvent args)
 {
     args.Safety = component.Safety;
 }