fixed inactive elements when spawning with brush
This commit is contained in:
@@ -13,7 +13,7 @@ public class Element {
|
||||
|
||||
public int DiffuseSpeed = 10;
|
||||
public const int MAX_DIFFUSE_SPEED = 100;
|
||||
public const int STEPS_UNTIL_INACTIVE = 100;
|
||||
public const int STEPS_UNTIL_INACTIVE = 500;
|
||||
|
||||
protected const float MAX_COLOR_VARIANCE = 0.1f;
|
||||
protected static readonly Vector2I VERTICAL_OPPOSITE = new Vector2I(-1, 1);
|
||||
@@ -24,12 +24,14 @@ public class Element {
|
||||
public Element(Element e) {
|
||||
Position = e.Position;
|
||||
Chunk = e.Chunk;
|
||||
LastMove = Engine.GetFramesDrawn();
|
||||
}
|
||||
|
||||
public Element(int x, int y, Chunk chunk) {
|
||||
Position.X = x;
|
||||
Position.Y = y;
|
||||
Chunk = chunk;
|
||||
LastMove = Engine.GetFramesDrawn();
|
||||
}
|
||||
|
||||
public bool Active {
|
||||
@@ -49,11 +51,11 @@ public class Element {
|
||||
/// </summary>
|
||||
/// <param name="currentFrame"></param>
|
||||
/// <returns>false if there is nothing to do</returns>
|
||||
public virtual bool Update(int currentFrame) {
|
||||
public virtual bool Update() {
|
||||
if (!Active) return false;
|
||||
|
||||
if (LastUpdate == currentFrame) return false; // already updated this frame
|
||||
LastUpdate = currentFrame;
|
||||
if (LastUpdate == Engine.GetFramesDrawn()) return false; // already updated this frame
|
||||
LastUpdate = Engine.GetFramesDrawn();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ public abstract class Liquid : Element {
|
||||
|
||||
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;
|
||||
if (LastMove + STEPS_UNTIL_INACTIVE < currentFrame) Active = false;
|
||||
public override bool Update() {
|
||||
if (!base.Update()) return false;
|
||||
if (LastMove + STEPS_UNTIL_INACTIVE < Engine.GetFramesDrawn()) Active = false;
|
||||
|
||||
Tick();
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace FOU.Scripts.Elements;
|
||||
public abstract class Solid : Element {
|
||||
protected Solid(int x, int y, ref Chunk chunk) : base(x, y, chunk) { }
|
||||
|
||||
public override bool Update(int currentFrame) {
|
||||
if (!base.Update(currentFrame)) return false;
|
||||
if (LastMove + STEPS_UNTIL_INACTIVE < currentFrame) Active = false;
|
||||
public override bool Update() {
|
||||
if (!base.Update()) return false;
|
||||
if (LastMove + STEPS_UNTIL_INACTIVE < Engine.GetFramesDrawn()) Active = false;
|
||||
|
||||
Tick();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user