mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2025-07-06 20:45:26 +08:00
The sample game works again!
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
|
||||
namespace Strawberry.Sample
|
||||
{
|
||||
@ -6,9 +7,54 @@ namespace Strawberry.Sample
|
||||
{
|
||||
public Hitbox Hitbox { get; private set; }
|
||||
|
||||
private Vector remainder;
|
||||
|
||||
public Vector ExactPosition => Entity.Position + remainder;
|
||||
|
||||
public this(Hitbox hitbox)
|
||||
{
|
||||
Hitbox = hitbox;
|
||||
}
|
||||
|
||||
public void FindRiders(List<Actor> into)
|
||||
{
|
||||
for (let a in Scene.All<Actor>(scope .()))
|
||||
if (a.IsRiding(this))
|
||||
into.Add(a);
|
||||
}
|
||||
|
||||
public void Move(Vector amount)
|
||||
{
|
||||
remainder += amount;
|
||||
Point move = remainder.Round();
|
||||
MoveExact(move);
|
||||
}
|
||||
|
||||
public void MoveTo(Vector pos)
|
||||
{
|
||||
Move(pos - ExactPosition);
|
||||
}
|
||||
|
||||
public void MoveExact(Point amount)
|
||||
{
|
||||
if (amount != .Zero)
|
||||
{
|
||||
if (Hitbox.Collidable)
|
||||
{
|
||||
List<Actor> riders = FindRiders(..scope .());
|
||||
Hitbox.Collidable = false;
|
||||
|
||||
for (let r in riders)
|
||||
{
|
||||
r.MoveExactX(amount.X);
|
||||
r.MoveExactY(amount.Y);
|
||||
}
|
||||
|
||||
Hitbox.Collidable = true;
|
||||
}
|
||||
|
||||
Entity.Position += amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,15 @@ namespace Strawberry.Sample
|
||||
{
|
||||
public Hitbox Hitbox { get; private set; }
|
||||
|
||||
private Vector remainder;
|
||||
|
||||
public Vector ExactPosition => Entity.Position + remainder;
|
||||
|
||||
public this(Hitbox hitbox)
|
||||
{
|
||||
Hitbox = hitbox;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user