added chunks
This commit is contained in:
@@ -5,7 +5,7 @@ namespace FOU.Scripts.Elements;
|
||||
public abstract class Liquid : Element {
|
||||
public const int MAX_VERTICAL_SPREAD = 3;
|
||||
|
||||
protected Liquid(int x, int y, ref Level level) : base(x, y, level) { }
|
||||
protected Liquid(int x, int y, ref Chunk chunk) : base(x, y, chunk) { }
|
||||
|
||||
public override bool Update(int currentFrame) {
|
||||
if (!base.Update(currentFrame)) return false;
|
||||
@@ -21,13 +21,13 @@ public abstract class Liquid : Element {
|
||||
if (randomDirection.Y != 0)
|
||||
randomDirection *= Vector2I.Left * (int)(GD.Randi() % MAX_VERTICAL_SPREAD);
|
||||
|
||||
if (Level.IsEmpty(Position + Vector2I.Down))
|
||||
Level.Swap(this, Position + Vector2I.Down);
|
||||
if (Chunk.IsEmpty(Position + Vector2I.Down))
|
||||
Chunk.Swap(this, Position + Vector2I.Down);
|
||||
|
||||
else if (Level.IsEmpty(Position + randomDirection))
|
||||
Level.Swap(this, Position + Vector2I.Right * randomDirection);
|
||||
else if (Chunk.IsEmpty(Position + randomDirection))
|
||||
Chunk.Swap(this, Position + Vector2I.Right * randomDirection);
|
||||
|
||||
else if (Level.IsEmpty(Position + randomDirection))
|
||||
Level.Swap(this, Position + Vector2I.Right * randomDirection * VERTICAL_OPPOSITE);
|
||||
else if (Chunk.IsEmpty(Position + randomDirection))
|
||||
Chunk.Swap(this, Position + Vector2I.Right * randomDirection * VERTICAL_OPPOSITE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user