using System.Collections; using System.Collections.Generic; using UnityEngine; namespace CHN { public class Floor : MonoBehaviour { public int floorIndex; public List machines = new(); public bool isEmptyFloor => machines.Count == 0; public Transform StartPoint; public GameObject Outer; public GameObject TopSurfaces; public GameObject Ceiling; public GameObject VisualizationAreas; Transform CeilingQuad; public float ceilingActiveRange = 0; private void Awake() { for(int i= 0; i < transform.childCount; ++i) { switch(transform.GetChild(i).name) { case nameof(Outer): Outer = transform.GetChild(i).gameObject; break; case nameof(Ceiling): Ceiling = transform.GetChild(i).gameObject; break; case nameof(VisualizationAreas): VisualizationAreas = transform.GetChild(i).gameObject; break; case nameof(TopSurfaces): TopSurfaces = transform.GetChild(i).gameObject; break; } } } public bool FloorContainsPoint(Vector3 pos) { var floorColliders = transform.GetComponents(); foreach(var collider in floorColliders) { if (collider.bounds.Contains(pos)) { return true; } } return false; } public void SetInternalState() { Ceiling.SetActive(true); TopSurfaces.SetActive(false); } public void SetExternalState() { TopSurfaces.SetActive(false); Ceiling.SetActive(false); } public void UnderCeilingControl(Vector3 pos) { if (Ceiling == null) return; float height = CeilingQuad.transform.position.y - ceilingActiveRange; bool isUnder = pos.y < height; Ceiling.SetActive(isUnder); } } }