Files
Ultimate-Fishing-Simulator-…/Assets/Scripts/Assembly-CSharp/UI_ContinueGame.cs
2026-03-04 09:37:33 +08:00

58 lines
1.2 KiB
C#

using System.Linq;
using Michsky.UI.Heat;
using Obvious.Soap;
using UnityEngine;
public class UI_ContinueGame : MonoBehaviour
{
public PlayerProfile PlayerProfile;
public BoolVariable IsInGameMainMenuEnabled;
private void Start()
{
Refresh();
}
private void OnEnable()
{
PlayerProfile.OnLoadData += Refresh;
PlayerProfile.OnProfileCreated += Refresh;
}
private void OnDisable()
{
PlayerProfile.OnLoadData -= Refresh;
PlayerProfile.OnProfileCreated -= Refresh;
}
private void Refresh()
{
BoxButtonManager component = GetComponent<BoxButtonManager>();
if ((bool)component)
{
component.Interactable(!string.IsNullOrEmpty(PlayerProfile.LastLoadedChapterID) || IsInGameMainMenuEnabled.Value);
}
}
public void OnButtonClick()
{
if (IsInGameMainMenuEnabled.Value)
{
IsInGameMainMenuEnabled.Value = false;
}
else
{
if (string.IsNullOrEmpty(PlayerProfile.LastLoadedChapterID))
{
return;
}
ChapterManager chapterManager = Object.FindFirstObjectByType<ChapterManager>(FindObjectsInactive.Include);
if ((bool)chapterManager)
{
chapterManager.chapters.FirstOrDefault((ChapterManager.ChapterItem c) => c.chapterID == PlayerProfile.LastLoadedChapterID)?.onPlay?.Invoke();
}
}
}
}