Add prototype gameplay loop with character/battlefield assets and server game APIs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
udx
2026-10-20 18:50:00 +08:00
co-authored by Cursor
parent 79369e4473
commit 6c64210331
833 changed files with 998079 additions and 1042 deletions
@@ -0,0 +1,69 @@
using UnityEngine;
namespace HotUpdate.Gameplay
{
/// <summary>Playback for the authored main-menu music prefab, independent of SFX.</summary>
public sealed class MainMenuMusic : MonoBehaviour
{
public const string PrefabName = "MainMenuMusic";
public const string PrefabFolder = "Assets/Bundles/Sound/Prefab";
[SerializeField] AudioSource _source;
bool _inMenu = true, _appPaused, _started, _began, _paused;
public AudioSource Source => _source;
void OnEnable()
{
PrototypeClientPrefs.AudioPreferencesChanged += ApplyPlayback;
ApplyPlayback();
}
void Start()
{
_started = true;
ApplyPlayback();
}
public void SetInMenu(bool inMenu)
{
_inMenu = inMenu;
ApplyPlayback();
}
void ApplyPlayback()
{
if (!_started || _source == null) return;
if (isActiveAndEnabled && _inMenu && !_appPaused && PrototypeClientPrefs.Music)
{
if (!_began)
{
_source.Play();
_began = true;
}
else if (_paused) _source.UnPause();
_paused = false;
}
else if (_began && !_paused)
{
_source.Pause();
_paused = true;
}
}
void OnApplicationPause(bool paused)
{
_appPaused = paused;
ApplyPlayback();
}
void OnDisable()
{
PrototypeClientPrefs.AudioPreferencesChanged -= ApplyPlayback;
if (_source != null && _began && !_paused)
{
_source.Pause();
_paused = true;
}
}
}
}