Quantum-Engineering/AirLock.cs

52 lines
1.3 KiB
C#

using UnityEngine;
public class AirLock : MonoBehaviour
{
private float updateTick;
public string ID = "unassigned";
public int address;
public bool open;
public GameObject openObject;
public GameObject closedObject;
public GameObject effects;
// Called by unity engine on start up to initialize variables
public void Start()
{
if (QualitySettings.GetQualityLevel() < 3)
{
effects.SetActive(false);
}
}
// Called once per frame by unity engine
public void Update()
{
updateTick += 1 * Time.deltaTime;
if (updateTick > 0.5f + (address * 0.001f))
{
GetComponent<PhysicsHandler>().UpdatePhysics();
updateTick = 0;
}
}
// Toggle the open or closed state of the hatchway
public void ToggleOpen()
{
if (open == false)
{
openObject.SetActive(true);
closedObject.SetActive(false);
GetComponent<Collider>().isTrigger = true;
open = true;
}
else
{
openObject.SetActive(false);
closedObject.SetActive(true);
GetComponent<Collider>().isTrigger = false;
open = false;
}
}
}