using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using BITKit; using BITKit.OpenWorld; using Quadtree; using UnityEngine; namespace BITFALL.OpenWorld { public class RuntimeSetActiveChunk : MonoBehaviour,IWorldChunkObject { [SerializeField, ReadOnly] private Vector3 size; [SerializeField,ReadOnly] private int _lod=-1; public Node ParentNode { get; set; } public Bounds GetBounds() { if (_isInitialized) return _bounds; _bounds = new Bounds(transform.position,Vector3.one); foreach (var x in _renderers = GetComponentsInChildren(true)) { _bounds.Encapsulate(x.bounds); } size = _bounds.size; _isInitialized = true; return _bounds; } private bool _isInitialized; private Bounds _bounds; public void QuadTree_Root_Initialized(IQuadtreeRoot> root) { } public int Id { get; set; } private Renderer[] _renderers; public int Lod { get => _lod; set { _lod = value; var _active = value is 0 or 1; if(_active==active)return; active = _active; foreach (var x in _renderers) { x.enabled = active; } } } private bool active; internal void Initialize() { GetBounds(); foreach (var x in _renderers) { x.enabled = false; } active = false; } } }