fixed activate not set on copy

This commit is contained in:
2025-05-01 23:06:46 +02:00
parent e653f23a42
commit c41cdd57c4

View File

@@ -13,8 +13,8 @@ public class Element{
protected const int MAX_DIFFUSE_SPEED = 100; protected const int MAX_DIFFUSE_SPEED = 100;
protected const int STEPS_UNTIL_INACTIVE = 500; protected const int STEPS_UNTIL_INACTIVE = 500;
protected const float MAX_COLOR_VARIANCE = 0.1f;
protected static readonly Vector2I VERTICAL_OPPOSITE = new Vector2I(-1, 1); protected static readonly Vector2I VERTICAL_OPPOSITE = new Vector2I(-1, 1);
private const float MAX_COLOR_VARIANCE = 0.1f;
private bool active = false; private bool active = false;
private int lastUpdate = -1; private int lastUpdate = -1;
@@ -32,7 +32,7 @@ public class Element{
Position.X = x; Position.X = x;
Position.Y = y; Position.Y = y;
Chunk = chunk; Chunk = chunk;
Active = true; Active = active;
} }
public bool Active { public bool Active {
@@ -79,6 +79,9 @@ public class Element{
protected virtual void Tick() { protected virtual void Tick() {
Vector2I randomDirection = RandomDirectionDown(); Vector2I randomDirection = RandomDirectionDown();
// fall speed reduction:
if (GD.Randi() % MAX_DIFFUSE_SPEED > DiffuseSpeed) return; // descend slower
if (Chunk.IsEmpty(Position + Vector2I.Down)) if (Chunk.IsEmpty(Position + Vector2I.Down))
Chunk.Swap(this, Position + Vector2I.Down); Chunk.Swap(this, Position + Vector2I.Down);