mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2025-07-06 20:45:26 +08:00
Tracker fixes and debug methods. ComponentInterfaceAttribute removed, interface use is auto-detected. Scene actually calls update and draw methods
This commit is contained in:
@ -8,6 +8,16 @@ namespace Strawberry
|
||||
public bool Collidable = true;
|
||||
public Rect Rect;
|
||||
|
||||
public this(Rect rect)
|
||||
{
|
||||
Rect = rect;
|
||||
}
|
||||
|
||||
public this(int x, int y, int width, int height)
|
||||
{
|
||||
Rect = .(x, y, width, height);
|
||||
}
|
||||
|
||||
public void DebugDraw()
|
||||
{
|
||||
Game.Batcher.Rect(SceneHitbox, .Red);
|
||||
@ -116,52 +126,62 @@ namespace Strawberry
|
||||
Single Collisions
|
||||
*/
|
||||
|
||||
[Inline]
|
||||
public bool Check(Point point)
|
||||
{
|
||||
return SceneHitbox.Contains(point);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public bool Check(Rect rect)
|
||||
{
|
||||
return SceneHitbox.Intersects(rect);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public bool Check(Grid grid)
|
||||
{
|
||||
return grid != null && grid.Check(SceneHitbox);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public bool Check(Grid grid, Point offset)
|
||||
{
|
||||
return grid != null && grid.Check(SceneHitbox + offset);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public bool Check(Hitbox other)
|
||||
{
|
||||
return other.Collidable && SceneHitbox.Intersects(other.SceneHitbox);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public bool Check(Hitbox other, Point offset)
|
||||
{
|
||||
return other.Collidable && (SceneHitbox + offset).Intersects(other.SceneHitbox);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
public bool CheckOutside(Hitbox other, Point offset)
|
||||
{
|
||||
return other.Collidable && !SceneHitbox.Intersects(other.SceneHitbox) && (SceneHitbox + offset).Intersects(other.SceneHitbox);
|
||||
}
|
||||
|
||||
public bool Check<T>(T other) where T : Component, IHasHitbox
|
||||
[Inline]
|
||||
public bool Check(IHasHitbox other)
|
||||
{
|
||||
return Check(other.Hitbox);
|
||||
}
|
||||
|
||||
public bool Check<T>(T other, Point offset) where T : Component, IHasHitbox
|
||||
[Inline]
|
||||
public bool Check(IHasHitbox other, Point offset)
|
||||
{
|
||||
return Check(other.Hitbox, offset);
|
||||
}
|
||||
|
||||
public bool CheckOutside<T>(T other, Point offset) where T : Component, IHasHitbox
|
||||
[Inline]
|
||||
public bool CheckOutside(IHasHitbox other, Point offset)
|
||||
{
|
||||
return CheckOutside(other.Hitbox, offset);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
[ComponentInterface]
|
||||
public interface IDebugDraw
|
||||
{
|
||||
public void DebugDraw();
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
[ComponentInterface]
|
||||
public interface IDraw
|
||||
{
|
||||
public void Draw();
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
[ComponentInterface]
|
||||
public interface IHasHitbox
|
||||
{
|
||||
public Hitbox Hitbox { get; }
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
[ComponentInterface]
|
||||
public interface ILateUpdate
|
||||
{
|
||||
public void LateUpdate();
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
[ComponentInterface]
|
||||
public interface IUpdate
|
||||
{
|
||||
public void Update();
|
||||
|
Reference in New Issue
Block a user