refactor: redesign project structure
This commit is contained in:
38
Package/embedded/GlobalClasses/Nodes/Scenes/CameraScene.cs
Normal file
38
Package/embedded/GlobalClasses/Nodes/Scenes/CameraScene.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
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;
|
||||
}
|
||||
|
||||
[ProxyMethod]
|
||||
public virtual void __Ready()
|
||||
{
|
||||
}
|
||||
|
||||
public sealed override void _Ready()
|
||||
{
|
||||
Camera = GetNode<Camera2D>("Camera");
|
||||
__Ready();
|
||||
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;
|
||||
}
|
||||
45
Package/embedded/GlobalClasses/Nodes/Scenes/DissolveScene.cs
Normal file
45
Package/embedded/GlobalClasses/Nodes/Scenes/DissolveScene.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma warning disable IDE0130
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class DissolveScene : Scene
|
||||
{
|
||||
[Export]
|
||||
public Scene NextScene { get; set; }
|
||||
private bool Finished { get; set; } = false;
|
||||
private bool Terminated { get; set; } = false;
|
||||
|
||||
public sealed override void _Process(double delta)
|
||||
{
|
||||
if(Finished && !Terminated)
|
||||
{
|
||||
Terminated = true;
|
||||
GlobalRegistry.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();
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0130
|
||||
63
Package/embedded/GlobalClasses/Nodes/Scenes/RootScene.cs
Normal file
63
Package/embedded/GlobalClasses/Nodes/Scenes/RootScene.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
#pragma warning disable IDE0130
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
using Polonium.Interfaces;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
[RegistryEntity]
|
||||
public partial class RootScene : Scene
|
||||
{
|
||||
private Scene CurrentScene { get; set; }
|
||||
|
||||
public void SwitchScene(Scene scene)
|
||||
{
|
||||
if (CurrentScene != null)
|
||||
RemoveChild(CurrentScene);
|
||||
AddChild(scene);
|
||||
CurrentScene = scene;
|
||||
}
|
||||
|
||||
[ProxyMethod]
|
||||
public virtual void __Enter()
|
||||
{
|
||||
}
|
||||
|
||||
[ProxyMethod]
|
||||
public virtual void __Ready()
|
||||
{
|
||||
}
|
||||
|
||||
[ProxyMethod]
|
||||
public virtual void __Process(double delta)
|
||||
{
|
||||
}
|
||||
|
||||
public sealed override void _EnterTree()
|
||||
{
|
||||
GlobalRegistry.Prepare();
|
||||
GlobalRegistry.Start();
|
||||
__Enter();
|
||||
base._EnterTree();
|
||||
}
|
||||
|
||||
public sealed override void _Process(double delta)
|
||||
{
|
||||
if(!GlobalRegistry.Paused)
|
||||
foreach (ITimeConsumer tc in GlobalRegistry.TimeConsumers)
|
||||
tc.Process(delta);
|
||||
__Process(delta);
|
||||
base._Process(delta);
|
||||
}
|
||||
|
||||
public sealed override void _Ready()
|
||||
{
|
||||
GlobalRegistry.RootScene = this;
|
||||
__Ready();
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
}
|
||||
#pragma warning restore IDE0130
|
||||
13
Package/embedded/GlobalClasses/Nodes/Scenes/Scene.cs
Normal file
13
Package/embedded/GlobalClasses/Nodes/Scenes/Scene.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma warning disable IDE0130
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class Scene : Node2D
|
||||
{
|
||||
|
||||
}
|
||||
#pragma warning restore IDE0130
|
||||
Reference in New Issue
Block a user