Proper Entity and Component bucketing/tracking

This commit is contained in:
Matt Thorson
2020-05-21 21:24:04 -07:00
parent df00a1ec82
commit 0b1a938fe2
6 changed files with 180 additions and 14 deletions

View File

@ -1,3 +1,5 @@
using System;
namespace Strawberry
{
public enum Cardinals
@ -66,5 +68,33 @@ namespace Strawberry
return Point.Down;
}
}
static public Result<Cardinals> FromPoint(Point p)
{
if (p.X > 0 && p.Y == 0)
return .Right;
else if (p.X < 0 && p.Y == 0)
return .Left;
else if (p.Y < 0 && p.X == 0)
return .Up;
else if (p.Y > 0 && p.X == 0)
return .Down;
else
return .Err;
}
static public Result<Cardinals> FromVector(Vector v)
{
if (v.X > 0 && v.Y == 0)
return .Right;
else if (v.X < 0 && v.Y == 0)
return .Left;
else if (v.Y < 0 && v.X == 0)
return .Up;
else if (v.Y > 0 && v.X == 0)
return .Down;
else
return .Err;
}
}
}