- Teleporter buttons change spawn for all but the host/admin/camera operators. - Fixed wanted posters having improperly scaled normal maps.
114 lines
2.8 KiB
C#
114 lines
2.8 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDKBase;
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
|
public class PlayerTeleporter : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] private PermissionsPanel _PermissionsPanel;
|
|
[Space]
|
|
[Tooltip("The spawn point used for the world. This will be moved to new locations when teleports are requested.")]
|
|
[SerializeField] private Transform _SpawnPointObject;
|
|
[Space]
|
|
[SerializeField] private Transform _EngineeringRoomTeleportLocation;
|
|
[Space]
|
|
[SerializeField] private Transform _HostTeleportLocation;
|
|
[SerializeField] private Transform _EntranceTeleportLocation;
|
|
[Space]
|
|
[SerializeField] private Transform _Player1TeleportLocation;
|
|
[SerializeField] private Transform _Player2TeleportLocation;
|
|
[SerializeField] private Transform _Player3TeleportLocation;
|
|
[Space]
|
|
[SerializeField] private Transform _AudienceTeleportLocation;
|
|
[Space]
|
|
[SerializeField] private GameObject _HostTeleportButtons;
|
|
[Space]
|
|
[SerializeField] private PlayerPodium[] _PlayerPodiums;
|
|
|
|
|
|
public override void OnPlayerRespawn(VRCPlayerApi Player)
|
|
{
|
|
if (_PermissionsPanel.IsPlayerHost(Player) ||
|
|
_PermissionsPanel.IsPlayerAdmin(Player) ||
|
|
_PermissionsPanel.IsPlayerCameraOperator(Player))
|
|
{
|
|
_MoveSpawnPointTo(_EngineeringRoomTeleportLocation);
|
|
_TeleportToCurrentSpawnPoint();
|
|
}
|
|
|
|
if (_PermissionsPanel.IsPlayerHost(Player))
|
|
{
|
|
_HostTeleportButtons.SetActive(true);
|
|
}
|
|
|
|
base.OnPlayerRespawn(Player);
|
|
}
|
|
|
|
|
|
public void HostEnabled()
|
|
{
|
|
_HostTeleportButtons.SetActive(true);
|
|
}
|
|
|
|
public void HostDisabled()
|
|
{
|
|
_HostTeleportButtons.SetActive(false);
|
|
}
|
|
|
|
|
|
public void TeleportToHostPosition()
|
|
{
|
|
_MoveSpawnPointTo(_HostTeleportLocation);
|
|
_TeleportToCurrentSpawnPoint();
|
|
}
|
|
|
|
public void TeleportToEntrancePosition()
|
|
{
|
|
_MoveSpawnPointTo(_EntranceTeleportLocation);
|
|
_TeleportToCurrentSpawnPoint();
|
|
}
|
|
|
|
public void TeleportToPlayer1Position()
|
|
{
|
|
_PlayerPodiums[0].SetPlayerName();
|
|
_MoveSpawnPointTo(_Player1TeleportLocation);
|
|
_TeleportToCurrentSpawnPoint();
|
|
}
|
|
|
|
public void TeleportToPlayer2Position()
|
|
{
|
|
_PlayerPodiums[1].SetPlayerName();
|
|
_MoveSpawnPointTo(_Player2TeleportLocation);
|
|
_TeleportToCurrentSpawnPoint();
|
|
}
|
|
|
|
public void TeleportToPlayer3Position()
|
|
{
|
|
_PlayerPodiums[2].SetPlayerName();
|
|
_MoveSpawnPointTo(_Player3TeleportLocation);
|
|
_TeleportToCurrentSpawnPoint();
|
|
}
|
|
|
|
public void TeleportToAudience()
|
|
{
|
|
_MoveSpawnPointTo(_AudienceTeleportLocation);
|
|
_TeleportToCurrentSpawnPoint();
|
|
}
|
|
|
|
|
|
private void _MoveSpawnPointTo(Transform Parent)
|
|
{
|
|
_SpawnPointObject.SetParent(Parent);
|
|
_SpawnPointObject.localPosition = Vector3.zero;
|
|
_SpawnPointObject.localRotation = Quaternion.identity;
|
|
_SpawnPointObject.localScale = Vector3.one;
|
|
}
|
|
|
|
private void _TeleportToCurrentSpawnPoint()
|
|
{
|
|
Networking.LocalPlayer.TeleportTo(_SpawnPointObject.position, _SpawnPointObject.rotation);
|
|
}
|
|
}
|