Player/Economy/AccountIncome.cs
using System;

namespace PlanetMeat;

[Group( "Planet Meat - Player" ), Title( "Account Income" ), Icon( "trending_up" )]
public sealed class AccountIncome : Component, IAgendaPhaseListener
{
	[Property] private string AccountIdent { get; set; } = "";
	[Property] private string RateImprovment { get; set; } = "";
	[Property] private string CapImprovement { get; set; } = "";
	[Property] private string IncomeImprovement { get; set; } = "";

	public ValueAggregator<float> AggregateRate => field ??= ValueAggregator<float>.FromImprovement( RateImprovment );
	public ValueAggregator<double> AggregateCap => field ??= ValueAggregator<double>.FromImprovement( CapImprovement );
	public ValueAggregator<int> AggregateIncome => field ??= ValueAggregator<int>.FromImprovement( IncomeImprovement );

	public void OnTimelinePhase( Agenda.Phases prev, Agenda.Phases current )
	{
		if ( current == Agenda.Phases.Upgrade && current != prev && Bank.Current.GetAccount( AccountIdent ) is Bank.Account account )
		{
			account.Profit( AggregateIncome.Total );
			account.Profit( Math.Min( AggregateCap.Total, account.Funds ).MultiplyCapped( AggregateRate.Total ) );
		}
	}
}