EVERYTHING
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using BlockSpace.Voxels;
|
||||
using BlockSpace.Worlds;
|
||||
using UnityEngine;
|
||||
|
||||
[DisallowMultipleComponent]
|
||||
public sealed class MoveBehavior : NodeBehavior
|
||||
{
|
||||
public override void OnRun(string inputPortName)
|
||||
{
|
||||
if (!string.Equals(inputPortName, "Move", StringComparison.Ordinal))
|
||||
{
|
||||
return;
|
||||
}
|
||||
BSValue inputValue = GetInputValue("Group");
|
||||
VoxelGroup group;
|
||||
if (inputValue.Kind == BSValueKind.Player)
|
||||
{
|
||||
int num = inputValue.AsPlayerId();
|
||||
if (num <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Vector3 position = NodePlayerUtility.VoxelToWorldPosition(new Vector3((float)GetInputNumber("X"), (float)GetInputNumber("Y"), (float)GetInputNumber("Z")));
|
||||
if (NodePlayerUtility.IsLocalPlayerId(num))
|
||||
{
|
||||
if (PlayerTeleportUtil.TryTeleportLocalPlayer(position))
|
||||
{
|
||||
TriggerOutput("Moved");
|
||||
}
|
||||
}
|
||||
else if (base.IsAuthoritative)
|
||||
{
|
||||
NodePlayerTransformRpc nodePlayerTransformRpc = NodePlayerTransformRpc.Ensure();
|
||||
if (nodePlayerTransformRpc != null && nodePlayerTransformRpc.TryMovePlayer(num, position))
|
||||
{
|
||||
TriggerOutput("Moved");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (base.IsAuthoritative && TryGetInputGroup("Group", out group) && !(group == null) && !(VoxelGroupManager.Instance == null))
|
||||
{
|
||||
Vector3Int gridPosition = new Vector3Int(Mathf.RoundToInt((float)GetInputNumber("X")), Mathf.RoundToInt((float)GetInputNumber("Y")), Mathf.RoundToInt((float)GetInputNumber("Z")));
|
||||
if (VoxelGroupManager.Instance.TransformGroup(group, gridPosition, group.packedRotation))
|
||||
{
|
||||
TriggerOutput("Moved");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user