riversong code showcase
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace DanieleMarotta.RiversongCodeShowcase
|
||||
{
|
||||
public class PopulationPanelUIController : UIControllerSystem<PopulationPanelUIView>, IUpdatable
|
||||
{
|
||||
[InjectService]
|
||||
private World _world;
|
||||
|
||||
private PopulationPanelModel _model;
|
||||
|
||||
public PopulationPanelUIController(IServiceLocator serviceLocator) : base(serviceLocator)
|
||||
{
|
||||
}
|
||||
|
||||
protected override PopulationPanelUIView View => UIRoot.GetView<PopulationPanelUIView>();
|
||||
|
||||
public override async UniTask InitializeAsync()
|
||||
{
|
||||
await base.InitializeAsync();
|
||||
|
||||
_model = new PopulationPanelModel();
|
||||
View.SetModel(_model);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
var population = _world.PopulationState.Population;
|
||||
var happiness = math.clamp((int)math.round(_world.PopulationState.Happiness * 100), 0, 100);
|
||||
_model.Update(population, happiness, _world.ProductionState.LaborTier);
|
||||
|
||||
View.UpdateHappinessIconAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user