Enemy Loadout Generation
Modified zone generator to scale the radius and mass of a zone according to galaxy density Added loadout generator which procedurally generates ships and turrets Generating 3 randomized ships in each occupied zone Fixed DatabaseCache.GetAll for parent types Fixed wormhole traversal bug for returning to previous zone (ZoneRenderer subscriptions not being properly disposed)
This commit is contained in:
parent
c0494ee3d8
commit
ebde23a64d
25 changed files with 5421 additions and 148 deletions
|
|
@ -175,6 +175,50 @@ public class Shape
|
|||
);
|
||||
return shape;
|
||||
}
|
||||
|
||||
// TODO: Use the power of math to optimize this function!
|
||||
// Try to find a rotation and position with which a shape can be placed to fit within another shape
|
||||
public bool FitsWithin(Shape other, out ItemRotation rotation, out int2 position)
|
||||
{
|
||||
// Try every item orientation
|
||||
foreach(var rot in (ItemRotation[])Enum.GetValues(typeof(ItemRotation)))
|
||||
{
|
||||
rotation = rot;
|
||||
if (FitsWithin(other, rot, out var pos))
|
||||
{
|
||||
position = pos;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
rotation = ItemRotation.None;
|
||||
position = int2.zero;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Try to find a position with which a shape can be placed to fit within another shape
|
||||
public bool FitsWithin(Shape other, ItemRotation rotation, out int2 position)
|
||||
{
|
||||
// Try every item position that could possibly fit
|
||||
for(int x = 0; x < other.Width - Width + 1; x++)
|
||||
{
|
||||
for (int y = 0; y < other.Height - Height + 1; y++)
|
||||
{
|
||||
position = int2(x, y);
|
||||
var fits = true;
|
||||
foreach (var v in Coordinates)
|
||||
{
|
||||
fits = fits && other[Rotate(v, rotation) + position];
|
||||
if (!fits) break;
|
||||
}
|
||||
|
||||
if (fits) return true;
|
||||
}
|
||||
}
|
||||
|
||||
position = int2.zero;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[MessagePackObject,
|
||||
|
|
|
|||
Loading…
Reference in a new issue