-
Notifications
You must be signed in to change notification settings - Fork 0
/
NuclearReactor.cs
98 lines (92 loc) · 3.41 KB
/
NuclearReactor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using UnityEngine;
public class NuclearReactor : Machine
{
public bool hasHeatExchanger;
public int cooling;
public string ID = "unassigned";
public string creationMethod = "built";
public int turbineCount;
public bool sufficientCooling;
private StateManager stateManager;
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
}
//! Called by MachineManager update coroutine.
public override void UpdateMachine()
{
if (ID == "unassigned" || stateManager.initMachines == false)
return;
GetComponent<PhysicsHandler>().UpdatePhysics();
int currentTurbineCount = 0;
if (Physics.Raycast(transform.position, transform.up, out RaycastHit reactorUpHit, 3))
{
if (reactorUpHit.collider.gameObject.GetComponent<PowerSource>() != null)
{
if (reactorUpHit.collider.gameObject.GetComponent<PowerSource>().type.Equals("Reactor Turbine"))
{
currentTurbineCount++;
}
}
}
if (Physics.Raycast(transform.position, -transform.up, out RaycastHit reactorDownHit, 3))
{
if (reactorDownHit.collider.gameObject.GetComponent<PowerSource>() != null)
{
if (reactorDownHit.collider.gameObject.GetComponent<PowerSource>().type.Equals("Reactor Turbine"))
{
currentTurbineCount++;
}
}
}
if (Physics.Raycast(transform.position, transform.right, out RaycastHit reactorRightHit, 3))
{
if (reactorRightHit.collider.gameObject.GetComponent<PowerSource>() != null)
{
if (reactorRightHit.collider.gameObject.GetComponent<PowerSource>().type.Equals("Reactor Turbine"))
{
currentTurbineCount++;
}
}
}
if (Physics.Raycast(transform.position, -transform.right, out RaycastHit reactorLeftHit, 3))
{
if (reactorLeftHit.collider.gameObject.GetComponent<PowerSource>() != null)
{
if (reactorLeftHit.collider.gameObject.GetComponent<PowerSource>().type.Equals("Reactor Turbine"))
{
currentTurbineCount++;
}
}
}
if (Physics.Raycast(transform.position, transform.forward, out RaycastHit reactorFrontHit, 3))
{
if (reactorFrontHit.collider.gameObject.GetComponent<PowerSource>() != null)
{
if (reactorFrontHit.collider.gameObject.GetComponent<PowerSource>().type.Equals("Reactor Turbine"))
{
currentTurbineCount++;
}
}
}
if (Physics.Raycast(transform.position, -transform.forward, out RaycastHit reactorBackHit, 3))
{
if (reactorBackHit.collider.gameObject.GetComponent<PowerSource>() != null)
{
if (reactorBackHit.collider.gameObject.GetComponent<PowerSource>().type.Equals("Reactor Turbine"))
{
currentTurbineCount++;
}
}
}
turbineCount = currentTurbineCount;
if (cooling >= turbineCount * 5)
{
sufficientCooling = true;
}
else
{
sufficientCooling = false;
}
}
}