Jamie Greunbaum 6721bc1729 - Added an unfinished The Brazen Bean Bamboozlement to the list of cases.
- Lightning round now supports clue images.
- Added Canadian province borders file to the map maker files.
2026-06-27 14:47:47 -04:00

104 lines
2.9 KiB
C#

using UdonSharp;
using UnityEngine;
using VRC.SDK3.Data;
using VRC.SDK3.Image;
using VRC.Udon.Common;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class LightningRoundClueImage : UdonSharpBehaviour
{
[SerializeField] private GameManagerRound1 _GameManager;
[Space]
[SerializeField] private GameObject _ClueImageHome;
[SerializeField] private MeshRenderer _ClueImageCardMesh;
[UdonSynced] private bool _Enabled = false;
[UdonSynced] private int[] _ReferenceImageIndices = new int[0];
[UdonSynced] private float[] _ReferenceImageScales = new float[0];
[UdonSynced] private int _CurrentClueImageIndex = -1;
private VRCImageDownloader _ClueImageDownloader;
void Start()
{
_ClueImageDownloader = new VRCImageDownloader();
}
void OnDestroy()
{
_ClueImageDownloader.Dispose();
}
public override void OnDeserialization(DeserializationResult Result)
{
_EnableImage_Synced();
_LoadClueImage_Synced();
base.OnDeserialization(Result);
}
public void EnableImage(bool Enable)
{
_Enabled = Enable;
_EnableImage_Synced();
RequestSerialization();
}
private void _EnableImage_Synced()
{
_ClueImageCardMesh.transform.localPosition = Vector3.zero;
_ClueImageCardMesh.transform.localRotation = Quaternion.identity;
_ClueImageHome.SetActive(_Enabled);
}
public void LoadClueImages(DataList ReferenceImages, DataList ReferenceImagesScale)
{
_ReferenceImageIndices = new int[ReferenceImages.Count];
for (int i = 0; i < _ReferenceImageIndices.Length; i++)
{
_ReferenceImageIndices[i] = (int)ReferenceImages[i].Number;
}
_ReferenceImageScales = new float[ReferenceImages.Count];
for (int i = 0; i < _ReferenceImageScales.Length; i++)
{
_ReferenceImageScales[i] = (i < ReferenceImagesScale.Count) ? (float)ReferenceImagesScale[i].Number : 1.0f;
}
_LoadClueImage(0);
}
private void _LoadClueImage(int Index)
{
_CurrentClueImageIndex = Index % _ReferenceImageIndices.Length;
_ClueImageCardMesh.transform.localScale = Vector3.one;
_LoadClueImage_Synced();
RequestSerialization();
}
private void _LoadClueImage_Synced()
{
if (_CurrentClueImageIndex >= 0 && _CurrentClueImageIndex < _ReferenceImageIndices.Length)
{
TextureInfo AdditionalTextureInfo = new TextureInfo();
AdditionalTextureInfo.WrapModeU = TextureWrapMode.Clamp;
AdditionalTextureInfo.WrapModeV = TextureWrapMode.Clamp;
AdditionalTextureInfo.GenerateMipMaps = true;
_ClueImageDownloader.DownloadImage(
_GameManager.GetClueImageURL(_ReferenceImageIndices[_CurrentClueImageIndex % _ReferenceImageIndices.Length]), null, this, AdditionalTextureInfo);
}
}
public override void OnImageLoadSuccess(IVRCImageDownload Result)
{
_ClueImageCardMesh.material.SetTexture("_MainTex", Result.Result);
float Scale = _ReferenceImageScales[_CurrentClueImageIndex];
_ClueImageCardMesh.transform.localScale = new Vector3(Scale, Scale, Scale);
base.OnImageLoadSuccess(Result);
}
}