2020-05-05 11:50:38 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
|
|
|
|
namespace Strawberry
|
|
|
|
{
|
2020-05-06 08:43:33 +08:00
|
|
|
public abstract class Geometry : Entity
|
2020-05-05 11:50:38 +08:00
|
|
|
{
|
|
|
|
private Vector remainder;
|
|
|
|
|
|
|
|
public this(int x, int y)
|
|
|
|
: base(x, y)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-06 08:43:33 +08:00
|
|
|
public void MoveX(float amount)
|
2020-05-05 11:50:38 +08:00
|
|
|
{
|
|
|
|
remainder.X += amount;
|
|
|
|
let move = (int)Math.Round(remainder.X);
|
|
|
|
if (move != 0)
|
|
|
|
{
|
|
|
|
remainder.X -= move;
|
2020-05-06 08:43:33 +08:00
|
|
|
MoveExactX(move);
|
2020-05-05 11:50:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-06 08:43:33 +08:00
|
|
|
public void MoveY(float amount)
|
2020-05-05 11:50:38 +08:00
|
|
|
{
|
|
|
|
remainder.Y += amount;
|
|
|
|
let move = (int)Math.Round(remainder.Y);
|
|
|
|
if (move != 0)
|
|
|
|
{
|
|
|
|
remainder.Y -= move;
|
2020-05-06 08:43:33 +08:00
|
|
|
MoveExactY(move);
|
2020-05-05 11:50:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-06 08:43:33 +08:00
|
|
|
public abstract void MoveExactX(int amount);
|
|
|
|
public abstract void MoveExactY(int amount);
|
2020-05-05 11:50:38 +08:00
|
|
|
public abstract List<Actor> GetRiders(List<Actor> into);
|
|
|
|
|
|
|
|
public void ZeroRemainderX()
|
|
|
|
{
|
|
|
|
remainder.X = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ZeroRemainderY()
|
|
|
|
{
|
|
|
|
remainder.Y = 0;
|
|
|
|
}
|
|
|
|
|
2020-05-06 08:43:33 +08:00
|
|
|
public void ZeroRemainders()
|
2020-05-05 11:50:38 +08:00
|
|
|
{
|
|
|
|
remainder = Vector.Zero;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|