EVERYTHING
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using BlockSpace.Voxels;
|
||||
using UnityEngine;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public sealed class SphereOverlapBehavior : NodeBehavior
|
||||
{
|
||||
private readonly List<VoxelGroup> buffer = new List<VoxelGroup>();
|
||||
|
||||
public override void OnRun(string inputPortName)
|
||||
{
|
||||
if (!string.Equals(inputPortName, "Scan", StringComparison.Ordinal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
VoxelGroupManager instance = VoxelGroupManager.Instance;
|
||||
if (instance == null)
|
||||
{
|
||||
SetOutputValueIfChanged("Group", BSValue.None);
|
||||
TriggerOutput("Done");
|
||||
return;
|
||||
}
|
||||
Vector3 voxelPosition = new Vector3((float)GetInputNumber("X"), (float)GetInputNumber("Y"), (float)GetInputNumber("Z"));
|
||||
float num = Mathf.Max(0f, (float)GetInputNumber("Radius"));
|
||||
Vector3 vector = NodePlayerUtility.VoxelToWorldPosition(voxelPosition);
|
||||
float num2 = num * NodePlayerUtility.GetVoxelSize();
|
||||
float num3 = num2 * num2;
|
||||
buffer.Clear();
|
||||
instance.GetAllGroups(buffer);
|
||||
for (int i = 0; i < buffer.Count; i++)
|
||||
{
|
||||
VoxelGroup voxelGroup = buffer[i];
|
||||
if (!(voxelGroup == null) && (voxelGroup.GetWorldBounds().ClosestPoint(vector) - vector).sqrMagnitude <= num3)
|
||||
{
|
||||
SetOutputValueIfChanged("Group", BSValue.FromGroup(voxelGroup.id));
|
||||
TriggerOutput("Each");
|
||||
}
|
||||
}
|
||||
SetOutputValueIfChanged("Group", BSValue.None);
|
||||
TriggerOutput("Done");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user