Auto formatting
This commit is contained in:
@@ -19,7 +19,8 @@
|
||||
<FormDisplayComponent Label="Army units built">
|
||||
<Display>
|
||||
<div class="armyCardsContainer">
|
||||
@foreach (var unit in armyCount) {
|
||||
@foreach (var unit in armyCount)
|
||||
{
|
||||
<div class="armyCard">
|
||||
<div class="armyCountPosition">
|
||||
<div class="armyCount">@unit.Value.ToString()x</div>
|
||||
@@ -72,33 +73,39 @@
|
||||
|
||||
List<EntityModel> army = new();
|
||||
|
||||
protected override void OnInitialized() {
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
buildOrder.Subscribe(OnBuildOrderChanged);
|
||||
timingService.Subscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose() {
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
buildOrder.Unsubscribe(OnBuildOrderChanged);
|
||||
timingService.Unsubscribe(StateHasChanged);
|
||||
}
|
||||
|
||||
protected override bool ShouldRender() {
|
||||
protected override bool ShouldRender()
|
||||
{
|
||||
#if DEBUG
|
||||
jsRuntime.InvokeVoidAsync("console.time", "ArmyComponent");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnAfterRender(bool firstRender) {
|
||||
protected override void OnAfterRender(bool firstRender)
|
||||
{
|
||||
#if DEBUG
|
||||
jsRuntime.InvokeVoidAsync("console.timeEnd", "ArmyComponent");
|
||||
#endif
|
||||
}
|
||||
|
||||
void OnBuildOrderChanged() {
|
||||
void OnBuildOrderChanged()
|
||||
{
|
||||
var armyCountWas = 0;
|
||||
foreach (var army in armyCount) {
|
||||
foreach (var army in armyCount)
|
||||
{
|
||||
armyCountWas += army.Value;
|
||||
}
|
||||
|
||||
@@ -108,14 +115,19 @@
|
||||
|
||||
var entitiesOverTime = buildOrder.GetOrders();
|
||||
|
||||
foreach (var entitiesAtTime in entitiesOverTime) {
|
||||
foreach (var entity in entitiesAtTime.Value) {
|
||||
if (entity.EntityType == EntityType.Army) {
|
||||
if (!armyCount.TryAdd(entity.Info().Name, 1)) {
|
||||
foreach (var entitiesAtTime in entitiesOverTime)
|
||||
{
|
||||
foreach (var entity in entitiesAtTime.Value)
|
||||
{
|
||||
if (entity.EntityType == EntityType.Army)
|
||||
{
|
||||
if (!armyCount.TryAdd(entity.Info().Name, 1))
|
||||
{
|
||||
armyCount[entity.Info().Name]++;
|
||||
}
|
||||
|
||||
if (entity.Production() != null && entity.Production().BuildTime + entitiesAtTime.Key > lastInterval) {
|
||||
if (entity.Production() != null && entity.Production().BuildTime + entitiesAtTime.Key > lastInterval)
|
||||
{
|
||||
lastInterval = entity.Production().BuildTime + entitiesAtTime.Key;
|
||||
}
|
||||
}
|
||||
@@ -124,12 +136,14 @@
|
||||
|
||||
//TODO Better
|
||||
var armyCountIs = 0;
|
||||
foreach (var army in armyCount) {
|
||||
foreach (var army in armyCount)
|
||||
{
|
||||
armyCountIs += army.Value;
|
||||
}
|
||||
|
||||
|
||||
if (armyCountWas != armyCountIs) {
|
||||
if (armyCountWas != armyCountIs)
|
||||
{
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user