- Added a callback class to allow interactions to send signals to non-pickups. - Round 2 phone now syncs with VRCObjectSync, like many simple pick-ups now do. - Doors can now choose whether they auto-close. - GameManagers now enable and disable live lights as necessary. - More transparent textures now have "Alpha is transparency" enabled. - Podium prefab shifted slightly in its default position. This changes nothing.
101 lines
2.2 KiB
C#
101 lines
2.2 KiB
C#
|
|
using UdonSharp;
|
|
using UnityEngine;
|
|
using VRC.SDK3.Components;
|
|
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 VRCObjectSync _PhoneObjectSync;
|
|
[SerializeField] private VRCPickup _PhonePickup;
|
|
|
|
[UdonSynced] private bool _Active = false;
|
|
[UdonSynced] private string _CallRecipient = "";
|
|
[UdonSynced] private bool _CallHasBeenPlayed = false;
|
|
|
|
private bool _Active_Cached = false;
|
|
|
|
|
|
public override void OnDeserialization(DeserializationResult Result)
|
|
{
|
|
_Activate_Synced();
|
|
base.OnDeserialization(Result);
|
|
}
|
|
|
|
public void JailPhonePickedUp()
|
|
{
|
|
VRCPlayerApi LocalPlayer = Networking.LocalPlayer;
|
|
Networking.SetOwner(LocalPlayer, gameObject);
|
|
|
|
if (LocalPlayer.displayName == _CallRecipient)
|
|
{
|
|
PlayJailCall();
|
|
}
|
|
|
|
base.OnPickup();
|
|
}
|
|
|
|
|
|
public void Initialise()
|
|
{
|
|
Activate(false);
|
|
_CallHasBeenPlayed = false;
|
|
|
|
RequestSerialization();
|
|
}
|
|
|
|
public void Activate(bool Active, string CallRecipient = "")
|
|
{
|
|
if (_GameManager.IsRoundInitialised())
|
|
{
|
|
_Active = Active;
|
|
_CallRecipient = CallRecipient;
|
|
_Activate_Synced();
|
|
RequestSerialization();
|
|
}
|
|
}
|
|
private void _Activate_Synced()
|
|
{
|
|
if (_Active != _Active_Cached)
|
|
{
|
|
_PhoneObjectSync.enabled = _Active;
|
|
|
|
if (_Active)
|
|
{
|
|
_GameManager.PhoneRing();
|
|
}
|
|
else
|
|
{
|
|
_PhoneObjectSync.transform.localPosition = Vector3.zero;
|
|
_PhoneObjectSync.transform.localRotation = Quaternion.identity;
|
|
}
|
|
}
|
|
|
|
_PhonePickup.pickupable = _Active && (Networking.LocalPlayer == _GameManager.GetHostOwner() || Networking.LocalPlayer.displayName == _CallRecipient);
|
|
|
|
_Active_Cached = _Active;
|
|
}
|
|
|
|
|
|
private void PlayJailCall()
|
|
{
|
|
if (_Active && !_CallHasBeenPlayed)
|
|
{
|
|
_GameManager.SendCustomNetworkEvent(NetworkEventTarget.Owner, "FollowPlayerHoldingPhone", _CallRecipient);
|
|
|
|
SendCustomEventDelayedSeconds(nameof(PlayJailCall_Delayed), 0.75f);
|
|
_CallHasBeenPlayed = true;
|
|
RequestSerialization();
|
|
}
|
|
}
|
|
public void PlayJailCall_Delayed()
|
|
{
|
|
_GameManager.SendCustomNetworkEvent(NetworkEventTarget.Owner, "PlayJailCall");
|
|
}
|
|
}
|