added second element type: snow
added simple snow weather
This commit is contained in:
@@ -3,24 +3,29 @@
|
||||
namespace FOU.Scripts.Elements;
|
||||
|
||||
public abstract class Liquid : Element {
|
||||
protected Liquid(int x, int y, ref Level level) : base(x, y, ref level) { }
|
||||
protected Liquid(int x, int y, ref Level level) : base(x, y, level) { }
|
||||
|
||||
|
||||
// TODO: rework this!
|
||||
protected override Vector2I Check(Element source, Vector2I maxDirection) {
|
||||
if (GD.Randi() % 2 != 0)
|
||||
maxDirection.X *= -1;
|
||||
|
||||
Vector2I freePos = Vector2I.Zero;
|
||||
for (int y = 0; y <= maxDirection.Y; y++) { // height
|
||||
for (int y = maxDirection.Y; y > 0; y--) { // height
|
||||
if (source.Position.Y + y >= Level.SizeY) return freePos; // bounds check
|
||||
|
||||
// check if we can further
|
||||
if (Level.Get(source.Position.X, source.Position.Y + y).GetType() == typeof(Element)) {
|
||||
freePos = new Vector2I(source.Position.X, source.Position.Y + y);
|
||||
} else {
|
||||
freePos = Vector2I.Zero;
|
||||
}
|
||||
|
||||
for (int x = -maxDirection.X; x <= maxDirection.X; x++) { // width
|
||||
if (freePos != Vector2I.Zero) break;
|
||||
|
||||
if (source.Position.X + x >= Level.SizeX || source.Position.X + x < 0) return freePos; // bounds check
|
||||
if (source.Position.X + x >= Level.SizeX || source.Position.X + x < 0) continue; // bounds check
|
||||
|
||||
if (Level.Get(source.Position.X + x, source.Position.Y + y).GetType() == typeof(Element)) {
|
||||
freePos = new Vector2I(source.Position.X + x, source.Position.Y + y);
|
||||
|
||||
Reference in New Issue
Block a user