moved tick to process from physics process

fixed fall speed
improved naming
This commit is contained in:
2025-05-01 22:46:51 +02:00
parent 4462573267
commit ea34b8ecc0
3 changed files with 15 additions and 8 deletions

View File

@@ -88,13 +88,13 @@ public class Element{
else if (Chunk.IsEmpty(Position + randomDirection * VERTICAL_OPPOSITE))
Chunk.Swap(this, Position + randomDirection * VERTICAL_OPPOSITE);
if (GD.Randi() % MAX_DIFFUSE_SPEED > DiffuseSpeed) return; // descend slower
if (Chunk.Get(Position + randomDirection)?.Density < Density)
// density check
if (Chunk.Get(Position + Vector2I.Down)?.Density < Density)
Chunk.Swap(this, Position + Vector2I.Down);
else if (Chunk.Get(Position + Vector2I.Down + randomDirection)?.Density < Density)
Chunk.Swap(this, Position + Vector2I.Down);
}
/// <returns>-1, 0 or 1</returns>
protected Vector2I RandomDirectionDown() {
int randomDirection = GD.Randi() % 2 != 0 ? 1 : -1;
@@ -102,6 +102,13 @@ public class Element{
+ (GD.Randi() % 2 != 0 ? Vector2I.Zero : Vector2I.Right * randomDirection);
}
/// <returns>-1, 0 or 1</returns>
protected Vector2I RandomDirection() {
int randomDirection = GD.Randi() % 2 != 0 ? 1 : -1;
return (GD.Randi() % 2 != 0 ? Vector2I.Zero : Vector2I.Right * randomDirection);
}
protected Color AddColorVariance(Color baseColor) {
Color c = baseColor;
c.R += (GD.Randf() - 1) * MAX_COLOR_VARIANCE;
@@ -128,7 +135,7 @@ public class Element{
MarkForUpdate();
}
public bool MarkedForUpdate() {
public bool IsMarkedForUpdate() {
return markedForUpdate;
}