This commit is contained in:
CortexCore
2024-04-16 04:15:06 +08:00
parent b673a9438d
commit 0362b2c606
183 changed files with 5695 additions and 1453 deletions

View File

@@ -3,6 +3,8 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Quadtree;
using Quadtree.Items;
using UnityEngine;
namespace BITKit.WorldNodes
@@ -32,9 +34,19 @@ namespace BITKit.WorldNodes
[ExecuteInEditMode]
public class WorldNodeService : MonoBehaviour,IWorldNodeService
{
private class WorldNodeProxy : IItem<WorldNodeProxy, Node<WorldNodeProxy>>
{
public Bounds Bounds;
public Bounds GetBounds()=>Bounds;
public Node<WorldNodeProxy> ParentNode { get; set; }
public void QuadTree_Root_Initialized(IQuadtreeRoot<WorldNodeProxy, Node<WorldNodeProxy>> root)
{
}
}
public static event Action OnDrawGizmo;
public static readonly CacheList<IWorldNode> WorldNodeList = new();
public static IWorldNode[] WorldNodes => WorldNodeList.ValueArray;
private static QuadtreeRoot<WorldNodeProxy, Node<WorldNodeProxy>> _QuadtreeRoot;
public static IWorldNode[] GetNodes(Vector3 position, float radius)
{
return WorldNodes.Where(node => InRange(position, node, radius))
@@ -77,6 +89,13 @@ namespace BITKit.WorldNodes
{
WorldNodeList.Clear();
}
[SerializeField] private Vector3 size;
private void Start()
{
_QuadtreeRoot = new QuadtreeRoot<WorldNodeProxy, Node<WorldNodeProxy>>(transform.position,size);
}
}
}