using Godot; namespace FOU.Scripts.Elements; public class Element { public Color Color = Colors.Black; public Vector2I Position; protected Level _level; private int _lastUpdate = -1; public Element(int x, int y, ref Level level) { Position.X = x; Position.Y = y; _level = level; } /// /// base update method, checks if anything is to do at all /// /// /// false if there is nothing to do public virtual bool Update(int currentFrame) { if (_lastUpdate == currentFrame) return false; // already updated this frame _lastUpdate = currentFrame; return true; } public override string ToString() { return $"{GetType()} {Position}"; } // 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; // } /// /// Checks from source to maxDirection (also X-mirrored) and returns a free position /// /// from where to check /// where to go to (max). X is treated as [-X..X] /// free position or V2.zero if nothing was found protected virtual Vector2I Check(Element source, Vector2I maxDirection) { return Vector2I.Zero; }}