Quantum-Engineering/MachineInteraction.cs

1030 lines
46 KiB
C#
Raw Normal View History

2020-08-29 02:15:38 -04:00
using UnityEngine;
public class MachineInteraction
2020-08-29 02:15:38 -04:00
{
private PlayerController playerController;
private InteractionController interactionController;
2020-09-16 21:40:25 -05:00
//! This class handles the player's interactions with machines.
public MachineInteraction(PlayerController playerController, InteractionController interactionController)
2020-08-29 02:15:38 -04:00
{
this.playerController = playerController;
this.interactionController = interactionController;
2020-08-29 02:15:38 -04:00
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at an electric light.
2020-08-29 02:15:38 -04:00
public void InteractWithElectricLight()
{
if(cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Electric Light");
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a quantum hatchway.
2020-08-29 02:15:38 -04:00
public void InteractWithAirLock()
{
AirLock airLock = playerController.objectInSight.GetComponent<AirLock>();
2020-08-29 02:15:38 -04:00
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Quantum Hatchway");
}
if (cInput.GetKeyDown("Interact"))
{
AirLock[] airLocks = Object.FindObjectsOfType<AirLock>();
2020-08-29 02:15:38 -04:00
foreach (AirLock a in airLocks)
{
if (Vector3.Distance(playerController.transform.position, a.transform.position) < 40)
2020-08-29 02:15:38 -04:00
{
a.ToggleOpen();
}
}
if (airLock.open == true)
2020-08-29 02:15:38 -04:00
{
airLock.openObject.GetComponent<AudioSource>().Play();
2020-08-29 02:15:38 -04:00
}
else
{
airLock.closedObject.GetComponent<AudioSource>().Play();
2020-08-29 02:15:38 -04:00
}
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a power source.
2020-08-29 02:15:38 -04:00
public void InteractWithPowerSource()
{
PowerSource powerSource = playerController.objectInSight.GetComponent<PowerSource>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineID = powerSource.ID;
playerController.machineOutputID = powerSource.outputID;
2020-08-29 02:15:38 -04:00
if (powerSource.type.Equals("Solar Panel"))
2020-08-29 02:15:38 -04:00
{
if (powerSource.blocked == false)
2020-08-29 02:15:38 -04:00
{
2020-09-14 01:11:01 -04:00
playerController.machinePower = 2;
2020-08-29 02:15:38 -04:00
}
else
{
playerController.machinePower = 0;
}
}
else if (powerSource.type.Equals("Generator"))
2020-08-29 02:15:38 -04:00
{
playerController.machineAmount = powerSource.fuelAmount;
playerController.machineType = powerSource.fuelType;
if (powerSource.outOfFuel == false)
2020-08-29 02:15:38 -04:00
{
2020-09-14 01:11:01 -04:00
playerController.machinePower = 20;
2020-08-29 02:15:38 -04:00
}
else
{
playerController.machinePower = 0;
}
}
else if (powerSource.type.Equals("Reactor Turbine"))
2020-08-29 02:15:38 -04:00
{
if (powerSource.noReactor == false)
2020-08-29 02:15:38 -04:00
{
2020-09-14 01:11:01 -04:00
playerController.machinePower = 200;
2020-08-29 02:15:38 -04:00
}
else
{
playerController.machinePower = 0;
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject(powerSource.type);
2020-08-29 02:15:38 -04:00
}
if (cInput.GetKeyDown("Interact"))
{
interactionController.ToggleMachineGUI();
2020-08-29 02:15:38 -04:00
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a nuclear reactor.
2020-08-29 02:15:38 -04:00
public void InteractWithNuclearReactor()
{
NuclearReactor reactor = playerController.objectInSight.GetComponent<NuclearReactor>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineID = reactor.ID;
playerController.machineCooling = reactor.cooling;
2020-08-29 02:15:38 -04:00
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Nuclear Reactor");
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a power conduit.
2020-08-29 02:15:38 -04:00
public void InteractWithPowerConduit()
{
PowerConduit powerConduit = playerController.objectInSight.GetComponent<PowerConduit>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineID = powerConduit.ID;
playerController.machineOutputID = powerConduit.outputID1;
playerController.machineOutputID2 = powerConduit.outputID2;
playerController.machinePower = powerConduit.powerAmount;
playerController.machineRange = powerConduit.range;
2020-08-29 02:15:38 -04:00
if (playerController.machineRange < 10)
{
playerController.machineRange = 10;
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Power Conduit");
}
if (cInput.GetKeyDown("Interact"))
{
interactionController.ToggleMachineGUI();
2020-08-29 02:15:38 -04:00
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a turret.
2020-08-29 02:15:38 -04:00
public void InteractWithTurret()
{
Turret turret = playerController.objectInSight.GetComponent<Turret>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineID = turret.ID;
playerController.machineHasPower = turret.powerON;
playerController.machineSpeed = turret.speed;
playerController.machinePower = turret.power;
playerController.machineHeat = turret.heat;
playerController.machineCooling = turret.cooling;
2020-08-29 02:15:38 -04:00
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Turret");
}
if (cInput.GetKeyDown("Interact"))
{
interactionController.ToggleMachineGUI();
2020-08-29 02:15:38 -04:00
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a universal extractor.
2020-08-29 02:15:38 -04:00
public void InteractWithUniversalExtractor()
{
UniversalExtractor extractor = playerController.objectInSight.GetComponent<UniversalExtractor>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineID = extractor.ID;
playerController.collectorAmount = extractor.amount;
playerController.machineHasPower = extractor.powerON;
playerController.machinePower = extractor.power;
playerController.machineSpeed = extractor.speed;
playerController.machineHeat = extractor.heat;
playerController.machineCooling = extractor.cooling;
playerController.machineType = extractor.type;
2020-08-29 02:15:38 -04:00
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Universal Extractor");
}
if (cInput.GetKeyDown("Interact"))
{
interactionController.ToggleMachineGUI();
2020-08-29 02:15:38 -04:00
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at an auger.
2020-08-29 02:15:38 -04:00
public void InteractWithAuger()
{
Auger auger = playerController.objectInSight.GetComponent<Auger>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineID = auger.ID;
playerController.collectorAmount = auger.amount;
playerController.machineHasPower = auger.powerON;
playerController.machinePower = auger.power;
playerController.machineSpeed = auger.speed;
playerController.machineHeat = auger.heat;
playerController.machineCooling = auger.cooling;
2020-08-29 02:15:38 -04:00
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Auger");
}
if (cInput.GetKeyDown("Interact"))
{
interactionController.ToggleMachineGUI();
2020-08-29 02:15:38 -04:00
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a dark matter collector.
2020-08-29 02:15:38 -04:00
public void InteractWithDarkMatterCollector()
{
DarkMatterCollector collector = playerController.objectInSight.GetComponent<DarkMatterCollector>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineID = collector.ID;
playerController.collectorAmount = collector.darkMatterAmount;
playerController.machineHasPower = collector.powerON;
playerController.machinePower = collector.power;
playerController.machineSpeed = collector.speed;
playerController.machineHeat = collector.heat;
playerController.machineCooling = collector.cooling;
2020-08-29 02:15:38 -04:00
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Dark Matter Collector");
}
if (cInput.GetKeyDown("Interact"))
{
if (playerController.machineGUIopen == false)
{
playerController.machineGUIopen = true;
}
else
{
playerController.machineGUIopen = false;
}
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a universal conduit.
2020-08-29 02:15:38 -04:00
public void InteractWithUniversalConduit()
{
UniversalConduit conduit = playerController.objectInSight.GetComponent<UniversalConduit>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineAmount = conduit.amount;
playerController.machineID = conduit.ID;
playerController.machineType = conduit.type;
playerController.machineSpeed = conduit.speed;
playerController.machineRange = conduit.range;
2020-08-29 02:15:38 -04:00
if (playerController.machineRange < 10)
{
playerController.machineRange = 10;
}
if (conduit.inputObject != null)
2020-08-29 02:15:38 -04:00
{
GameObject conduitInput = conduit.inputObject;
if (conduitInput.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = conduitInput.GetComponent<UniversalConduit>().ID;
playerController.machineInputAmount = conduitInput.GetComponent<UniversalConduit>().amount;
playerController.machineInputType = conduitInput.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
if (conduitInput.GetComponent<UniversalExtractor>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = conduitInput.GetComponent<UniversalExtractor>().ID;
playerController.machineInputAmount = conduitInput.GetComponent<UniversalExtractor>().amount;
playerController.machineInputType = conduitInput.GetComponent<UniversalExtractor>().type;
2020-08-29 02:15:38 -04:00
}
if (conduitInput.GetComponent<Auger>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = conduitInput.GetComponent<Auger>().ID;
playerController.machineInputAmount = conduitInput.GetComponent<Auger>().amount;
2020-08-29 02:15:38 -04:00
playerController.machineInputType = "Regolith";
}
if (conduitInput.GetComponent<Smelter>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = conduitInput.GetComponent<Smelter>().ID;
playerController.machineInputAmount = conduitInput.GetComponent<Smelter>().amount;
playerController.machineInputType = conduitInput.GetComponent<Smelter>().outputType;
2020-08-29 02:15:38 -04:00
}
if (conduitInput.GetComponent<Press>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = conduitInput.GetComponent<Press>().ID;
playerController.machineInputAmount = conduitInput.GetComponent<Press>().amount;
playerController.machineInputType = conduitInput.GetComponent<Press>().outputType;
2020-08-29 02:15:38 -04:00
}
if (conduitInput.GetComponent<AlloySmelter>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = conduitInput.GetComponent<AlloySmelter>().ID;
playerController.machineInputAmount = conduitInput.GetComponent<AlloySmelter>().amount;
playerController.machineInputType = conduitInput.GetComponent<AlloySmelter>().outputType;
2020-08-29 02:15:38 -04:00
}
if (conduitInput.GetComponent<Extruder>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = conduitInput.GetComponent<Extruder>().ID;
playerController.machineInputAmount = conduitInput.GetComponent<Extruder>().amount;
playerController.machineInputType = conduitInput.GetComponent<Extruder>().outputType;
2020-08-29 02:15:38 -04:00
}
if (conduitInput.GetComponent<Retriever>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = conduitInput.GetComponent<Retriever>().ID;
playerController.machineInputType = conduitInput.GetComponent<Retriever>().currentType;
2020-08-29 02:15:38 -04:00
}
if (conduitInput.GetComponent<HeatExchanger>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = conduitInput.GetComponent<HeatExchanger>().ID;
playerController.machineInputAmount = conduitInput.GetComponent<HeatExchanger>().amount;
playerController.machineInputType = conduitInput.GetComponent<HeatExchanger>().inputType;
2020-08-29 02:15:38 -04:00
}
if (conduitInput.GetComponent<GearCutter>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = conduitInput.GetComponent<GearCutter>().ID;
playerController.machineInputAmount = conduitInput.GetComponent<GearCutter>().amount;
playerController.machineInputType = conduitInput.GetComponent<GearCutter>().outputType;
2020-08-29 02:15:38 -04:00
}
2020-09-13 02:45:50 -04:00
if (conduitInput.GetComponent<ModMachine>() != null)
{
playerController.machineInputID = conduitInput.GetComponent<ModMachine>().ID;
playerController.machineInputAmount = conduitInput.GetComponent<ModMachine>().amount;
playerController.machineInputType = conduitInput.GetComponent<ModMachine>().outputType;
}
2020-08-29 02:15:38 -04:00
}
if (conduit.outputObject != null)
2020-08-29 02:15:38 -04:00
{
GameObject conduitOutput = conduit.outputObject;
if (conduitOutput.GetComponent<PowerSource>() != null)
2020-09-06 03:45:41 -04:00
{
playerController.machineOutputID = conduitOutput.GetComponent<PowerSource>().ID;
playerController.machineOutputAmount = conduitOutput.GetComponent<PowerSource>().fuelAmount;
playerController.machineOutputType = conduitOutput.GetComponent<PowerSource>().fuelType;
2020-09-06 03:45:41 -04:00
}
if (conduitOutput.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = conduitOutput.GetComponent<UniversalConduit>().ID;
playerController.machineOutputAmount = conduitOutput.GetComponent<UniversalConduit>().amount;
playerController.machineOutputType = conduitOutput.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
if (conduitOutput.GetComponent<Smelter>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = conduitOutput.GetComponent<Smelter>().ID;
playerController.machineOutputAmount = conduitOutput.GetComponent<Smelter>().amount;
playerController.machineOutputType = conduitOutput.GetComponent<Smelter>().inputType;
2020-08-29 02:15:38 -04:00
}
if (conduitOutput.GetComponent<Press>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = conduitOutput.GetComponent<Press>().ID;
playerController.machineOutputAmount = conduitOutput.GetComponent<Press>().amount;
playerController.machineOutputType = conduitOutput.GetComponent<Press>().inputType;
2020-08-29 02:15:38 -04:00
}
if (conduitOutput.GetComponent<Extruder>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = conduitOutput.GetComponent<Extruder>().ID;
playerController.machineOutputAmount = conduitOutput.GetComponent<Extruder>().amount;
playerController.machineOutputType = conduitOutput.GetComponent<Extruder>().inputType;
2020-08-29 02:15:38 -04:00
}
2020-09-13 02:45:50 -04:00
if (conduitOutput.GetComponent<ModMachine>() != null)
{
playerController.machineOutputID = conduitOutput.GetComponent<ModMachine>().ID;
playerController.machineOutputAmount = conduitOutput.GetComponent<ModMachine>().amount;
playerController.machineOutputType = conduitOutput.GetComponent<ModMachine>().inputType;
}
if (conduitOutput.GetComponent<HeatExchanger>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = conduitOutput.GetComponent<HeatExchanger>().ID;
playerController.machineOutputAmount = conduitOutput.GetComponent<HeatExchanger>().amount;
playerController.machineOutputType = conduitOutput.GetComponent<HeatExchanger>().inputType;
2020-08-29 02:15:38 -04:00
}
if (conduitOutput.GetComponent<GearCutter>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = conduitOutput.GetComponent<GearCutter>().ID;
playerController.machineOutputAmount = conduitOutput.GetComponent<GearCutter>().amount;
playerController.machineOutputType = conduitOutput.GetComponent<GearCutter>().inputType;
2020-08-29 02:15:38 -04:00
}
if (conduitOutput.GetComponent<AlloySmelter>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = conduitOutput.GetComponent<AlloySmelter>().ID;
playerController.machineOutputAmount = conduitOutput.GetComponent<AlloySmelter>().amount;
if (conduit.type.Equals(conduitOutput.GetComponent<AlloySmelter>().inputType1))
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputType = conduitOutput.GetComponent<AlloySmelter>().inputType1;
2020-08-29 02:15:38 -04:00
}
else if (conduit.type.Equals(conduitOutput.GetComponent<AlloySmelter>().inputType2))
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputType = conduitOutput.GetComponent<AlloySmelter>().inputType2;
2020-08-29 02:15:38 -04:00
}
}
if (conduitOutput.GetComponent<InventoryManager>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = conduitOutput.GetComponent<InventoryManager>().ID;
2020-08-29 02:15:38 -04:00
int storageTotal = 0;
foreach (InventorySlot slot in conduitOutput.GetComponent<InventoryManager>().inventory)
2020-08-29 02:15:38 -04:00
{
if (slot.typeInSlot.Equals(conduit.type))
2020-08-29 02:15:38 -04:00
{
storageTotal += slot.amountInSlot;
playerController.machineOutputType = slot.typeInSlot;
}
}
playerController.machineOutputAmount = storageTotal;
}
if (conduitOutput.GetComponent<StorageComputer>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = conduitOutput.GetComponent<StorageComputer>().ID;
2020-08-29 02:15:38 -04:00
int storageTotal = 0;
foreach (InventoryManager manager in conduitOutput.GetComponent<StorageComputer>().computerContainers)
2020-08-29 02:15:38 -04:00
{
foreach (InventorySlot slot in manager.inventory)
{
if (slot.typeInSlot.Equals(conduit.type))
2020-08-29 02:15:38 -04:00
{
storageTotal += slot.amountInSlot;
playerController.machineOutputType = slot.typeInSlot;
}
}
}
playerController.machineOutputAmount = storageTotal;
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Universal Conduit");
}
if (cInput.GetKeyDown("Interact"))
{
interactionController.ToggleMachineGUI();
2020-08-29 02:15:38 -04:00
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a dark matter conduit.
2020-08-29 02:15:38 -04:00
public void InteractWithDarkMatterConduit()
{
DarkMatterConduit dmConduit = playerController.objectInSight.GetComponent<DarkMatterConduit>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineAmount = dmConduit.darkMatterAmount;
playerController.machineID = dmConduit.ID;
playerController.machineSpeed = dmConduit.speed;
playerController.machineRange = dmConduit.range;
2020-08-29 02:15:38 -04:00
if (playerController.machineRange < 10)
{
playerController.machineRange = 10;
}
if (dmConduit.inputObject != null)
2020-08-29 02:15:38 -04:00
{
if (dmConduit.inputObject.GetComponent<DarkMatterConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = dmConduit.inputObject.GetComponent<DarkMatterConduit>().ID;
playerController.machineInputAmount = dmConduit.inputObject.GetComponent<DarkMatterConduit>().darkMatterAmount;
2020-08-29 02:15:38 -04:00
playerController.machineInputType = "Dark Matter";
}
if (dmConduit.inputObject.GetComponent<DarkMatterCollector>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = dmConduit.inputObject.GetComponent<DarkMatterCollector>().ID;
playerController.machineInputAmount = dmConduit.inputObject.GetComponent<DarkMatterCollector>().darkMatterAmount;
2020-08-29 02:15:38 -04:00
playerController.machineInputType = "Dark Matter";
}
}
if (dmConduit.outputObject != null)
2020-08-29 02:15:38 -04:00
{
if (dmConduit.outputObject.GetComponent<DarkMatterConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = dmConduit.outputObject.GetComponent<DarkMatterConduit>().ID;
playerController.machineOutputAmount = dmConduit.outputObject.GetComponent<DarkMatterConduit>().darkMatterAmount;
2020-08-29 02:15:38 -04:00
playerController.machineOutputType = "Dark Matter";
}
if (dmConduit.outputObject.GetComponent<StorageComputer>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = dmConduit.outputObject.GetComponent<StorageComputer>().ID;
2020-08-29 02:15:38 -04:00
int storageTotal = 0;
foreach (InventoryManager manager in dmConduit.outputObject.GetComponent<StorageComputer>().computerContainers)
2020-08-29 02:15:38 -04:00
{
foreach (InventorySlot slot in manager.inventory)
{
if (slot.typeInSlot.Equals("Dark Matter"))
{
storageTotal += slot.amountInSlot;
playerController.machineOutputType = "Dark Matter";
}
}
}
playerController.machineOutputAmount = storageTotal;
}
if (dmConduit.outputObject.GetComponent<InventoryManager>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = dmConduit.outputObject.GetComponent<InventoryManager>().ID;
2020-08-29 02:15:38 -04:00
int storageTotal = 0;
foreach (InventorySlot slot in dmConduit.outputObject.GetComponent<InventoryManager>().inventory)
2020-08-29 02:15:38 -04:00
{
if (slot.typeInSlot.Equals("Dark Matter"))
{
storageTotal += slot.amountInSlot;
playerController.machineOutputType = "Dark Matter";
}
}
playerController.machineOutputAmount = storageTotal;
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Dark Matter Conduit");
}
if (cInput.GetKeyDown("Interact"))
{
interactionController.ToggleMachineGUI();
2020-08-29 02:15:38 -04:00
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a smelter.
2020-08-29 02:15:38 -04:00
public void InteractWithSmelter()
{
Smelter smelter = playerController.objectInSight.GetComponent<Smelter>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineAmount = smelter.amount;
playerController.machineID = smelter.ID;
playerController.machineHasPower = smelter.powerON;
playerController.machineType = smelter.inputType;
playerController.machinePower = smelter.power;
playerController.machineSpeed = smelter.speed;
playerController.machineHeat = smelter.heat;
playerController.machineCooling = smelter.cooling;
if (smelter.inputObject != null)
2020-08-29 02:15:38 -04:00
{
if (smelter.inputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = smelter.inputObject.GetComponent<UniversalConduit>().ID;
playerController.machineInputAmount = smelter.inputObject.GetComponent<UniversalConduit>().amount;
playerController.machineInputType = smelter.inputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (smelter.outputObject != null)
2020-08-29 02:15:38 -04:00
{
if (smelter.outputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = smelter.outputObject.GetComponent<UniversalConduit>().ID;
playerController.machineOutputAmount = smelter.outputObject.GetComponent<UniversalConduit>().amount;
playerController.machineOutputType = smelter.outputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Smelter");
}
if (cInput.GetKeyDown("Interact"))
{
if (playerController.machineGUIopen == false)
{
playerController.machineGUIopen = true;
}
else
{
playerController.machineGUIopen = false;
}
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at an alloy smelter.
2020-08-29 02:15:38 -04:00
public void InteractWithAlloySmelter()
{
AlloySmelter alloySmelter = playerController.objectInSight.GetComponent<AlloySmelter>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineAmount = alloySmelter.amount;
playerController.machineAmount2 = alloySmelter.amount2;
playerController.machineID = alloySmelter.ID;
playerController.machineHasPower = alloySmelter.powerON;
playerController.machineType = alloySmelter.inputType1;
playerController.machineType2 = alloySmelter.inputType2;
playerController.machinePower = alloySmelter.power;
playerController.machineSpeed = alloySmelter.speed;
playerController.machineHeat = alloySmelter.heat;
playerController.machineCooling = alloySmelter.cooling;
if (alloySmelter.inputObject1 != null)
2020-08-29 02:15:38 -04:00
{
if (alloySmelter.inputObject1.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = alloySmelter.inputObject1.GetComponent<UniversalConduit>().ID;
playerController.machineInputAmount = alloySmelter.inputObject1.GetComponent<UniversalConduit>().amount;
playerController.machineInputType = alloySmelter.inputObject1.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (alloySmelter.inputObject2 != null)
2020-08-29 02:15:38 -04:00
{
if (alloySmelter.inputObject2.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID2 = alloySmelter.inputObject2.GetComponent<UniversalConduit>().ID;
playerController.machineInputAmount2 = alloySmelter.inputObject2.GetComponent<UniversalConduit>().amount;
playerController.machineInputType2 = alloySmelter.inputObject2.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (alloySmelter.outputObject != null)
2020-08-29 02:15:38 -04:00
{
if (alloySmelter.outputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = alloySmelter.outputObject.GetComponent<UniversalConduit>().ID;
playerController.machineOutputAmount = alloySmelter.outputObject.GetComponent<UniversalConduit>().amount;
playerController.machineOutputType = alloySmelter.outputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Alloy Smelter");
}
if (cInput.GetKeyDown("Interact"))
{
if (playerController.machineGUIopen == false)
{
playerController.machineGUIopen = true;
}
else
{
playerController.machineGUIopen = false;
}
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at an extruder.
2020-08-29 02:15:38 -04:00
public void InteractWithExtruder()
{
Extruder extruder = playerController.objectInSight.GetComponent<Extruder>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineAmount = extruder.amount;
playerController.machineID = extruder.ID;
playerController.machineHasPower = extruder.powerON;
playerController.machineType = extruder.inputType;
playerController.machinePower = extruder.power;
playerController.machineSpeed = extruder.speed;
playerController.machineHeat = extruder.heat;
playerController.machineCooling = extruder.cooling;
if (extruder.inputObject != null)
2020-08-29 02:15:38 -04:00
{
if (extruder.inputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = extruder.inputObject.GetComponent<UniversalConduit>().ID;
playerController.machineInputAmount = extruder.inputObject.GetComponent<UniversalConduit>().amount;
playerController.machineInputType = extruder.inputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (extruder.outputObject != null)
2020-08-29 02:15:38 -04:00
{
if (extruder.outputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = extruder.outputObject.GetComponent<UniversalConduit>().ID;
playerController.machineOutputAmount = extruder.outputObject.GetComponent<UniversalConduit>().amount;
playerController.machineOutputType = extruder.outputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Extruder");
}
if (cInput.GetKeyDown("Interact"))
{
if (playerController.machineGUIopen == false)
{
playerController.machineGUIopen = true;
}
else
{
playerController.machineGUIopen = false;
}
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at any machine added through the modding API (excluding plugins).
2020-09-13 02:45:50 -04:00
public void InteractWithModMachine()
{
ModMachine modMachine = playerController.objectInSight.GetComponent<ModMachine>();
playerController.machineInSight = playerController.objectInSight;
playerController.machineAmount = modMachine.amount;
playerController.machineID = modMachine.ID;
playerController.machineHasPower = modMachine.powerON;
playerController.machineType = modMachine.inputType;
playerController.machinePower = modMachine.power;
playerController.machineSpeed = modMachine.speed;
playerController.machineHeat = modMachine.heat;
playerController.machineCooling = modMachine.cooling;
if (modMachine.inputObject != null)
{
if (modMachine.inputObject.GetComponent<UniversalConduit>() != null)
{
playerController.machineInputID = modMachine.inputObject.GetComponent<UniversalConduit>().ID;
playerController.machineInputAmount = modMachine.inputObject.GetComponent<UniversalConduit>().amount;
playerController.machineInputType = modMachine.inputObject.GetComponent<UniversalConduit>().type;
}
}
if (modMachine.outputObject != null)
{
if (modMachine.outputObject.GetComponent<UniversalConduit>() != null)
{
playerController.machineOutputID = modMachine.outputObject.GetComponent<UniversalConduit>().ID;
playerController.machineOutputAmount = modMachine.outputObject.GetComponent<UniversalConduit>().amount;
playerController.machineOutputType = modMachine.outputObject.GetComponent<UniversalConduit>().type;
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject(modMachine.machineName);
}
if (cInput.GetKeyDown("Interact"))
{
if (playerController.machineGUIopen == false)
{
playerController.machineGUIopen = true;
}
else
{
playerController.machineGUIopen = false;
}
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a rail cart hub.
2020-08-29 02:15:38 -04:00
public void InteractWithRailCartHub()
{
RailCartHub railCartHub = playerController.objectInSight.GetComponent<RailCartHub>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineID = railCartHub.ID;
playerController.machineRange = railCartHub.range;
2020-08-29 02:15:38 -04:00
if (playerController.machineRange < 10)
{
playerController.machineRange = 10;
}
if (railCartHub.inputObject != null)
2020-08-29 02:15:38 -04:00
{
if (railCartHub.inputObject.GetComponent<RailCartHub>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = railCartHub.inputObject.GetComponent<RailCartHub>().ID;
2020-08-29 02:15:38 -04:00
}
}
if (railCartHub.outputObject != null)
2020-08-29 02:15:38 -04:00
{
if (railCartHub.outputObject.GetComponent<RailCartHub>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = railCartHub.outputObject.GetComponent<RailCartHub>().ID;
2020-08-29 02:15:38 -04:00
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Rail Cart Hub");
}
if (cInput.GetKeyDown("Interact"))
{
interactionController.ToggleMachineGUI();
2020-08-29 02:15:38 -04:00
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a retriever.
2020-08-29 02:15:38 -04:00
public void InteractWithRetriever()
{
Retriever retriever = playerController.objectInSight.GetComponent<Retriever>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineID = retriever.ID;
playerController.machineHasPower = retriever.powerON;
if (retriever.type.Count > 1)
2020-08-29 02:15:38 -04:00
{
playerController.machineType = "multiple items";
}
else if (retriever.type.Count > 0)
2020-08-29 02:15:38 -04:00
{
playerController.machineType = retriever.type[0];
2020-08-29 02:15:38 -04:00
}
else
{
playerController.machineType = "nothing";
}
playerController.machinePower = retriever.power;
playerController.machineSpeed = retriever.speed;
playerController.machineHeat = retriever.heat;
playerController.machineCooling = retriever.cooling;
2020-08-29 02:15:38 -04:00
playerController.storageInventory = playerController.objectInSight.GetComponent<InventoryManager>();
if (retriever.inputObject != null)
2020-08-29 02:15:38 -04:00
{
if (retriever.inputObject.GetComponent<InventoryManager>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = retriever.inputObject.GetComponent<InventoryManager>().ID;
2020-08-29 02:15:38 -04:00
}
if (retriever.inputObject.GetComponent<StorageComputer>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = retriever.inputObject.GetComponent<StorageComputer>().ID;
2020-08-29 02:15:38 -04:00
}
}
if (retriever.outputObject != null)
2020-08-29 02:15:38 -04:00
{
if (retriever.outputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = retriever.outputObject.GetComponent<UniversalConduit>().ID;
playerController.machineOutputAmount = retriever.outputObject.GetComponent<UniversalConduit>().amount;
playerController.machineOutputType = retriever.outputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (cInput.GetKeyDown("Collect Object"))
{
2020-09-05 18:39:40 -04:00
interactionController.CollectObject("Retriever");
2020-08-29 02:15:38 -04:00
}
if (cInput.GetKeyDown("Interact"))
{
if (playerController.machineGUIopen == false)
{
playerController.machineGUIopen = true;
playerController.remoteStorageActive = false;
}
else
{
playerController.machineGUIopen = false;
}
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a heat exchanger.
2020-08-29 02:15:38 -04:00
public void InteractWithHeatExchanger()
{
HeatExchanger heatExchanger = playerController.objectInSight.GetComponent<HeatExchanger>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineAmount = heatExchanger.amount;
playerController.machineID = heatExchanger.ID;
playerController.machineType = heatExchanger.inputType;
playerController.machineSpeed = heatExchanger.speed;
if (heatExchanger.inputObject != null)
2020-08-29 02:15:38 -04:00
{
if (heatExchanger.inputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = heatExchanger.inputObject.GetComponent<UniversalConduit>().ID;
playerController.machineInputAmount = heatExchanger.inputObject.GetComponent<UniversalConduit>().amount;
playerController.machineInputType = heatExchanger.inputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (heatExchanger.outputObject != null)
2020-08-29 02:15:38 -04:00
{
if (heatExchanger.outputObject.GetComponent<UniversalExtractor>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<UniversalExtractor>().ID;
2020-08-29 02:15:38 -04:00
}
if (heatExchanger.outputObject.GetComponent<DarkMatterCollector>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<DarkMatterCollector>().ID;
2020-08-29 02:15:38 -04:00
}
if (heatExchanger.outputObject.GetComponent<Auger>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<Auger>().ID;
2020-08-29 02:15:38 -04:00
}
if (heatExchanger.outputObject.GetComponent<Smelter>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<Smelter>().ID;
2020-08-29 02:15:38 -04:00
}
if (heatExchanger.outputObject.GetComponent<Extruder>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<Extruder>().ID;
2020-08-29 02:15:38 -04:00
}
if (heatExchanger.outputObject.GetComponent<Retriever>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<Retriever>().ID;
2020-08-29 02:15:38 -04:00
}
if (heatExchanger.outputObject.GetComponent<AutoCrafter>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<AutoCrafter>().ID;
2020-08-29 02:15:38 -04:00
}
if (heatExchanger.outputObject.GetComponent<Press>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<Press>().ID;
2020-08-29 02:15:38 -04:00
}
if (heatExchanger.outputObject.GetComponent<AlloySmelter>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<AlloySmelter>().ID;
2020-08-29 02:15:38 -04:00
}
if (heatExchanger.outputObject.GetComponent<GearCutter>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<GearCutter>().ID;
2020-08-29 02:15:38 -04:00
}
if (heatExchanger.outputObject.GetComponent<Turret>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<Turret>().ID;
2020-08-29 02:15:38 -04:00
}
2020-09-13 02:45:50 -04:00
if (heatExchanger.outputObject.GetComponent<ModMachine>() != null)
{
playerController.machineOutputID = heatExchanger.outputObject.GetComponent<ModMachine>().ID;
}
2020-08-29 02:15:38 -04:00
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Heat Exchanger");
}
if (cInput.GetKeyDown("Interact"))
{
if (playerController.machineGUIopen == false)
{
playerController.hxAmount = heatExchanger.amount;
2020-08-29 02:15:38 -04:00
playerController.machineGUIopen = true;
}
else
{
playerController.machineGUIopen = false;
}
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a gear cutter.
2020-08-29 02:15:38 -04:00
public void InteractWithGearCutter()
{
GearCutter gearCutter = playerController.objectInSight.GetComponent<GearCutter>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineAmount = gearCutter.amount;
playerController.machineID = gearCutter.ID;
playerController.machineHasPower = gearCutter.powerON;
playerController.machineType = gearCutter.inputType;
playerController.machinePower = gearCutter.power;
playerController.machineSpeed = gearCutter.speed;
playerController.machineHeat = gearCutter.heat;
playerController.machineCooling = gearCutter.cooling;
if (gearCutter.inputObject != null)
2020-08-29 02:15:38 -04:00
{
if (gearCutter.inputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = gearCutter.inputObject.GetComponent<UniversalConduit>().ID;
playerController.machineInputAmount = gearCutter.inputObject.GetComponent<UniversalConduit>().amount;
playerController.machineInputType = gearCutter.inputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (gearCutter.outputObject != null)
2020-08-29 02:15:38 -04:00
{
if (gearCutter.outputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = gearCutter.outputObject.GetComponent<UniversalConduit>().ID;
playerController.machineOutputAmount = gearCutter.outputObject.GetComponent<UniversalConduit>().amount;
playerController.machineOutputType = gearCutter.outputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Gear Cutter");
}
if (cInput.GetKeyDown("Interact"))
{
if (playerController.machineGUIopen == false)
{
playerController.machineGUIopen = true;
}
else
{
playerController.machineGUIopen = false;
}
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at a press.
2020-08-29 02:15:38 -04:00
public void InteractWithPress()
{
Press press = playerController.objectInSight.GetComponent<Press>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineAmount = press.amount;
playerController.machineID = press.ID;
playerController.machineHasPower = press.powerON;
playerController.machineType = press.inputType;
playerController.machinePower = press.power;
playerController.machineSpeed = press.speed;
playerController.machineHeat = press.heat;
playerController.machineCooling = press.cooling;
if (press.inputObject != null)
2020-08-29 02:15:38 -04:00
{
if (press.inputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = press.inputObject.GetComponent<UniversalConduit>().ID;
playerController.machineInputAmount = press.inputObject.GetComponent<UniversalConduit>().amount;
playerController.machineInputType = press.inputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (press.outputObject != null)
2020-08-29 02:15:38 -04:00
{
if (press.outputObject.GetComponent<UniversalConduit>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineOutputID = press.outputObject.GetComponent<UniversalConduit>().ID;
playerController.machineOutputAmount = press.outputObject.GetComponent<UniversalConduit>().amount;
playerController.machineOutputType = press.outputObject.GetComponent<UniversalConduit>().type;
2020-08-29 02:15:38 -04:00
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Press");
}
if (cInput.GetKeyDown("Interact"))
{
if (playerController.machineGUIopen == false)
{
playerController.machineGUIopen = true;
}
else
{
playerController.machineGUIopen = false;
}
}
}
2020-09-16 21:40:25 -05:00
//! Called when the player is looking at an auto crafter.
2020-08-29 02:15:38 -04:00
public void InteractWithAutoCrafter()
{
AutoCrafter autoCrafter = playerController.objectInSight.GetComponent<AutoCrafter>();
2020-08-29 02:15:38 -04:00
playerController.machineInSight = playerController.objectInSight;
playerController.machineID = autoCrafter.ID;
playerController.machineHasPower = autoCrafter.powerON;
playerController.machineType = autoCrafter.type;
playerController.machinePower = autoCrafter.power;
playerController.machineSpeed = autoCrafter.speed;
playerController.machineHeat = autoCrafter.heat;
playerController.machineCooling = autoCrafter.cooling;
2020-08-29 02:15:38 -04:00
playerController.storageInventory = playerController.objectInSight.GetComponent<InventoryManager>();
if (autoCrafter.inputObject != null)
2020-08-29 02:15:38 -04:00
{
if (autoCrafter.inputObject.GetComponent<InventoryManager>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = autoCrafter.inputObject.GetComponent<InventoryManager>().ID;
2020-08-29 02:15:38 -04:00
}
if (autoCrafter.inputObject.GetComponent<StorageComputer>() != null)
2020-08-29 02:15:38 -04:00
{
playerController.machineInputID = autoCrafter.inputObject.GetComponent<StorageComputer>().ID;
2020-08-29 02:15:38 -04:00
}
}
if (cInput.GetKeyDown("Collect Object"))
{
interactionController.CollectObject("Auto Crafter");
}
if (cInput.GetKeyDown("Interact"))
{
if (playerController.machineGUIopen == false)
{
playerController.machineGUIopen = true;
playerController.remoteStorageActive = false;
}
else
{
playerController.machineGUIopen = false;
}
}
}
2020-09-16 21:40:25 -05:00
}