// Update is called once per frame
    void Update()
    {
        if (network == null)
        {
            network = GameObject.FindGameObjectWithTag("Player").GetComponent<spt_NetworkPuzzleLogic>();
            if (network != null)
            {
                indecies = new int[network.PuzzleStates.Count];
                weights = new double[network.PuzzleStates.Count];
                //network.Cmd_UpdatePuzzleLogic("extCordPlugged", true, "mdl_extCord");
            }
        }
        else
        {
            //network = GameObject.FindObjectOfType(typeof(spt_NetworkPuzzleLogic)) as spt_NetworkPuzzleLogic;
            //Debug.Log(network.loaded);
            if (loadedTheNetwork == false)
            {
                // Iterates through the puzzle logic communicator, gets all necessary data for item interaction (populates the above arrays)
                int j = 0;
                for (int i = 0; i < network.PuzzleStates.Count; i++)
                {
                    if (network.PuzzleStates[i].isMonsterInteractable)
                    {

                        indecies[j] = i;
                        weights[j] = 0.5;
                        j++;
                    }
                }

                InvokeRepeating("updateTime", 1, 1);
                loadedTheNetwork = true;
            }

            else if (loadedTheNetwork == true)
            {

                // If the monster is not in a downtime period...
                if ((currentTime - lastInteractionTime) > interactionDowntime)
                {

                    // Cycle through the possible interactable objects.
                    for (int i = 0; i < indecies.Length; i++)
                    {

                        // If the monster is within interaction range...
                        if (Vector3.Distance(new Vector3(GameObject.Find(network.PuzzleStates[indecies[i]].itemName).transform.position.x, 1, GameObject.Find(network.PuzzleStates[indecies[i]].itemName).transform.position.z), gameObject.transform.position) < 2 && checkIfInteractableYet(network.PuzzleStates[indecies[i]].itemName))
                        {

                            // Perform interaction some of the time, dependent on a random number.
                            float decision = Random.Range(0, 1);
                            if (decision < weights[i])
                            {
                                animationScript = GameObject.FindObjectOfType(typeof(spt_monsterAnimations)) as spt_monsterAnimations;
                                interactionName = network.PuzzleStates[indecies[i]].name;
                                interactionItemName = network.PuzzleStates[indecies[i]].itemName;
                                Debug.LogWarning("Interacting with: " + network.PuzzleStates[indecies[i]].itemName);
                                animationScript.interactWithObject(interactionItemName);
                                //interactWithObject(network.PuzzleStates[indecies[i]].name, network.PuzzleStates[indecies[i]].itemName);
                            }
                        }
                    }
                }
            }
        }
    }