Example #1
0
    //! Searches for items in all containers connected to the computer.
    public void SearchComputerContainers(StorageComputer computer, string term)
    {
        int containerCount = 0;

        foreach (InventoryManager manager in computer.computerContainers)
        {
            foreach (InventorySlot slot in manager.inventory)
            {
                if (term.Length < slot.typeInSlot.Length)
                {
                    if (slot.typeInSlot.Substring(0, term.Length).ToLower().Equals(term.ToLower()))
                    {
                        playerController.storageComputerInventory = containerCount;
                        playerController.storageInventory         = computer.computerContainers[playerController.storageComputerInventory];
                    }
                }
                else if (term.Length > slot.typeInSlot.Length)
                {
                    if (slot.typeInSlot.ToLower().Equals(term.Substring(0, slot.typeInSlot.Length).ToLower()))
                    {
                        playerController.storageComputerInventory = containerCount;
                        playerController.storageInventory         = computer.computerContainers[playerController.storageComputerInventory];
                    }
                }
                else if (term.Length == slot.typeInSlot.Length)
                {
                    if (slot.typeInSlot.ToLower().Equals(term.ToLower()))
                    {
                        playerController.storageComputerInventory = containerCount;
                        playerController.storageInventory         = computer.computerContainers[playerController.storageComputerInventory];
                    }
                }
            }
            containerCount++;
        }
    }
Example #2
0
    //! Called when the player is looking at a storage computer.
    public void InteractWithStorageComputer()
    {
        playerController.machineGUIopen = false;
        playerController.machineInSight = playerController.objectInSight;
        StorageComputer computer = playerController.objectInSight.GetComponent <StorageComputer>();

        playerController.machineID       = computer.ID;
        playerController.machineHasPower = computer.powerON;
        if (cInput.GetKeyDown("Interact"))
        {
            if (PlayerPrefsX.GetPersistentBool("multiplayer") == true)
            {
                if (!interactionController.CanInteract())
                {
                    return;
                }
            }
            if (playerController.storageGUIopen == false)
            {
                if (computer.powerON == true && computer.initialized == true)
                {
                    bool foundContainer = false;
                    int  containerCount = 0;
                    foreach (InventoryManager manager in computer.computerContainers)
                    {
                        if (foundContainer == false)
                        {
                            if (computer.computerContainers[containerCount] != null)
                            {
                                Cursor.visible   = true;
                                Cursor.lockState = CursorLockMode.None;
                                playerController.storageGUIopen         = true;
                                playerController.craftingGUIopen        = false;
                                playerController.machineGUIopen         = false;
                                playerController.inventoryOpen          = true;
                                playerController.storageInventory       = computer.computerContainers[0];
                                playerController.currentStorageComputer = playerController.objectInSight;
                                playerController.remoteStorageActive    = true;
                                foundContainer = true;
                            }
                            containerCount++;
                        }
                    }
                    if (foundContainer == false)
                    {
                        computer.Reboot();
                    }
                }
            }
            else
            {
                Cursor.visible   = false;
                Cursor.lockState = CursorLockMode.Locked;
                playerController.inventoryOpen   = false;
                playerController.craftingGUIopen = false;
                playerController.machineGUIopen  = false;
                playerController.storageGUIopen  = false;
            }
        }
        if (cInput.GetKeyDown("Collect Object"))
        {
            interactionController.CollectObject("Storage Computer");
        }
    }