Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CI09 committed Feb 12, 2025
1 parent 80a7e8c commit 330293e
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/microbe_stage/editor/PatchMapDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,12 @@ private void RebuildMap()
AddPatchNode(entry.Value, entry.Value.ScreenCoordinates);
}

// Hide excess cached indicators
for (var i = nextIndicatorIndex; i < playerSpeciesPopulationIndicators.Count - 1; i++)
{
playerSpeciesPopulationIndicators[i].Hide();
}

bool runNodeSelectionsUpdate = true;

if (SelectedPatch != null)
Expand Down Expand Up @@ -1136,19 +1142,9 @@ private void AddPlayerPopulationIndicators(Patch patch, Species playerSpecies, C
var playerPopulationIndicatorAmount = (int)Math.Ceiling(patch.GetSpeciesSimulationPopulation(playerSpecies) *
Constants.PLAYER_POPULATION_INDICATORS_PER_POPULATION);

var indicatorExcess = Math.Clamp(playerSpeciesPopulationIndicators.Count - playerPopulationIndicatorAmount,
0,
playerSpeciesPopulationIndicators.Count);

// Hide excess from the end of the list
for (int i = 0; i < indicatorExcess; ++i)
for (int i = 0; i < playerPopulationIndicatorAmount; ++i)
{
playerSpeciesPopulationIndicators[playerSpeciesPopulationIndicators.Count - i].Hide();
}

for (int i = nextIndicatorIndex; i < playerPopulationIndicatorAmount; ++i)
{
var noCached = i >= playerSpeciesPopulationIndicators.Count;
var noCached = nextIndicatorIndex >= playerSpeciesPopulationIndicators.Count;

Control indicator;
if (noCached)
Expand All @@ -1166,17 +1162,19 @@ private void AddPlayerPopulationIndicators(Patch patch, Species playerSpecies, C
}
else
{
indicator = playerSpeciesPopulationIndicators[i];
indicator = playerSpeciesPopulationIndicators[nextIndicatorIndex];

indicator.Show();
}

var nodeModifier = node.Position.LengthSquared();
var modifierSinus = MathF.Sin(i);

indicator.Position = position + node.Size * 0.5f + new Vector2(0, 35)
indicator.Position = position + node.Size * 0.5f + new Vector2(0, 40)
.Rotated(nodeModifier * 30) +
new Vector2(0, modifierSinus * 50).Rotated(i * 6 * modifierSinus + nodeModifier);
new Vector2(0, modifierSinus * 40).Rotated(i * 6 * modifierSinus + nodeModifier);

++nextIndicatorIndex;
}
}

Expand Down

1 comment on commit 330293e

@hhyyrylainen
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (var i = nextIndicatorIndex; i < playerSpeciesPopulationIndicators.Count - 1; i++) why is there a -1 on that line? Isn't that a bug as i < Count is the way to loop until the last item, and so if you subtract one then it goes to the second last item only...

Please sign in to comment.