refactor: move global classes def into package
This commit is contained in:
@@ -2,15 +2,14 @@ using Godot;
|
||||
using Polonium.Agents;
|
||||
using Polonium.Interfaces;
|
||||
using Polonium.Resources;
|
||||
using Polonium.Scenes;
|
||||
|
||||
namespace Polonium;
|
||||
|
||||
public class PoloniumRegistry
|
||||
{
|
||||
public static IGlobalRegistry GlobalRegistry { get; set; }
|
||||
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; }
|
||||
|
||||
@@ -21,6 +20,6 @@ public class PoloniumRegistry
|
||||
public Dictionary<string, Agent> Agents { get; set; } = new();
|
||||
|
||||
public HashSet<ITimeConsumer> TimeConsumers { get; set; } = new();
|
||||
public bool Paused { get; set; }
|
||||
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
namespace Polonium.Scenes;
|
||||
[ProxyNode]
|
||||
public partial class CameraScene : Scene
|
||||
{
|
||||
private Camera2D Camera { get; set; }
|
||||
|
||||
public float MaxZoom { get; set; }
|
||||
|
||||
public float MinZoom { get; set; }
|
||||
|
||||
public float ZoomRate { get; set; }
|
||||
|
||||
private float Zoom
|
||||
{
|
||||
get => Camera.Zoom.X;
|
||||
set => Camera.Zoom = value * Vector2.One;
|
||||
}
|
||||
public override void _Ready()
|
||||
{
|
||||
Camera = GetNode<Camera2D>("Camera");
|
||||
base._Ready();
|
||||
}
|
||||
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;
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
namespace Polonium.Scenes;
|
||||
[ProxyNode]
|
||||
public partial class DissolveScene : Scene
|
||||
{
|
||||
[Export]
|
||||
public Scene NextScene { get; set; }
|
||||
private bool Finished { get; set; } = false;
|
||||
private bool Terminated { get; set; } = false;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if(Finished && !Terminated)
|
||||
{
|
||||
Terminated = true;
|
||||
PoloniumRegistry.Instance.RootScene.SwitchScene(NextScene);
|
||||
return;
|
||||
}
|
||||
|
||||
Process(delta);
|
||||
base._Process(delta);
|
||||
}
|
||||
[ProxyMethod]
|
||||
public virtual void Enter()
|
||||
{
|
||||
}
|
||||
[ProxyMethod]
|
||||
public virtual void Process(double delta)
|
||||
{
|
||||
}
|
||||
|
||||
public sealed override void _EnterTree()
|
||||
{
|
||||
Finished = false;
|
||||
Terminated = false;
|
||||
Enter();
|
||||
base._EnterTree();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
|
||||
using Polonium.DataStructures;
|
||||
using Polonium.Managers;
|
||||
|
||||
namespace Polonium.Scenes;
|
||||
public abstract partial class LoadingScene<T> : Scene
|
||||
where T : ProgressInfo
|
||||
{
|
||||
public Scene AfterLoaded { get; set; }
|
||||
|
||||
private double CoolDown { get; set; } = 0;
|
||||
|
||||
public LoaderManager<T> Manager { get; set; }
|
||||
|
||||
protected abstract void ConsumeProgressInfo(T progressInfo);
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
CoolDown += delta;
|
||||
if (CoolDown < 1)
|
||||
return;
|
||||
CoolDown = 0;
|
||||
T progress = Manager.QueryProgress();
|
||||
ConsumeProgressInfo(progress);
|
||||
if(Manager.Finished)
|
||||
PoloniumRegistry.Instance.RootScene.SwitchScene(AfterLoaded);
|
||||
base._Process(delta);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
using Polonium.Interfaces;
|
||||
|
||||
namespace Polonium.Scenes;
|
||||
[ProxyNode]
|
||||
public partial class RootScene : Node2D
|
||||
{
|
||||
private Scene CurrentScene { get; set; }
|
||||
|
||||
public void SwitchScene(Scene scene)
|
||||
{
|
||||
if (CurrentScene != null)
|
||||
RemoveChild(CurrentScene);
|
||||
AddChild(scene);
|
||||
CurrentScene = scene;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
PoloniumRegistry.Instance.RootScene = this;
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
[ProxyMethod]
|
||||
public virtual void Enter()
|
||||
{
|
||||
}
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
Enter();
|
||||
base._EnterTree();
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if(!PoloniumRegistry.Instance.Paused)
|
||||
foreach (ITimeConsumer tc in PoloniumRegistry.Instance.TimeConsumers)
|
||||
tc.Process(delta);
|
||||
base._Process(delta);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
namespace Polonium.Scenes;
|
||||
[ProxyNode]
|
||||
public partial class Scene : Node2D
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user