- CameraAnchor no longer needs to sync with LightSync, and so does not. - Added noise texture to velvet rope material. - Improved lightmaps on velvet rope model. - Round 1 podiums now return empty strings when no player owns them. - Winning player camera in round 2 now has rotation offset for a later effect. - Jail phone syncs active status better, and finds a player to follow better.
107 lines
2.1 KiB
C#
107 lines
2.1 KiB
C#
|
|
using MMMaellon.LightSync;
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDKBase;
|
|
using VRC.Udon.Common;
|
|
using VRC.Udon.Common.Interfaces;
|
|
|
|
|
|
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
|
|
public class JailPhone : UdonSharpBehaviour
|
|
{
|
|
[SerializeField] private GameManagerRound2 _GameManager;
|
|
[SerializeField] private LightSync _ObjectSync;
|
|
|
|
[UdonSynced] private bool _Active = false;
|
|
[UdonSynced] private bool _CallHasBeenPlayed = false;
|
|
|
|
private bool _Active_Cached = false;
|
|
|
|
|
|
void Start()
|
|
{
|
|
_ObjectSync = GetComponent<LightSync>();
|
|
}
|
|
|
|
public override void OnDeserialization(DeserializationResult Result)
|
|
{
|
|
_Activate_Synced();
|
|
base.OnDeserialization(Result);
|
|
}
|
|
|
|
public override void OnPickup()
|
|
{
|
|
if (Networking.LocalPlayer != _GameManager.GetHostOwner())
|
|
{
|
|
Networking.SetOwner(Networking.LocalPlayer, gameObject);
|
|
}
|
|
base.OnPickup();
|
|
}
|
|
|
|
public override void OnPickupUseDown()
|
|
{
|
|
if (Networking.LocalPlayer == _GameManager.GetHostOwner())
|
|
{
|
|
PlayJailCall();
|
|
}
|
|
base.OnPickupUseDown();
|
|
}
|
|
|
|
public override void OnOwnershipTransferred(VRCPlayerApi Player)
|
|
{
|
|
_GameManager.SendCustomNetworkEvent(NetworkEventTarget.Owner, "FollowPlayerHoldingPhone", Player.displayName);
|
|
PlayJailCall();
|
|
base.OnOwnershipTransferred(Player);
|
|
}
|
|
|
|
|
|
public void Initialise()
|
|
{
|
|
Activate(false);
|
|
_CallHasBeenPlayed = false;
|
|
|
|
RequestSerialization();
|
|
}
|
|
|
|
public void Activate(bool Active)
|
|
{
|
|
_Active = Active;
|
|
_Activate_Synced();
|
|
_ObjectSync.pickup.pickupable = _Active;
|
|
RequestSerialization();
|
|
}
|
|
private void _Activate_Synced()
|
|
{
|
|
if (_Active != _Active_Cached)
|
|
{
|
|
if (_Active)
|
|
{
|
|
_GameManager.PhoneRing();
|
|
}
|
|
else
|
|
{
|
|
transform.localPosition = Vector3.zero;
|
|
transform.localRotation = Quaternion.identity;
|
|
}
|
|
}
|
|
|
|
_Active_Cached = _Active;
|
|
}
|
|
|
|
|
|
private void PlayJailCall()
|
|
{
|
|
if (_Active && !_CallHasBeenPlayed)
|
|
{
|
|
SendCustomEventDelayedSeconds(nameof(PlayJailCall_Delayed), 0.75f);
|
|
_CallHasBeenPlayed = true;
|
|
RequestSerialization();
|
|
}
|
|
}
|
|
public void PlayJailCall_Delayed()
|
|
{
|
|
_GameManager.SendCustomNetworkEvent(NetworkEventTarget.Owner, "PlayJailCall");
|
|
}
|
|
}
|