using BlockSpace.Voxels; using Photon.Pun; using Photon.VR; using Photon.VR.Player; using UnityEngine; internal static class NodePlayerUtility { public static float GetVoxelSize() { if (!(VoxelGroupManager.Instance != null)) { return 0.125f; } return VoxelGroupManager.Instance.VoxelSize; } public static Vector3 WorldToVoxelPosition(Vector3 worldPosition) { float num = Mathf.Max(0.0001f, GetVoxelSize()); return worldPosition / num; } public static Vector3 VoxelToWorldPosition(Vector3 voxelPosition) { return voxelPosition * Mathf.Max(0.0001f, GetVoxelSize()); } public static int NormalizeQuarterTurns(int turns) { turns %= 4; if (turns >= 0) { return turns; } return turns + 4; } public static Vector3Int WorldEulerToQuarterTurns(Vector3 eulerAngles) { return new Vector3Int(NormalizeQuarterTurns(Mathf.RoundToInt(eulerAngles.x / 90f)), NormalizeQuarterTurns(Mathf.RoundToInt(eulerAngles.y / 90f)), NormalizeQuarterTurns(Mathf.RoundToInt(eulerAngles.z / 90f))); } public static int ResolveLocalPlayerId() { PhotonVRPlayer photonVRPlayer = ((PhotonVRManager.Manager != null) ? PhotonVRManager.Manager.LocalPlayer : null); if (photonVRPlayer != null && photonVRPlayer.photonView != null && photonVRPlayer.photonView.Owner != null) { return photonVRPlayer.photonView.Owner.ActorNumber; } if (PhotonNetwork.LocalPlayer == null) { return 0; } return PhotonNetwork.LocalPlayer.ActorNumber; } public static bool IsLocalPlayerId(int playerId) { if (playerId > 0) { return playerId == ResolveLocalPlayerId(); } return false; } public static PhotonVRPlayer ResolvePlayer(int playerId) { if (playerId <= 0) { return null; } PhotonVRPlayer photonVRPlayer = ((PhotonVRManager.Manager != null) ? PhotonVRManager.Manager.LocalPlayer : null); if (photonVRPlayer != null && photonVRPlayer.photonView != null && photonVRPlayer.photonView.OwnerActorNr == playerId) { return photonVRPlayer; } PhotonVRPlayer[] array = Object.FindObjectsByType(FindObjectsInactive.Include); foreach (PhotonVRPlayer photonVRPlayer2 in array) { if (!(photonVRPlayer2 == null) && !(photonVRPlayer2.photonView == null) && photonVRPlayer2.photonView.OwnerActorNr == playerId) { return photonVRPlayer2; } } return null; } public static Transform ResolveHeadTransform(PhotonVRPlayer player) { if (player == null) { return null; } if (!(player.Head != null)) { return player.transform; } return player.Head; } }