using System; using System.Collections; using System.Collections.Generic; using Quadtree; using UnityEngine; namespace BITKit.OpenWorld { public class ChunkLodObject : MonoBehaviour, IWorldChunkObject { [SerializeField] private List lodObjects; [SerializeField,ReadOnly] private int _lod = -1; [SerializeField,ReadOnly] private int id; [SerializeField] private Vector3 initialSize; private Bounds _bounds; public Bounds GetBounds() => _bounds; public Node ParentNode { get; set; } public void QuadTree_Root_Initialized(IQuadtreeRoot> root) { } public int Id { get=>id; set=>id = value; } public int Lod { get=>_lod; set { if (_lod is not -1) lodObjects[_lod].enabled = false; _lod = value; if (_lod is -1) return; if (lodObjects.Count > _lod) lodObjects[_lod].enabled = true; } } private void Start() { _bounds = new Bounds(transform.position, initialSize); foreach (var x in lodObjects) if (x) x.enabled = false; UnityWorldChunkService.Register(this); destroyCancellationToken.Register(Dispose); } private void Dispose() { UnityWorldChunkService.Unregister(this); } } }