using System; using UnityEngine; public class InteractionController : MonoBehaviour { private PlayerController playerController; void Start() { playerController = GetComponent(); } void Update() { //RAYCAST AND ASSOCIATED DATA FOR INTERACTING WITH MACHINES AND OTHER OBJECTS if (Physics.Raycast(Camera.main.gameObject.transform.position, Camera.main.gameObject.transform.forward, out playerController.playerLookHit, 40) && playerController.inventoryOpen == false && playerController.escapeMenuOpen == false && playerController.tabletOpen == false) { playerController.objectInSight = playerController.playerLookHit.collider.gameObject; if (playerController.objectInSight.GetComponent() != null) { //Display info. } else if (playerController.objectInSight.GetComponent() != null) { //Display info. } else if (playerController.objectInSight.GetComponent() != null) { //Display info. } else if (playerController.objectInSight.GetComponent() != null && playerController.objectInSight.GetComponent() == null && playerController.objectInSight.GetComponent() == null) { if (cInput.GetKeyDown("Interact")) { if (playerController.storageGUIopen == false) { if (playerController.building == true) { if (GameObject.Find("GameManager").GetComponent().working == false) { playerController.stoppingBuildCoRoutine = true; GameObject.Find("GameManager").GetComponent().CombineBlocks(); playerController.separatedBlocks = false; playerController.destroyTimer = 0; playerController.buildTimer = 0; playerController.building = false; playerController.destroying = false; } else { playerController.requestedBuildingStop = true; } } if (playerController.objectInSight.GetComponent().initialized == true) { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; playerController.storageGUIopen = true; playerController.craftingGUIopen = false; playerController.machineGUIopen = false; playerController.inventoryOpen = true; playerController.storageInventory = playerController.objectInSight.GetComponent(); playerController.remoteStorageActive = false; } } 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") && playerController.objectInSight.GetComponent().ID != "Rocket" && playerController.objectInSight.GetComponent().ID != "Lander") { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Storage Container") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { InventoryManager thisContainer = playerController.objectInSight.GetComponent(); foreach (InventorySlot slot in thisContainer.inventory) { slot.typeInSlot = "nothing"; slot.amountInSlot = 0; } thisContainer.SaveData(); if (playerController.objectInSight.GetComponent() != null) { playerController.playerInventory.AddItem("Rail Cart", 1); } else { playerController.playerInventory.AddItem("Storage Container", 1); } Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; if (cInput.GetKeyDown("Interact")) { if (playerController.storageGUIopen == false) { if (playerController.building == true) { if (GameObject.Find("GameManager").GetComponent().working == false) { playerController.stoppingBuildCoRoutine = true; GameObject.Find("GameManager").GetComponent().CombineBlocks(); playerController.separatedBlocks = false; playerController.destroyTimer = 0; playerController.buildTimer = 0; playerController.building = false; playerController.destroying = false; } else { playerController.requestedBuildingStop = true; } } if (playerController.objectInSight.GetComponent().powerON == true && playerController.objectInSight.GetComponent().initialized == true) { bool foundContainer = false; int containerCount = 0; foreach (InventoryManager manager in playerController.objectInSight.GetComponent().computerContainers) { if (foundContainer == false) { if (playerController.objectInSight.GetComponent().computerContainers[containerCount] != null) { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; playerController.storageGUIopen = true; playerController.craftingGUIopen = false; playerController.machineGUIopen = false; playerController.inventoryOpen = true; playerController.storageInventory = playerController.objectInSight.GetComponent().computerContainers[0]; playerController.currentStorageComputer = playerController.objectInSight; playerController.remoteStorageActive = true; foundContainer = true; } containerCount++; } } } } 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")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Storage Computer") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Storage Computer", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineOutputID = playerController.objectInSight.GetComponent().outputID; if (playerController.objectInSight.GetComponent().type.Equals("Solar Panel")) { if (playerController.objectInSight.GetComponent().blocked == false) { playerController.machinePower = 1; } else { playerController.machinePower = 0; } } else if (playerController.objectInSight.GetComponent().type.Equals("Generator")) { playerController.machineAmount = playerController.objectInSight.GetComponent().fuelAmount; playerController.machineType = playerController.objectInSight.GetComponent().fuelType; if (playerController.objectInSight.GetComponent().outOfFuel == false) { playerController.machinePower = 10; } else { playerController.machinePower = 0; } } else if (playerController.objectInSight.GetComponent().type.Equals("Reactor Turbine")) { if (playerController.objectInSight.GetComponent().noReactor == false) { playerController.machinePower = 100; } else { playerController.machinePower = 0; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals(playerController.objectInSight.GetComponent().type) && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { if (playerController.objectInSight.GetComponent().type.Equals("Solar Panel")) { playerController.playerInventory.AddItem("Solar Panel", 1); } else if (playerController.objectInSight.GetComponent().type.Equals("Generator")) { playerController.playerInventory.AddItem("Generator", 1); } else if (playerController.objectInSight.GetComponent().type.Equals("Reactor Turbine")) { playerController.playerInventory.AddItem("Reactor Turbine", 1); } Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { if (playerController.building == true) { if (GameObject.Find("GameManager").GetComponent().working == false) { playerController.stoppingBuildCoRoutine = true; GameObject.Find("GameManager").GetComponent().CombineBlocks(); playerController.separatedBlocks = false; playerController.destroyTimer = 0; playerController.buildTimer = 0; playerController.building = false; playerController.destroying = false; } else { playerController.requestedBuildingStop = true; } } Cursor.visible = true; Cursor.lockState = CursorLockMode.None; playerController.storageGUIopen = false; playerController.craftingGUIopen = false; playerController.inventoryOpen = false; playerController.machineGUIopen = true; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; playerController.inventoryOpen = false; playerController.craftingGUIopen = false; playerController.storageGUIopen = false; playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Nuclear Reactor") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Nuclear Reactor", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineOutputID = playerController.objectInSight.GetComponent().outputID1; playerController.machineOutputID2 = playerController.objectInSight.GetComponent().outputID2; playerController.machinePower = playerController.objectInSight.GetComponent().powerAmount; playerController.machineRange = playerController.objectInSight.GetComponent().range; if (playerController.machineRange < 10) { playerController.machineRange = 10; } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Power Conduit") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Power Conduit", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { if (playerController.building == true) { if (GameObject.Find("GameManager").GetComponent().working == false) { playerController.stoppingBuildCoRoutine = true; GameObject.Find("GameManager").GetComponent().CombineBlocks(); playerController.separatedBlocks = false; playerController.destroyTimer = 0; playerController.buildTimer = 0; playerController.building = false; playerController.destroying = false; } else { playerController.requestedBuildingStop = true; } } Cursor.visible = true; Cursor.lockState = CursorLockMode.None; playerController.storageGUIopen = false; playerController.craftingGUIopen = false; playerController.inventoryOpen = false; playerController.machineGUIopen = true; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; playerController.inventoryOpen = false; playerController.craftingGUIopen = false; playerController.storageGUIopen = false; playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Turret") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Turret", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { if (playerController.building == true) { if (GameObject.Find("GameManager").GetComponent().working == false) { playerController.stoppingBuildCoRoutine = true; GameObject.Find("GameManager").GetComponent().CombineBlocks(); playerController.separatedBlocks = false; playerController.destroyTimer = 0; playerController.buildTimer = 0; playerController.building = false; playerController.destroying = false; } else { playerController.requestedBuildingStop = true; } } Cursor.visible = true; Cursor.lockState = CursorLockMode.None; playerController.storageGUIopen = false; playerController.craftingGUIopen = false; playerController.inventoryOpen = false; playerController.machineGUIopen = true; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; playerController.inventoryOpen = false; playerController.craftingGUIopen = false; playerController.storageGUIopen = false; playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.collectorAmount = playerController.objectInSight.GetComponent().amount; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; playerController.machineType = playerController.objectInSight.GetComponent().type; if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Universal Extractor") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Universal Extractor", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { if (playerController.building == true) { if (GameObject.Find("GameManager").GetComponent().working == false) { playerController.stoppingBuildCoRoutine = true; GameObject.Find("GameManager").GetComponent().CombineBlocks(); playerController.separatedBlocks = false; playerController.destroyTimer = 0; playerController.buildTimer = 0; playerController.building = false; playerController.destroying = false; } else { playerController.requestedBuildingStop = true; } } Cursor.visible = true; Cursor.lockState = CursorLockMode.None; playerController.storageGUIopen = false; playerController.craftingGUIopen = false; playerController.inventoryOpen = false; playerController.machineGUIopen = true; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; playerController.inventoryOpen = false; playerController.craftingGUIopen = false; playerController.storageGUIopen = false; playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.collectorAmount = playerController.objectInSight.GetComponent().amount; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Auger") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Auger", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { if (playerController.building == true) { if (GameObject.Find("GameManager").GetComponent().working == false) { playerController.stoppingBuildCoRoutine = true; GameObject.Find("GameManager").GetComponent().CombineBlocks(); playerController.separatedBlocks = false; playerController.destroyTimer = 0; playerController.buildTimer = 0; playerController.building = false; playerController.destroying = false; } else { playerController.requestedBuildingStop = true; } } Cursor.visible = true; Cursor.lockState = CursorLockMode.None; playerController.storageGUIopen = false; playerController.craftingGUIopen = false; playerController.inventoryOpen = false; playerController.machineGUIopen = true; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; playerController.inventoryOpen = false; playerController.craftingGUIopen = false; playerController.storageGUIopen = false; playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.collectorAmount = playerController.objectInSight.GetComponent().darkMatterAmount; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Dark Matter Collector") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Dark Matter Collector", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { playerController.machineGUIopen = true; } else { playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineAmount = playerController.objectInSight.GetComponent().amount; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineType = playerController.objectInSight.GetComponent().type; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineRange = playerController.objectInSight.GetComponent().range; if (playerController.machineRange < 10) { playerController.machineRange = 10; } if (playerController.objectInSight.GetComponent().inputObject != null) { if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().type; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().type; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = "Regolith"; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().outputType; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().outputType; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().outputType; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().outputType; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().currentType; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().type; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().outputType; } } if (playerController.objectInSight.GetComponent().outputObject != null) { if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().type; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().inputType; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().inputType; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().inputType; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().inputType; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().inputType; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; if (playerController.objectInSight.GetComponent().type.Equals(playerController.objectInSight.GetComponent().outputObject.GetComponent().inputType1)) { playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().inputType1; } else if (playerController.objectInSight.GetComponent().type.Equals(playerController.objectInSight.GetComponent().outputObject.GetComponent().inputType2)) { playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().inputType2; } } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; int storageTotal = 0; foreach (InventorySlot slot in playerController.objectInSight.GetComponent().outputObject.GetComponent().inventory) { if (slot.typeInSlot.Equals(playerController.objectInSight.GetComponent().type)) { storageTotal += slot.amountInSlot; playerController.machineOutputType = slot.typeInSlot; } } playerController.machineOutputAmount = storageTotal; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; int storageTotal = 0; foreach (InventoryManager manager in playerController.objectInSight.GetComponent().outputObject.GetComponent().computerContainers) { foreach (InventorySlot slot in manager.inventory) { if (slot.typeInSlot.Equals(playerController.objectInSight.GetComponent().type)) { storageTotal += slot.amountInSlot; playerController.machineOutputType = slot.typeInSlot; } } } playerController.machineOutputAmount = storageTotal; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Universal Conduit") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Universal Conduit", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { if (playerController.building == true) { if (GameObject.Find("GameManager").GetComponent().working == false) { playerController.stoppingBuildCoRoutine = true; GameObject.Find("GameManager").GetComponent().CombineBlocks(); playerController.separatedBlocks = false; playerController.destroyTimer = 0; playerController.buildTimer = 0; playerController.building = false; playerController.destroying = false; } else { playerController.requestedBuildingStop = true; } } Cursor.visible = true; Cursor.lockState = CursorLockMode.None; playerController.storageGUIopen = false; playerController.craftingGUIopen = false; playerController.inventoryOpen = false; playerController.machineGUIopen = true; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; playerController.inventoryOpen = false; playerController.craftingGUIopen = false; playerController.storageGUIopen = false; playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineAmount = playerController.objectInSight.GetComponent().darkMatterAmount; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineRange = playerController.objectInSight.GetComponent().range; if (playerController.machineRange < 10) { playerController.machineRange = 10; } if (playerController.objectInSight.GetComponent().inputObject != null) { if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().darkMatterAmount; playerController.machineInputType = "Dark Matter"; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().darkMatterAmount; playerController.machineInputType = "Dark Matter"; } } if (playerController.objectInSight.GetComponent().outputObject != null) { if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().darkMatterAmount; playerController.machineOutputType = "Dark Matter"; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; int storageTotal = 0; foreach (InventoryManager manager in playerController.objectInSight.GetComponent().outputObject.GetComponent().computerContainers) { foreach (InventorySlot slot in manager.inventory) { if (slot.typeInSlot.Equals("Dark Matter")) { storageTotal += slot.amountInSlot; playerController.machineOutputType = "Dark Matter"; } } } playerController.machineOutputAmount = storageTotal; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; int storageTotal = 0; foreach (InventorySlot slot in playerController.objectInSight.GetComponent().outputObject.GetComponent().inventory) { if (slot.typeInSlot.Equals("Dark Matter")) { storageTotal += slot.amountInSlot; playerController.machineOutputType = "Dark Matter"; } } playerController.machineOutputAmount = storageTotal; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Dark Matter Conduit") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Dark Matter Conduit", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { if (playerController.building == true) { if (GameObject.Find("GameManager").GetComponent().working == false) { playerController.stoppingBuildCoRoutine = true; GameObject.Find("GameManager").GetComponent().CombineBlocks(); playerController.separatedBlocks = false; playerController.destroyTimer = 0; playerController.buildTimer = 0; playerController.building = false; playerController.destroying = false; } else { playerController.requestedBuildingStop = true; } } Cursor.visible = true; Cursor.lockState = CursorLockMode.None; playerController.storageGUIopen = false; playerController.craftingGUIopen = false; playerController.inventoryOpen = false; playerController.machineGUIopen = true; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; playerController.inventoryOpen = false; playerController.craftingGUIopen = false; playerController.storageGUIopen = false; playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineAmount = playerController.objectInSight.GetComponent().amount; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; playerController.machineType = playerController.objectInSight.GetComponent().inputType; playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; if (playerController.objectInSight.GetComponent().inputObject != null) { if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().type; } } if (playerController.objectInSight.GetComponent().outputObject != null) { if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().type; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Smelter") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Smelter", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { playerController.machineGUIopen = true; } else { playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineAmount = playerController.objectInSight.GetComponent().amount; playerController.machineAmount2 = playerController.objectInSight.GetComponent().amount2; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; playerController.machineType = playerController.objectInSight.GetComponent().inputType1; playerController.machineType2 = playerController.objectInSight.GetComponent().inputType2; playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; if (playerController.objectInSight.GetComponent().inputObject1 != null) { if (playerController.objectInSight.GetComponent().inputObject1.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject1.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject1.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject1.GetComponent().type; } } if (playerController.objectInSight.GetComponent().inputObject2 != null) { if (playerController.objectInSight.GetComponent().inputObject2.GetComponent() != null) { playerController.machineInputID2 = playerController.objectInSight.GetComponent().inputObject2.GetComponent().ID; playerController.machineInputAmount2 = playerController.objectInSight.GetComponent().inputObject2.GetComponent().amount; playerController.machineInputType2 = playerController.objectInSight.GetComponent().inputObject2.GetComponent().type; } } if (playerController.objectInSight.GetComponent().outputObject != null) { if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().type; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Alloy Smelter") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Alloy Smelter", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { playerController.machineGUIopen = true; } else { playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineAmount = playerController.objectInSight.GetComponent().amount; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; playerController.machineType = playerController.objectInSight.GetComponent().inputType; playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; if (playerController.objectInSight.GetComponent().inputObject != null) { if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().type; } } if (playerController.objectInSight.GetComponent().outputObject != null) { if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().type; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Extruder") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Extruder", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { playerController.machineGUIopen = true; } else { playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineRange = playerController.objectInSight.GetComponent().range; if (playerController.machineRange < 10) { playerController.machineRange = 10; } if (playerController.objectInSight.GetComponent().inputObject != null) { if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; } } if (playerController.objectInSight.GetComponent().outputObject != null) { if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Rail Cart Hub") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Rail Cart Hub", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { if (playerController.building == true) { if (GameObject.Find("GameManager").GetComponent().working == false) { playerController.stoppingBuildCoRoutine = true; GameObject.Find("GameManager").GetComponent().CombineBlocks(); playerController.separatedBlocks = false; playerController.destroyTimer = 0; playerController.buildTimer = 0; playerController.building = false; playerController.destroying = false; } else { playerController.requestedBuildingStop = true; } } Cursor.visible = true; Cursor.lockState = CursorLockMode.None; playerController.storageGUIopen = false; playerController.craftingGUIopen = false; playerController.inventoryOpen = false; playerController.machineGUIopen = true; } else { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; playerController.inventoryOpen = false; playerController.craftingGUIopen = false; playerController.storageGUIopen = false; playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; if (playerController.objectInSight.GetComponent().type.Count > 1) { playerController.machineType = "multiple items"; } else if (playerController.objectInSight.GetComponent().type.Count > 0) { playerController.machineType = playerController.objectInSight.GetComponent().type[0]; } else { playerController.machineType = "nothing"; } playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; playerController.storageInventory = playerController.objectInSight.GetComponent(); if (playerController.objectInSight.GetComponent().inputObject != null) { if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; } } if (playerController.objectInSight.GetComponent().outputObject != null) { if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().type; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Retriever") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Retriever", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { playerController.machineGUIopen = true; playerController.remoteStorageActive = false; } else { playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; playerController.machineType = playerController.objectInSight.GetComponent().type; playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; playerController.storageInventory = playerController.objectInSight.GetComponent(); if (playerController.objectInSight.GetComponent().inputObject != null) { if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Auto Crafter") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Auto Crafter", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { playerController.machineGUIopen = true; playerController.remoteStorageActive = false; } else { playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineAmount = playerController.objectInSight.GetComponent().amount; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineType = playerController.objectInSight.GetComponent().inputType; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; if (playerController.objectInSight.GetComponent().inputObject != null) { if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().type; } } if (playerController.objectInSight.GetComponent().outputObject != null) { if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Heat Exchanger") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Heat Exchanger", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { playerController.machineGUIopen = true; } else { playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineAmount = playerController.objectInSight.GetComponent().amount; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; playerController.machineType = playerController.objectInSight.GetComponent().inputType; playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; if (playerController.objectInSight.GetComponent().inputObject != null) { if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().type; } } if (playerController.objectInSight.GetComponent().outputObject != null) { if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().type; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Gear Cutter") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Gear Cutter", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { playerController.machineGUIopen = true; } else { playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { playerController.machineInSight = playerController.objectInSight; playerController.machineAmount = playerController.objectInSight.GetComponent().amount; playerController.machineID = playerController.objectInSight.GetComponent().ID; playerController.machineHasPower = playerController.objectInSight.GetComponent().powerON; playerController.machineType = playerController.objectInSight.GetComponent().inputType; playerController.machinePower = playerController.objectInSight.GetComponent().power; playerController.machineSpeed = playerController.objectInSight.GetComponent().speed; playerController.machineHeat = playerController.objectInSight.GetComponent().heat; playerController.machineCooling = playerController.objectInSight.GetComponent().cooling; if (playerController.objectInSight.GetComponent().inputObject != null) { if (playerController.objectInSight.GetComponent().inputObject.GetComponent() != null) { playerController.machineInputID = playerController.objectInSight.GetComponent().inputObject.GetComponent().ID; playerController.machineInputAmount = playerController.objectInSight.GetComponent().inputObject.GetComponent().amount; playerController.machineInputType = playerController.objectInSight.GetComponent().inputObject.GetComponent().type; } } if (playerController.objectInSight.GetComponent().outputObject != null) { if (playerController.objectInSight.GetComponent().outputObject.GetComponent() != null) { playerController.machineOutputID = playerController.objectInSight.GetComponent().outputObject.GetComponent().ID; playerController.machineOutputAmount = playerController.objectInSight.GetComponent().outputObject.GetComponent().amount; playerController.machineOutputType = playerController.objectInSight.GetComponent().outputObject.GetComponent().type; } } if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Press") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Press", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { if (playerController.machineGUIopen == false) { playerController.machineGUIopen = true; } else { playerController.machineGUIopen = false; } } } else if (playerController.objectInSight.GetComponent() != null) { if (cInput.GetKeyDown("Collect Object")) { string objectName = ""; if (playerController.objectInSight.name.Equals("IronRamp(Clone)")) { objectName = "Iron Ramp"; } else { objectName = "Iron Block"; } bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals(objectName) && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem(objectName, 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); playerController.destroyTimer = 0; playerController.buildTimer = 0; } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } } else if (playerController.objectInSight.GetComponent() != null) { if (cInput.GetKeyDown("Collect Object")) { string objectName = ""; if (playerController.objectInSight.name.Equals("SteelRamp(Clone)")) { objectName = "Steel Ramp"; } else { objectName = "Steel Block"; } bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals(objectName) && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem(objectName, 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); playerController.destroyTimer = 0; playerController.buildTimer = 0; } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } } else if (playerController.objectInSight.GetComponent() != null) { if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Glass Block") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Glass Block", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); playerController.destroyTimer = 0; playerController.buildTimer = 0; } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } } else if (playerController.objectInSight.GetComponent() != null) { if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Brick") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Brick", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); playerController.destroyTimer = 0; playerController.buildTimer = 0; } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } } else if (playerController.objectInSight.GetComponent() != null) { if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Electric Light") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Electric Light", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } } else if (playerController.objectInSight.tag.Equals("CombinedMesh")) { playerController.lookingAtCombinedMesh = true; if (cInput.GetKeyDown("Collect Object") && playerController.paintGunActive == false) { if (GameObject.Find("GameManager").GetComponent().working == false) { GameObject.Find("GameManager").GetComponent().SeparateBlocks(transform.position, "all",true); playerController.separatedBlocks = true; } else { playerController.requestedChunkLoad = true; } if (playerController.building == false) { playerController.destroying = true; playerController.destroyStartPosition = transform.position; } } if (playerController.paintGunActive == true && playerController.paintColorSelected == true) { if (Input.GetKeyDown(KeyCode.Mouse0)) { playerController.paintGun.GetComponent().Play(); playerController.objectInSight.GetComponent().material.color = new Color(playerController.paintRed, playerController.paintGreen, playerController.paintBlue); if (playerController.objectInSight.name.Equals("brickHolder(Clone)")) { PlayerPrefsX.SetBool(playerController.stateManager.WorldName + "brickHolder" + playerController.objectInSight.GetComponent().ID + "painted", true); } if (playerController.objectInSight.name.Equals("glassHolder(Clone)")) { PlayerPrefsX.SetBool(playerController.stateManager.WorldName + "glassHolder" + playerController.objectInSight.GetComponent().ID + "painted", true); } if (playerController.objectInSight.name.Equals("ironHolder(Clone)")) { PlayerPrefsX.SetBool(playerController.stateManager.WorldName + "ironHolder" + playerController.objectInSight.GetComponent().ID + "painted", true); } if (playerController.objectInSight.name.Equals("steelHolder(Clone)")) { PlayerPrefsX.SetBool(playerController.stateManager.WorldName + "steelHolder" + playerController.objectInSight.GetComponent().ID + "painted", true); } } } } else if (playerController.objectInSight.GetComponent() != null) { if (cInput.GetKeyDown("Collect Object")) { bool spaceAvailable = false; foreach (InventorySlot slot in playerController.playerInventory.inventory) { if (slot.typeInSlot.Equals("nothing") || slot.typeInSlot.Equals("Quantum Hatchway") && slot.amountInSlot < 1000) { spaceAvailable = true; } } if (spaceAvailable == true) { playerController.playerInventory.AddItem("Quantum Hatchway", 1); Destroy(playerController.objectInSight); playerController.guiSound.volume = 0.3f; playerController.guiSound.clip = playerController.craftingClip; playerController.guiSound.Play(); } else { playerController.cannotCollect = true; playerController.guiSound.volume = 0.15f; playerController.guiSound.clip = playerController.missingItemsClip; playerController.guiSound.Play(); } } if (cInput.GetKeyDown("Interact")) { AirLock[] airLocks = FindObjectsOfType(); foreach (AirLock a in airLocks) { if (Vector3.Distance(transform.position, a.transform.position) < 40) { a.ToggleOpen(); } } if (playerController.objectInSight.GetComponent().open == true) { playerController.objectInSight.GetComponent().openObject.GetComponent().Play(); } else { playerController.objectInSight.GetComponent().closedObject.GetComponent().Play(); } } } else { if (playerController.machineGUIopen == true) { playerController.machineGUIopen = false; } playerController.lookingAtCombinedMesh = false; playerController.objectInSight = null; playerController.machineInSight = null; playerController.machineInputID = "none"; playerController.machineOutputID = "none"; playerController.machineType = "none"; playerController.machineAmount = 0; playerController.machineInputAmount = 0; playerController.machineOutputAmount = 0; } } else { if (playerController.machineGUIopen == true) { playerController.machineGUIopen = false; } playerController.lookingAtCombinedMesh = false; playerController.objectInSight = null; playerController.machineInSight = null; playerController.machineInputID = "none"; playerController.machineOutputID = "none"; playerController.machineType = "none"; playerController.machineAmount = 0; playerController.machineInputAmount = 0; playerController.machineOutputAmount = 0; } } }