Files
riversong-code-showcase/Source/Riversong/Game/UI/Panels/Demo/DemoPanelUIController.cs
2026-05-21 16:04:49 +02:00

45 lines
1.2 KiB
C#

using System;
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace DanieleMarotta.RiversongCodeShowcase
{
public class DemoPanelUIController : UIControllerSystem<DemoPanelUIView>, IDisposable
{
[InjectService]
private ISignalBus _signalBus;
[InjectService]
private World _world;
public DemoPanelUIController(IServiceLocator serviceLocator) : base(serviceLocator)
{
}
protected override DemoPanelUIView View => UIRoot.GetView<DemoPanelUIView>();
public override async UniTask InitializeAsync()
{
await base.InitializeAsync();
View.FeedbackButtonClick += OnFeedbackButtonClick;
_signalBus.Subscribe<DemoCompletedSignal>(OnDemoCompleted);
}
public void Dispose()
{
View.FeedbackButtonClick -= OnFeedbackButtonClick;
_signalBus.Unsubscribe<DemoCompletedSignal>(OnDemoCompleted);
}
private void OnDemoCompleted(DemoCompletedSignal signal)
{
View.OnDemoCompleted(_world.PopulationState.Population, signal.GameTime);
}
private void OnFeedbackButtonClick()
{
Application.OpenURL(AppLinks.DemoFeedbackUrl);
}
}
}