JSON fixes. Grids

This commit is contained in:
Matt Thorson
2020-05-17 16:27:02 -07:00
parent 3f8b016d84
commit 5745029fcc
8 changed files with 288 additions and 4 deletions

View File

@ -301,6 +301,26 @@ namespace Strawberry
return SceneHitbox.Intersects(rect);
}
public bool Check(Scene scene)
{
return scene.SolidGrid != null && Check(scene.SolidGrid);
}
public bool Check(Scene scene, Point offset)
{
return scene.SolidGrid != null && Check(scene.SolidGrid, offset);
}
public bool Check(Grid grid)
{
return grid.Check(SceneHitbox);
}
public bool Check(Grid grid, Point offset)
{
return grid.Check(SceneHitbox + offset);
}
public bool Check(Entity other)
{
return other.Collidable && SceneHitbox.Intersects(other.SceneHitbox);

View File

@ -6,6 +6,7 @@ namespace Strawberry
public class Scene
{
public float TimeStarted { get; private set; }
public Grid SolidGrid;
private List<Entity> entities;
private HashSet<Entity> toRemove;
@ -20,6 +21,9 @@ namespace Strawberry
public ~this()
{
if (SolidGrid != null)
delete SolidGrid;
for (var e in entities)
if (e.DeleteOnRemove)
delete e;