r2mods/ilspy_dump/ror2_csproj/RoR2/CreditsController.cs

54 lines
1.3 KiB
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using RoR2.UI;
using UnityEngine;
namespace RoR2;
[RequireComponent(typeof(VoteController))]
public class CreditsController : MonoBehaviour
{
private CreditsPanelController creditsPanelController;
private VoteController voteController;
private static GameObject creditsPanelPrefab => LegacyResourcesAPI.Load<GameObject>("Prefabs/UI/Credits/CreditsPanel");
private void Awake()
{
voteController = GetComponent<VoteController>();
}
private void OnEnable()
{
creditsPanelController = Object.Instantiate(creditsPanelPrefab, RoR2Application.instance.mainCanvas.transform).GetComponent<CreditsPanelController>();
creditsPanelController.voteInfoPanel.voteController = voteController;
creditsPanelController.skipButton.onClick.AddListener(SubmitLocalVotesToEnd);
PauseManager.IsAbleToPause = false;
}
private void OnDisable()
{
PauseManager.IsAbleToPause = true;
if ((bool)creditsPanelController)
{
Object.Destroy(creditsPanelController.gameObject);
}
}
private void Update()
{
if (!creditsPanelController)
{
SubmitLocalVotesToEnd();
base.enabled = false;
}
}
private void SubmitLocalVotesToEnd()
{
foreach (NetworkUser readOnlyLocalPlayers in NetworkUser.readOnlyLocalPlayersList)
{
readOnlyLocalPlayers.CallCmdSubmitVote(base.gameObject, 0);
}
}
}