EVERYTHING
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public sealed class DistanceBehavior : GuardedValueNodeBehavior
|
||||
{
|
||||
protected override void RecomputeCore()
|
||||
{
|
||||
Vector3 worldPosition = ResolvePosition(GetInputValue("A"));
|
||||
Vector3 worldPosition2 = ResolvePosition(GetInputValue("B"));
|
||||
Vector3 a = NodePlayerUtility.WorldToVoxelPosition(worldPosition);
|
||||
Vector3 b = NodePlayerUtility.WorldToVoxelPosition(worldPosition2);
|
||||
float num = Vector3.Distance(a, b);
|
||||
SetOutputValueIfChanged("Distance", BSValue.FromNumber(num));
|
||||
}
|
||||
|
||||
private static Vector3 ResolvePosition(BSValue value)
|
||||
{
|
||||
if (value.Kind == BSValueKind.Player)
|
||||
{
|
||||
Transform transform = NodePlayerUtility.ResolveHeadTransform(NodePlayerUtility.ResolvePlayer(value.AsPlayerId()));
|
||||
if (!(transform != null))
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
return transform.position;
|
||||
}
|
||||
if (value.TryResolveGroup(out var group) && group != null)
|
||||
{
|
||||
return group.GetWorldBounds().center;
|
||||
}
|
||||
return Vector3.zero;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user