| 1 | using System.Collections; |
| 2 | using System.Collections.Generic; |
| 3 | using UnityEngine; |
| 4 | |
| 5 | public abstract class ModuleBase : MonoBehaviour |
| 6 | { |
| 7 | protected abstract bool TestCorrectness(); |
| 8 | public bool ModuleFinalized { get; private set; } |
| 9 | [SerializeField] private ModuleStatusLight StatusLight; |
| 10 | |
| 11 | public void EjectComponents() |
| 12 | { |
| 13 | Connector[] connected = GetComponentsInChildren<Connector>(); |
| 14 | |
| 15 | foreach (Connector conn in connected) |
| 16 | { |
| 17 | conn.Eject(); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | void LateUpdate() |
| 22 | { |
| 23 | if(!ModuleFinalized) |
| 24 | { |
| 25 | ModuleFinalized = TestCorrectness(); |
| 26 | |
| 27 | if(ModuleFinalized) |
| 28 | { |
| 29 | Connector[] connected = GetComponentsInChildren<Connector>(); |
| 30 | |
| 31 | foreach(Connector conn in connected) |
| 32 | { |
| 33 | if(conn.Connected != null) |
| 34 | conn.Connected.Locked = true; |
| 35 | } |
| 36 | |
| 37 | StatusLight.SetStatus(true); |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | } |