using System; using System.Collections; using System.Collections.Generic; using System.Net.NetworkInformation; using Quadtree; using UnityEngine; namespace BITKit.OpenWorld { public class ChunkObject : MonoBehaviour,IWorldChunkObject { [SerializeField,ReadOnly] private int _lod = -1; [SerializeField,ReadOnly] private int id; [SerializeField] protected Vector3 size = Vector3.one; [SerializeField] protected Vector3 offset = Vector3.one * 0.5f; public Bounds GetBounds()=>new Bounds(transform.position+transform.rotation * offset,transform.rotation * size); 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 => OnLodChanged(_lod,_lod=value); } protected virtual void Start() { UnityWorldChunkService.Singleton.Register(this); destroyCancellationToken.Register(Dispose); } private void Dispose() { UnityWorldChunkService.Singleton.Unregister(this); } protected virtual void OnLodChanged(int oldLod, int newLod) { } private void OnDrawGizmosSelected() { var bounds = GetBounds(); Gizmos.color = Color.red; Gizmos.DrawWireCube(bounds.center, bounds.size); } } }