Retroactive refactoring

This commit is contained in:
raccoon
2024-12-09 18:12:25 +05:00
parent 94ff6334fe
commit abda218bae

View File

@@ -1,31 +1,25 @@
using System.Collections; using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class Autoportal : MonoBehaviour public class Autoportal : MonoBehaviour
{ {
private List<GameObject> imposters; private Transform[] imposters;
private OcclusionPortal portal; private OcclusionPortal portal;
void Start() void Start()
{ {
this.portal = this.GetComponent<OcclusionPortal>(); this.portal = this.GetComponent<OcclusionPortal>();
this.imposters = new List<GameObject>(); this.imposters = Array.FindAll(GetComponentsInChildren<Transform>(), child => child != this.transform);
foreach(Transform child in this.transform)
{
this.imposters.Add(child.gameObject);
}
} }
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
{ {
this.portal.open = true; this.portal.open = true;
foreach(GameObject imposter in this.imposters) foreach(Transform imposter in this.imposters)
{ {
imposter.SetActive(false); imposter.gameObject.SetActive(false);
} }
} }
@@ -33,9 +27,9 @@ public class Autoportal : MonoBehaviour
{ {
this.portal.open = false; this.portal.open = false;
foreach(GameObject imposter in this.imposters) foreach(Transform imposter in this.imposters)
{ {
imposter.SetActive(true); imposter.gameObject.SetActive(true);
} }
} }
} }