mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2024-11-25 16:18:56 +08:00
Vector operators. Rect constructor. Scene condition getters
This commit is contained in:
parent
c5ae789804
commit
c546c69434
|
@ -166,6 +166,14 @@ namespace Strawberry
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool Check<T>(Point point, delegate bool(T) condition) where T : Component, IHasHitbox
|
||||
{
|
||||
for (T c in componentTracker[typeof(T)])
|
||||
if (c.Hitbox.Check(point) && condition(c))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Check<T>(Rect rect) where T : Component, IHasHitbox
|
||||
{
|
||||
for (T c in componentTracker[typeof(T)])
|
||||
|
@ -174,6 +182,14 @@ namespace Strawberry
|
|||
return false;
|
||||
}
|
||||
|
||||
public bool Check<T>(Rect rect, delegate bool(T) condition) where T : Component, IHasHitbox
|
||||
{
|
||||
for (T c in componentTracker[typeof(T)])
|
||||
if (c.Hitbox.Check(rect) && condition(c))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public T First<T>() where T : Component
|
||||
{
|
||||
for (T c in componentTracker[typeof(T)])
|
||||
|
|
|
@ -22,6 +22,14 @@ namespace Strawberry
|
|||
Height = height;
|
||||
}
|
||||
|
||||
public this(Point pos, int width, int height)
|
||||
{
|
||||
X = pos.X;
|
||||
Y = pos.Y;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public this(JSON json)
|
||||
: this(json["x"], json["y"], json["width"], json["height"])
|
||||
{
|
||||
|
|
|
@ -146,6 +146,18 @@ namespace Strawberry
|
|||
return .(a.X - b.X, a.Y - b.Y);
|
||||
}
|
||||
|
||||
[Inline, Commutable]
|
||||
static public Vector operator*(Vector a, int b)
|
||||
{
|
||||
return .(a.X * b, a.Y * b);
|
||||
}
|
||||
|
||||
[Inline, Commutable]
|
||||
static public Vector operator/(Vector a, int b)
|
||||
{
|
||||
return .(a.X / b, a.Y / b);
|
||||
}
|
||||
|
||||
[Inline, Commutable]
|
||||
static public Vector operator*(Vector a, float b)
|
||||
{
|
||||
|
@ -158,6 +170,12 @@ namespace Strawberry
|
|||
return .(a.X / b, a.Y / b);
|
||||
}
|
||||
|
||||
[Inline, Commutable]
|
||||
static public Vector operator*(Vector a, Facings f)
|
||||
{
|
||||
return .(a.X * (int)f, a.Y);
|
||||
}
|
||||
|
||||
[Inline]
|
||||
static public Vector operator*(Vector a, Mat3x2 b)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user