private void OnSignalReceived(EntityUid uid, DoorSignalControlComponent component, SignalReceivedEvent args) { if (!TryComp(uid, out DoorComponent? door)) { return; } if (args.Port == component.OpenPort) { if (door.State != DoorState.Open) { _doorSystem.TryOpen(uid, door); } } else if (args.Port == component.ClosePort) { if (door.State != DoorState.Closed) { _doorSystem.TryClose(uid, door); } } else if (args.Port == component.TogglePort) { _doorSystem.TryToggleDoor(uid, door); } }
private void OnBeforeInteract(EntityUid uid, DoorRemoteComponent component, BeforeRangedInteractEvent args) { if (args.Handled || args.Target == null || !TryComp <DoorComponent>(args.Target, out var doorComp) || // If it isn't a door we don't use it !TryComp <AirlockComponent>(args.Target, out var airlockComp) // Remotes only work on airlocks // The remote can be used anywhere the user can see the door. // This doesn't work that well, but I don't know of an alternative || !_interactionSystem.InRangeUnobstructed(args.User, args.Target.Value, SharedInteractionSystem.MaxRaycastRange, CollisionGroup.Opaque)) { return; } args.Handled = true; if (!this.IsPowered(args.Target.Value, EntityManager)) { ShowPopupToUser("door-remote-no-power", args.User); return; } if (TryComp <AccessReaderComponent>(args.Target, out var accessComponent) && !_doorSystem.HasAccess(doorComp.Owner, args.Used, accessComponent)) { _doorSystem.Deny(airlockComp.Owner, doorComp, args.User); ShowPopupToUser("door-remote-denied", args.User); return; } switch (component.Mode) { case OperatingMode.OpenClose: _doorSystem.TryToggleDoor(doorComp.Owner, doorComp, args.Used); break; case OperatingMode.ToggleBolts: //TODO: What about cut wires...? airlockComp.SetBoltsWithAudio(!airlockComp.IsBolted()); break; case OperatingMode.ToggleEmergencyAccess: _sharedAirlockSystem.ToggleEmergencyAccess(airlockComp); break; default: throw new InvalidOperationException( $"{nameof(DoorRemoteComponent)} had invalid mode {component.Mode}"); } }
private void HandleDoorTrigger(EntityUid uid, ToggleDoorOnTriggerComponent component, TriggerEvent args) { _sharedDoorSystem.TryToggleDoor(uid); }