-
Notifications
You must be signed in to change notification settings - Fork 0
/
ElectricLight.cs
45 lines (39 loc) · 1.17 KB
/
ElectricLight.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
using UnityEngine;
public class ElectricLight : Machine
{
public string ID = "unassigned";
public string creationMethod = "built";
public bool powerON;
public GameObject powerObject;
public PowerReceiver powerReceiver;
private StateManager stateManager;
//! Called by unity engine on start up to initialize variables.
public void Start()
{
stateManager = FindObjectOfType<StateManager>();
powerReceiver = gameObject.AddComponent<PowerReceiver>();
}
//! Called by MachineManager update coroutine.
public override void UpdateMachine()
{
if (ID == "unassigned" || stateManager.initMachines == false)
return;
GetComponent<PhysicsHandler>().UpdatePhysics();
UpdatePowerReceiver();
if (powerON == true)
{
GetComponent<Light>().enabled = true;
}
else
{
GetComponent<Light>().enabled = false;
}
}
//! Gets power values from power receiver.
private void UpdatePowerReceiver()
{
powerReceiver.ID = ID;
powerON = powerReceiver.powerON;
powerObject = powerReceiver.powerObject;
}
}