finalized dirt

added base for liquids
This commit is contained in:
2023-10-17 14:29:42 +02:00
parent 9145a6a3f9
commit 31dbbbf070
6 changed files with 113 additions and 29 deletions

View File

@@ -5,16 +5,15 @@ namespace FOU.Scripts.Elements;
public class Element {
public Color Color = Colors.Black;
public int X;
public int Y;
public Vector2I Position;
protected Level _level;
private int _lastUpdate = -1;
public Element(int x, int y, ref Level level) {
X = x;
Y = y;
Position.X = x;
Position.Y = y;
_level = level;
}
@@ -31,15 +30,25 @@ public class Element {
}
public override string ToString() {
return $"{GetType()} {X}:{Y}";
return $"{GetType()} {Position}";
}
protected bool CheckBelow(int x, int y) {
if (y+1 >= _level.SizeY) return false;
// OBSOLETE:
// protected bool CheckBelow(int sourceX, int sourceY) {
// if (sourceY+1 >= _level.SizeY) return false;
//
// if (_level.Get(sourceX, sourceY+1).GetType() == GetType())
// return false;
//
// return true;
// }
if (_level.Get(x, y+1).GetType() == GetType())
return false;
return true;
}
}
/// <summary>
/// Checks from source to maxDirection (also X-mirrored) and returns a free position
/// </summary>
/// <param name="source">from where to check</param>
/// <param name="maxDirection">where to go to (max). X is treated as [-X..X]</param>
/// <returns>free position or V2.zero if nothing was found</returns>
protected virtual Vector2I Check(Element source, Vector2I maxDirection) {
return Vector2I.Zero;
}}