Compare commits
3 Commits
9a36418d23
...
activate-n
| Author | SHA1 | Date | |
|---|---|---|---|
| 4220e94e38 | |||
| b0b5e95eda | |||
| 7458d5749c |
@@ -69,15 +69,16 @@ public class Chunk {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if not empty and overwrite not allowed:
|
||||
if (!Elements[x,y].IsEmpty() && !Main.Instance.AllowOverwrite)
|
||||
return;
|
||||
else if (!Elements[x,y].IsEmpty()) {
|
||||
Elements[x, y].Chunk.RemoveFromChunk(Elements[x, y]);
|
||||
}
|
||||
|
||||
Type type = typeof(T);
|
||||
object o = Activator.CreateInstance(type, x, y, this);
|
||||
|
||||
// check if not empty and overwrite not allowed:
|
||||
if (!Elements[x,y].IsEmpty() && !Main.Instance.AllowOverwrite) {
|
||||
return;
|
||||
}
|
||||
|
||||
Elements[x, y].Chunk.RemoveFromChunk(Elements[x, y]);
|
||||
Elements[x, y] = o as Element;
|
||||
Elements[x, y].Active = true;
|
||||
}
|
||||
@@ -158,9 +159,6 @@ public class Chunk {
|
||||
swapTo.Moved();
|
||||
if (swapTo.IsEmpty())
|
||||
swapTo.ActivateNeighbors();
|
||||
|
||||
// TODO:
|
||||
// if either "what" or "swapTo" is empty, re-activate all neighbors of the now empty ones
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Element{
|
||||
Chunk.SetElementActive(this, Active);
|
||||
}
|
||||
|
||||
public Element(int x, int y, Chunk chunk) {
|
||||
public Element(int x, int y, Chunk chunk, bool active = true) {
|
||||
Position.X = x;
|
||||
Position.Y = y;
|
||||
Chunk = chunk;
|
||||
|
||||
@@ -24,15 +24,21 @@ public abstract class Liquid : Element {
|
||||
|
||||
if (Chunk.IsEmpty(Position + Vector2I.Down))
|
||||
Chunk.Swap(this, Position + Vector2I.Down);
|
||||
|
||||
else if (Chunk.IsEmpty(Position + randomDirection))
|
||||
Chunk.Swap(this, Position + randomDirection);
|
||||
else if (Chunk.IsEmpty(Position + randomDirection * VERTICAL_OPPOSITE))
|
||||
Chunk.Swap(this, Position + randomDirection * VERTICAL_OPPOSITE);
|
||||
|
||||
else if (Chunk.IsEmpty(Position + randomDirection))
|
||||
Chunk.Swap(this, Position + Vector2I.Right + randomDirection);
|
||||
else if (Chunk.IsEmpty(Position - randomDirection))
|
||||
Chunk.Swap(this, Position + Vector2I.Right + randomDirection * VERTICAL_OPPOSITE);
|
||||
else if (Chunk.IsEmpty(Position + 1 * randomDirection))
|
||||
Chunk.Swap(this, Position + 1 * randomDirection);
|
||||
else if (Chunk.IsEmpty(Position - 1 * randomDirection * VERTICAL_OPPOSITE))
|
||||
Chunk.Swap(this, Position - 1 * randomDirection * VERTICAL_OPPOSITE);
|
||||
|
||||
else if (Chunk.IsEmpty(Position + 2 * randomDirection))
|
||||
Chunk.Swap(this, Position + 2 * randomDirection);
|
||||
else if (Chunk.IsEmpty(Position - 2 * randomDirection * VERTICAL_OPPOSITE))
|
||||
Chunk.Swap(this, Position - 2 * randomDirection * VERTICAL_OPPOSITE);
|
||||
}
|
||||
|
||||
public override void ActivateNeighbors() {
|
||||
|
||||
Reference in New Issue
Block a user