using Quadtree.Items;
using System.Collections.Generic;
using UnityEngine;
namespace Quadtree
{
///
/// Mandatory interface of any single quadtree node.
///
public interface INode
where TItem : IItem
where TNode : INode
{
///
/// Bounds of this tree node.
///
Bounds Bounds { get; set; }
///
/// Root of the whole tree.
///
IQuadtreeRoot TreeRoot { get; set; }
///
/// Reference to parent tree node.
///
///
/// Is null for root node of the tree.
///
TNode ParentNode { get; set; }
///
/// Child nodes of this node.
///
IList SubNodes { get; set; }
///
/// Verifies whether provided boundaries () are fully contained within the boundaries of the node.
///
///
/// Boundaries of an object
/// True if object is fully contained within the node, False otherwise
bool Contains(Bounds bounds);
///
/// Calculates relative internal position of the provided bounds () within the node.
///
///
/// The method expects the boundaries to be fully contained within the node.
///
///
/// Boundaries contained within the node
/// Relative internal position
IntraLocation Location(Bounds bounds);
///
/// Inserts item () into the smallest node possible in the subtree.
///
///
/// The method expects item boundaries to be fully contained within the node.
///
///
/// Item to be inserted
void Insert(TItem item);
///
/// Removes the provided item () from the node and its subtree.
///
///
/// Item to be removed from the tree
void Remove(TItem item);
///
/// Checks whether the node and recursively all its subnodes are empty.
///
///
/// True if node and all its subnodes are empty, False otherwise
bool IsEmpty();
///
/// Updates provided item's () location within the tree.
///
///
/// Item which's location is to be updated
/// True forces tree to re-insert the item
/// True only for the first called node
void Update(TItem item, bool forceInsertionEvaluation = true, bool hasOriginallyContainedItem = true);
///
/// Finds items () located within provided boundaries ().
///
///
/// Boundaries to look for items within
/// Output list for found items
void FindAndAddItems(Bounds bounds, ref IList items);
///
/// Adds all items of this node and its sub-nodes to the provided list of items ().
/// If boundaries () are provided then only items intersecting with them will be added.
///
///
/// Output list for found items
/// Boundaries to look for items within
void AddItems(ref IList items, Bounds? bounds = null);
///
/// Removes any existing items from the node and removes all of its sub-nodes.
///
void Clear();
///
/// Displays boundaries of this node and all its sub-nodes and optinally a current number of contained items if is True.
///
///
/// True if number of node's items should be displayed
void DrawBounds(bool displayNumberOfItems = false);
}
}