refactor: move global classes def into package
This commit is contained in:
31
GlobalClasses/Scenes/CameraScene.cs
Normal file
31
GlobalClasses/Scenes/CameraScene.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
43
GlobalClasses/Scenes/DissolveScene.cs
Normal file
43
GlobalClasses/Scenes/DissolveScene.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
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 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();
|
||||
}
|
||||
}
|
||||
46
GlobalClasses/Scenes/RootScene.cs
Normal file
46
GlobalClasses/Scenes/RootScene.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
using Polonium.Interfaces;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
GlobalRegistry.RootScene = this;
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
[ProxyMethod]
|
||||
public virtual void Enter()
|
||||
{
|
||||
}
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
Enter();
|
||||
base._EnterTree();
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if(!GlobalRegistry.Paused)
|
||||
foreach (ITimeConsumer tc in GlobalRegistry.TimeConsumers)
|
||||
tc.Process(delta);
|
||||
base._Process(delta);
|
||||
}
|
||||
}
|
||||
11
GlobalClasses/Scenes/Scene.cs
Normal file
11
GlobalClasses/Scenes/Scene.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class Scene : Node2D
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user