Compare commits
1 Commits
4220e94e38
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f324122874 |
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Godot.NET.Sdk/4.4.1">
|
<Project Sdk="Godot.NET.Sdk/4.5.1">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
|||||||
12
FOU.csproj.old.1
Normal file
12
FOU.csproj.old.1
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<Project Sdk="Godot.NET.Sdk/4.4.1">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="benchmark.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="UI\" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -87,3 +87,10 @@ size_flags_vertical = 1
|
|||||||
max_value = 10.0
|
max_value = 10.0
|
||||||
step = 0.01
|
step = 0.01
|
||||||
value = 1.0
|
value = 1.0
|
||||||
|
|
||||||
|
[node name="ToolbarMarginContainer2" parent="CanvasLayer/TopUI" instance=ExtResource("5_kry3j")]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 860.0
|
||||||
|
offset_top = 5.0
|
||||||
|
offset_right = 1060.0
|
||||||
|
offset_bottom = 69.0
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public class Chunk {
|
|||||||
public Chunk NeighborS = null;
|
public Chunk NeighborS = null;
|
||||||
public Chunk NeighborW = null;
|
public Chunk NeighborW = null;
|
||||||
|
|
||||||
|
private readonly Image image;
|
||||||
private readonly int sizeX;
|
private readonly int sizeX;
|
||||||
private readonly int sizeY;
|
private readonly int sizeY;
|
||||||
private readonly HashSet<Element> activeElements;
|
private readonly HashSet<Element> activeElements;
|
||||||
@@ -32,6 +33,9 @@ public class Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activeElements = new HashSet<Element>(sizeX * sizeY);
|
activeElements = new HashSet<Element>(sizeX * sizeY);
|
||||||
|
|
||||||
|
image = Image.CreateEmpty(sizeX, sizeY, false, Image.Format.Rgb8);
|
||||||
|
image.Fill(Colors.Black);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update() {
|
public void Update() {
|
||||||
@@ -69,16 +73,15 @@ public class Chunk {
|
|||||||
return;
|
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);
|
Type type = typeof(T);
|
||||||
object o = Activator.CreateInstance(type, x, y, this);
|
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] = o as Element;
|
||||||
Elements[x, y].Active = true;
|
Elements[x, y].Active = true;
|
||||||
}
|
}
|
||||||
@@ -87,6 +90,10 @@ public class Chunk {
|
|||||||
return activeElements.Count;
|
return activeElements.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Swap(Element what, Vector2I pos) {
|
||||||
|
Swap(what, Get(pos));
|
||||||
|
}
|
||||||
|
|
||||||
public Element Get(Vector2I pos) {
|
public Element Get(Vector2I pos) {
|
||||||
Element e = null;
|
Element e = null;
|
||||||
|
|
||||||
@@ -122,10 +129,6 @@ public class Chunk {
|
|||||||
return Get(pos)?.GetType() == typeof(Element);
|
return Get(pos)?.GetType() == typeof(Element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Swap(Element what, Vector2I pos) {
|
|
||||||
Swap(what, Get(pos));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Swap(Element what, Element swapTo) {
|
private void Swap(Element what, Element swapTo) {
|
||||||
if (what == null || swapTo == null) {
|
if (what == null || swapTo == null) {
|
||||||
GD.PrintErr("Trying to swap null");
|
GD.PrintErr("Trying to swap null");
|
||||||
@@ -152,13 +155,8 @@ public class Chunk {
|
|||||||
|
|
||||||
what.Active = true;
|
what.Active = true;
|
||||||
what.Moved();
|
what.Moved();
|
||||||
if (what.IsEmpty())
|
|
||||||
what.ActivateNeighbors();
|
|
||||||
|
|
||||||
swapTo.Active = true;
|
swapTo.Active = true;
|
||||||
swapTo.Moved();
|
swapTo.Moved();
|
||||||
if (swapTo.IsEmpty())
|
|
||||||
swapTo.ActivateNeighbors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class Element{
|
|||||||
Chunk.SetElementActive(this, Active);
|
Chunk.SetElementActive(this, Active);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element(int x, int y, Chunk chunk, bool active = true) {
|
public Element(int x, int y, Chunk chunk) {
|
||||||
Position.X = x;
|
Position.X = x;
|
||||||
Position.Y = y;
|
Position.Y = y;
|
||||||
Chunk = chunk;
|
Chunk = chunk;
|
||||||
@@ -131,23 +131,4 @@ public class Element{
|
|||||||
public bool IsEmpty() {
|
public bool IsEmpty() {
|
||||||
return GetType() == typeof(Element);
|
return GetType() == typeof(Element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ActivateNeighbors() {
|
|
||||||
|
|
||||||
Element n = Chunk.Get(Position + Vector2I.Up);
|
|
||||||
if (n != null && !n.IsEmpty())
|
|
||||||
n.Active = true;
|
|
||||||
//
|
|
||||||
// Element e = Chunk.Get(Position + Vector2I.Right);
|
|
||||||
// if (e != null && !e.IsEmpty())
|
|
||||||
// e.Active = true;
|
|
||||||
//
|
|
||||||
// Element s = Chunk.Get(Position + Vector2I.Down);
|
|
||||||
// if (null != s && !s.IsEmpty())
|
|
||||||
// s.Active = true;
|
|
||||||
//
|
|
||||||
// Element w = Chunk.Get(Position + Vector2I.Left);
|
|
||||||
// if (null != w && !w.IsEmpty())
|
|
||||||
// w.Active = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,34 +26,9 @@ public abstract class Liquid : Element {
|
|||||||
Chunk.Swap(this, Position + Vector2I.Down);
|
Chunk.Swap(this, Position + Vector2I.Down);
|
||||||
|
|
||||||
else if (Chunk.IsEmpty(Position + randomDirection))
|
else if (Chunk.IsEmpty(Position + randomDirection))
|
||||||
Chunk.Swap(this, Position + randomDirection);
|
Chunk.Swap(this, Position + Vector2I.Right * randomDirection);
|
||||||
else if (Chunk.IsEmpty(Position + randomDirection * VERTICAL_OPPOSITE))
|
|
||||||
Chunk.Swap(this, Position + randomDirection * VERTICAL_OPPOSITE);
|
|
||||||
|
|
||||||
else if (Chunk.IsEmpty(Position + 1 * randomDirection))
|
else if (Chunk.IsEmpty(Position + randomDirection))
|
||||||
Chunk.Swap(this, Position + 1 * randomDirection);
|
Chunk.Swap(this, Position + Vector2I.Right * randomDirection * VERTICAL_OPPOSITE);
|
||||||
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() {
|
|
||||||
|
|
||||||
Element n = Chunk.Get(Position + Vector2I.Up);
|
|
||||||
if (n != null && !n.IsEmpty())
|
|
||||||
n.Active = true;
|
|
||||||
|
|
||||||
// only activate liquids left or right
|
|
||||||
Element e = Chunk.Get(Position + Vector2I.Right);
|
|
||||||
if (e != null && e.GetType() == typeof(Liquid))
|
|
||||||
e.Active = true;
|
|
||||||
|
|
||||||
Element s = Chunk.Get(Position + Vector2I.Down);
|
|
||||||
if (null != s && s.GetType() == typeof(Liquid))
|
|
||||||
s.Active = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ config_version=5
|
|||||||
|
|
||||||
config/name="FOU"
|
config/name="FOU"
|
||||||
run/main_scene="res://Scenes/main.tscn"
|
run/main_scene="res://Scenes/main.tscn"
|
||||||
config/features=PackedStringArray("4.4", "C#", "Forward Plus")
|
config/features=PackedStringArray("4.5", "C#", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|||||||
Reference in New Issue
Block a user