Added leveler

This commit is contained in:
2026-08-07 11:40:20 +03:00
parent d9d7ee49d2
commit e3746e3e9d
22 changed files with 2824 additions and 383 deletions
@@ -0,0 +1,46 @@
using System.Collections.Generic;
using UnityEngine;
public interface IPlayerInteractionSession
{
string ReleasePrompt { get; }
bool IsControlledBy(ulong clientId);
void RequestRelease();
}
public static class PlayerInteractionSessionRegistry
{
private static readonly HashSet<IPlayerInteractionSession> Sessions = new();
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void ResetRegistry() => Sessions.Clear();
public static void Register(IPlayerInteractionSession session)
{
if (session != null)
Sessions.Add(session);
}
public static void Unregister(IPlayerInteractionSession session)
{
if (session != null)
Sessions.Remove(session);
}
public static bool TryGetControlledSession(
ulong clientId,
out IPlayerInteractionSession session)
{
foreach (IPlayerInteractionSession candidate in Sessions)
{
if (candidate != null && candidate.IsControlledBy(clientId))
{
session = candidate;
return true;
}
}
session = null;
return false;
}
}