1
This commit is contained in:
55
Assets/BITKit/Unity/Scripts/WorldChunk/ChunkObject.cs
Normal file
55
Assets/BITKit/Unity/Scripts/WorldChunk/ChunkObject.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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() => _bounds;
|
||||
private Bounds _bounds;
|
||||
public Node<IWorldChunkObject> ParentNode { get; set; }
|
||||
public void QuadTree_Root_Initialized(IQuadtreeRoot<IWorldChunkObject, Node<IWorldChunkObject>> root)
|
||||
{
|
||||
}
|
||||
public int Id
|
||||
{
|
||||
get=>id;
|
||||
set=>id = value;
|
||||
}
|
||||
public int Lod
|
||||
{
|
||||
get=>_lod;
|
||||
set => OnLodChanged(_lod,_lod=value);
|
||||
}
|
||||
protected virtual void Start()
|
||||
{
|
||||
_bounds= new Bounds(transform.position+transform.rotation * offset,transform.rotation * size);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user