Skip to content

Commit

Permalink
Merge pull request #2820 from CombatExtended-Continued/RandomBoundsFix
Browse files Browse the repository at this point in the history
Average of Graphics_Collection
  • Loading branch information
N7Huntsman authored Oct 20, 2023
2 parents 186f7dd + 5200aa5 commit 19fcdb4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Source/CombatExtended/CombatExtended/BoundsInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,17 @@ private static Vector2 ExtractBounds(Graphic graphic, GraphicType type, Graphic
(float)(hBounds.max - hBounds.min) / (float)hWidth,
(float)(vBounds.max - vBounds.min) / (float)vHeight);
}

private static Vector2 ExctractBoundCollection(Graphic_Collection graphic, GraphicType type)
{
IEnumerable<Vector2> bounds = graphic.subGraphics.Select(x => ExtractBounds(x, type));
return new Vector2(bounds.Average(v => v.x), bounds.Average(v => v.y));
}
private static Vector2 ExtractBounds(Graphic graphic, GraphicType type)
{
if (graphic is Graphic_Collection graphic_collection)
{
return ExctractBoundCollection(graphic_collection, type);
}
int vWidth;
int vHeight;

Expand Down

0 comments on commit 19fcdb4

Please sign in to comment.