EVERYTHING

This commit is contained in:
niko
2026-06-01 17:19:55 +02:00
parent d063b81359
commit b62bac090b
1081 changed files with 1716544 additions and 0 deletions
@@ -0,0 +1,93 @@
using System.Collections.Generic;
using Photon.VR.Player;
using UnityEngine;
namespace BlockSpace.Gamemodes
{
[DisallowMultipleComponent]
public sealed class GamemodeZoneManager : MonoBehaviour
{
private readonly List<GamemodeZone> zones = new List<GamemodeZone>();
public static GamemodeZoneManager Instance { get; private set; }
public GamemodeZone CurrentZone { get; private set; }
private void Awake()
{
if (Instance != null && Instance != this)
{
Object.Destroy(base.gameObject);
}
else
{
Instance = this;
}
}
private void OnDestroy()
{
if (Instance == this)
{
Instance = null;
}
}
private void Update()
{
RefreshZonesFromPlayerPositions();
}
internal void RegisterZone(GamemodeZone zone)
{
if (!(zone == null) && !zones.Contains(zone))
{
zones.Add(zone);
}
}
internal void UnregisterZone(GamemodeZone zone)
{
if (!(zone == null))
{
zones.Remove(zone);
if (CurrentZone == zone)
{
CurrentZone = null;
}
}
}
private void RefreshZonesFromPlayerPositions()
{
if (zones.Count == 0)
{
CurrentZone = null;
return;
}
PhotonVRPlayer[] array = Object.FindObjectsByType<PhotonVRPlayer>(FindObjectsInactive.Include);
PhotonVRPlayer photonVRPlayer = null;
foreach (PhotonVRPlayer photonVRPlayer2 in array)
{
if (!(photonVRPlayer2 == null) && photonVRPlayer2.photonView != null && photonVRPlayer2.photonView.IsMine)
{
photonVRPlayer = photonVRPlayer2;
}
}
CurrentZone = null;
Vector3 worldPosition = ((photonVRPlayer != null) ? GamemodeZone.GetPlayerZonePosition(photonVRPlayer) : Vector3.zero);
for (int j = 0; j < zones.Count; j++)
{
GamemodeZone gamemodeZone = zones[j];
if (!(gamemodeZone == null))
{
gamemodeZone.RefreshPlayersInside(array);
if (photonVRPlayer != null && CurrentZone == null && gamemodeZone.ContainsWorldPosition(worldPosition))
{
CurrentZone = gamemodeZone;
}
}
}
}
}
}