Example #1
0
        private void InteractDoor(Vector3 currentPosition, Vector3 direction)
        {
            // Make sure there is a door controller
            Vector3Int position = Vector3Int.RoundToInt(currentPosition + direction);

            DoorController doorController = matrix.GetFirst <DoorController>(position);

            if (!doorController)
            {
                doorController = matrix.GetFirst <DoorController>(Vector3Int.RoundToInt(currentPosition));

                if (doorController)
                {
                    RegisterDoor registerDoor = doorController.GetComponent <RegisterDoor>();
                    if (registerDoor.IsPassable(position))
                    {
                        doorController = null;
                    }
                }
            }

            // Attempt to open door
            if (doorController != null && allowInput)
            {
                pna.CmdCheckDoorPermissions(doorController.gameObject, gameObject);

                allowInput = false;
                StartCoroutine(DoorInputCoolDown());
            }
        }
Example #2
0
        /// Cross-matrix now! uses world positions
        private void InteractDoor(Vector3Int currentPos, Vector3Int targetPos)
        {
            // Make sure there is a door controller
            DoorController doorController = MatrixManager.Instance.GetFirst <DoorController>(targetPos);

            if (!doorController)
            {
                doorController = MatrixManager.Instance.GetFirst <DoorController>(Vector3Int.RoundToInt(currentPos));

                if (doorController)
                {
                    RegisterDoor registerDoor = doorController.GetComponent <RegisterDoor>();

                    Vector3Int localPos = MatrixManager.Instance.WorldToLocalInt(targetPos, matrix);
                    if (registerDoor.IsPassable(localPos))
                    {
                        doorController = null;
                    }
                }
            }

            // Attempt to open door
            if (doorController != null && allowInput)
            {
                pna.CmdCheckDoorPermissions(doorController.gameObject, gameObject);

                allowInput = false;
                StartCoroutine(DoorInputCoolDown());
            }
        }
Example #3
0
        /// Cross-matrix now! uses world positions
        private void InteractDoor(Vector3Int currentPos, Vector3Int targetPos)
        {
            // Make sure there is a door controller
            DoorTrigger door = MatrixManager.Instance.GetFirst <DoorTrigger>(targetPos);

            if (!door)
            {
                door = MatrixManager.Instance.GetFirst <DoorTrigger>(Vector3Int.RoundToInt(currentPos));

                if (door)
                {
                    RegisterDoor registerDoor = door.GetComponent <RegisterDoor>();

                    Vector3Int localPos = MatrixManager.Instance.WorldToLocalInt(targetPos, matrix);
                    if (registerDoor.IsPassable(localPos))
                    {
                        door = null;
                    }
                }
            }

            // Attempt to open door
            if (door != null && allowInput)
            {
                door.Interact(gameObject, TransformState.HiddenPos);
            }
        }
Example #4
0
        private void InteractDoor(Vector3 currentPosition, Vector3 direction)
        {
            Vector3Int position = Vector3Int.RoundToInt(currentPosition + direction);

            DoorController doorController = matrix.GetFirst <DoorController>(position);

            if (!doorController)
            {
                doorController = matrix.GetFirst <DoorController>(Vector3Int.RoundToInt(currentPosition));

                if (doorController)
                {
                    RegisterDoor registerDoor = doorController.GetComponent <RegisterDoor>();
                    if (registerDoor.IsPassable(position))
                    {
                        doorController = null;
                    }
                }
            }

            if (doorController != null && allowInput)
            {
                //checking if the door actually has a restriction (only need one because that's how ss13 works!
                if (doorController.restriction > 0)
                {
                    //checking if the ID slot on player contains an ID with an itemIdentity component
                    if (UIManager.InventorySlots.IDSlot.IsFull &&
                        UIManager.InventorySlots.IDSlot.Item.GetComponent <IDCard>() != null)
                    {
                        //checking if the ID has access to bypass the restriction
                        CheckDoorAccess(UIManager.InventorySlots.IDSlot.Item.GetComponent <IDCard>(), doorController);
                        //Check the current hand for an ID
                    }
                    else if (UIManager.Hands.CurrentSlot.IsFull &&
                             UIManager.Hands.CurrentSlot.Item.GetComponent <IDCard>() != null)
                    {
                        CheckDoorAccess(UIManager.Hands.CurrentSlot.Item.GetComponent <IDCard>(), doorController);
                    }
                    else
                    {
                        //does not have an ID
                        allowInput = false;
                        StartCoroutine(DoorInputCoolDown());
                        if (CustomNetworkManager.Instance._isServer)
                        {
                            doorController.CmdTryDenied();
                        }
                    }
                }
                else
                {
                    //door does not have restriction
                    allowInput = false;
                    //Server only here but it is a cmd for the input trigger (opening with mouse click from client)
                    if (CustomNetworkManager.Instance._isServer)
                    {
                        doorController.CmdTryOpen(gameObject);
                    }

                    StartCoroutine(DoorInputCoolDown());
                }
            }
        }