diff --git a/.idea/.idea.Polonium/.idea/.gitignore b/.idea/.idea.Polonium/.idea/.gitignore
new file mode 100644
index 0000000..8af7534
--- /dev/null
+++ b/.idea/.idea.Polonium/.idea/.gitignore
@@ -0,0 +1,13 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Rider ignored files
+/.idea.Hangman.SDK.iml
+/modules.xml
+/projectSettingsUpdater.xml
+/contentModel.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/.idea.Polonium/.idea/encodings.xml b/.idea/.idea.Polonium/.idea/encodings.xml
new file mode 100644
index 0000000..df87cf9
--- /dev/null
+++ b/.idea/.idea.Polonium/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.Polonium/.idea/indexLayout.xml b/.idea/.idea.Polonium/.idea/indexLayout.xml
new file mode 100644
index 0000000..7b08163
--- /dev/null
+++ b/.idea/.idea.Polonium/.idea/indexLayout.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.idea.Polonium/.idea/vcs.xml b/.idea/.idea.Polonium/.idea/vcs.xml
new file mode 100644
index 0000000..62477ea
--- /dev/null
+++ b/.idea/.idea.Polonium/.idea/vcs.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Polonium.csproj b/Polonium.csproj
index 2e6c98e..c31c712 100644
--- a/Polonium.csproj
+++ b/Polonium.csproj
@@ -18,6 +18,7 @@
+
diff --git a/Polonium.sln.DotSettings.user b/Polonium.sln.DotSettings.user
new file mode 100644
index 0000000..0e44675
--- /dev/null
+++ b/Polonium.sln.DotSettings.user
@@ -0,0 +1,7 @@
+
+ ForceIncluded
+ ForceIncluded
+ ForceIncluded
+ ForceIncluded
+ ForceIncluded
+ ForceIncluded
\ No newline at end of file
diff --git a/src/Attributes/RegistryEntity.cs b/src/Attributes/RegistryEntity.cs
new file mode 100644
index 0000000..f4791ff
--- /dev/null
+++ b/src/Attributes/RegistryEntity.cs
@@ -0,0 +1,6 @@
+namespace Polonium.Attributes;
+[AttributeUsage(AttributeTargets.Class)]
+public class RegistryEntity : Attribute
+{
+
+}
\ No newline at end of file
diff --git a/src/PoloniumRegistry.cs b/src/PoloniumRegistry.cs
new file mode 100644
index 0000000..4460893
--- /dev/null
+++ b/src/PoloniumRegistry.cs
@@ -0,0 +1,19 @@
+using Godot;
+using Polonium.Resources;
+using Polonium.Scenes;
+
+namespace Polonium;
+
+public class PoloniumRegistry
+{
+ private static PoloniumRegistry InternalInstance { get; set; }
+ public static PoloniumRegistry Instance => InternalInstance ??= new PoloniumRegistry();
+ public RootScene RootScene { get; set; }
+ public Config Config { get; set; }
+ public Save Save { get; set; }
+
+ public static void Prepare()
+ {
+ DirAccess.MakeDirAbsolute("user://saves");
+ }
+}
\ No newline at end of file
diff --git a/src/Resources/Config.cs b/src/Resources/Config.cs
new file mode 100644
index 0000000..715b8ff
--- /dev/null
+++ b/src/Resources/Config.cs
@@ -0,0 +1,16 @@
+using Godot;
+
+namespace Polonium.Resources;
+
+public partial class Config: Resource
+
+{
+
+ public void Save() => ResourceSaver.Save(this, "user://Config.tres");
+
+ public static void Load()
+ where T : Config, new()
+ {
+ PoloniumRegistry.Instance.Config = ResourceLoader.Load("user://Config.tres") ?? new T();
+ }
+}
\ No newline at end of file
diff --git a/src/Resources/Save.cs b/src/Resources/Save.cs
new file mode 100644
index 0000000..f22014c
--- /dev/null
+++ b/src/Resources/Save.cs
@@ -0,0 +1,49 @@
+using Godot;
+
+namespace Polonium.Resources;
+
+public abstract partial class Save : Resource
+{
+ [Export]
+ public string Name { get; set; }
+
+ public abstract class Preview
+ {
+ }
+
+ public void SaveToUser() => ResourceSaver.Save(this, $"user://saves/{Name}.tres");
+
+ public static void LoadFromUser(string name)
+ where T : Save, new()
+ {
+ T res = ResourceLoader.Load($"user://saves/{name}.tres");
+ if (res is null)
+ {
+ res = new T();
+ res.Name = name;
+ }
+
+ PoloniumRegistry.Instance.Save = res;
+ }
+
+ public void Load() => PoloniumRegistry.Instance.Save = this;
+
+ public static IEnumerable ListSaves()
+ where T : Save
+ {
+ DirAccess dir = DirAccess.Open("user://saves");
+ if(dir is null)
+ {
+ DirAccess.MakeDirRecursiveAbsolute("user://saves");
+ yield break;
+ }
+
+ foreach (string save in dir.GetFiles())
+ {
+ if(!save.EndsWith(".tres"))
+ continue;
+ yield return ResourceLoader.Load($"user://saves/{save}");
+ }
+ }
+
+}
diff --git a/src/Scenes/CameraScene.cs b/src/Scenes/CameraScene.cs
index 684b5aa..bbc4ab9 100644
--- a/src/Scenes/CameraScene.cs
+++ b/src/Scenes/CameraScene.cs
@@ -1,13 +1,18 @@
using Godot;
namespace Polonium.Scenes;
-
-public abstract partial class CameraScene : Scene
+[GlobalClass]
+[Tool]
+public partial class CameraScene : Scene
{
private Camera2D Camera { get; set; }
- protected abstract float MaxZoom { get; }
- protected abstract float MinZoom { get; }
- protected abstract float ZoomRate { get; }
+ [Export(PropertyHint.Range)]
+ public float MaxZoom { get; set; }
+ [Export(PropertyHint.Range)]
+ public float MinZoom { get; set; }
+ [Export(PropertyHint.Range)]
+ public float ZoomRate { get; set; }
+ [Export(PropertyHint.Range)]
private float Zoom
{
get => Camera.Zoom.X;
@@ -15,11 +20,12 @@ public abstract partial class CameraScene : Scene
}
public override void _Ready()
{
- Camera = GetNode("Camera");
+ Camera = new Camera2D();
+ AddChild(Camera);
base._Ready();
}
- protected void ZoomIn() => Mathf.Max(Zoom * (1 + ZoomRate), MaxZoom);
- protected void ZoomOut() => Mathf.Min(Zoom * (1 - ZoomRate), MinZoom);
+ protected void ZoomIn() => Zoom = Mathf.Max(Zoom * (1 + ZoomRate), MaxZoom);
+ protected void ZoomOut() => Zoom = Mathf.Min(Zoom * (1 - ZoomRate), MinZoom);
protected void ZoomAt(Vector2 pos) => Camera.Position = pos;
}
diff --git a/src/Scenes/LayerCameraScene.cs b/src/Scenes/LayerCameraScene.cs
new file mode 100644
index 0000000..6f1d6fc
--- /dev/null
+++ b/src/Scenes/LayerCameraScene.cs
@@ -0,0 +1,14 @@
+using Godot;
+
+namespace Polonium.Scenes;
+[GlobalClass]
+public partial class LayerCameraScene : CameraScene
+{
+ private Node2D LayerHolder { get; set; }
+
+ public override void _Ready()
+ {
+ LayerHolder = new Node2D();
+ base._Ready();
+ }
+}
\ No newline at end of file
diff --git a/src/Scenes/RootScene.cs b/src/Scenes/RootScene.cs
index a7ef77c..4d07b6c 100644
--- a/src/Scenes/RootScene.cs
+++ b/src/Scenes/RootScene.cs
@@ -1,19 +1,21 @@
using Godot;
-
namespace Polonium.Scenes;
-
-public abstract partial class RootScene : Node2D
+[GlobalClass]
+public partial class RootScene : Node2D
{
- private Polonium.Scenes.Scene CurrentScene { get; set; }
+ private Scene CurrentScene { get; set; }
- public void SwitchScene(Polonium.Scenes.Scene scene)
+ public void SwitchScene(Scene scene)
{
if (CurrentScene != null)
RemoveChild(CurrentScene);
AddChild(scene);
CurrentScene = scene;
}
-
-
+ public override void _Ready()
+ {
+ PoloniumRegistry.Instance.RootScene = this;
+ base._Ready();
+ }
}
\ No newline at end of file