refactor: move global classes def into package
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
namespace Polonium.Scenes;
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class CameraScene : Scene
|
||||
{
|
||||
private Camera2D Camera { get; set; }
|
||||
@@ -26,5 +28,4 @@ public partial class CameraScene : Scene
|
||||
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,9 +1,10 @@
|
||||
using System.Diagnostics;
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
namespace Polonium.Scenes;
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class DissolveScene : Scene
|
||||
{
|
||||
[Export]
|
||||
@@ -16,7 +17,7 @@ public partial class DissolveScene : Scene
|
||||
if(Finished && !Terminated)
|
||||
{
|
||||
Terminated = true;
|
||||
PoloniumRegistry.Instance.RootScene.SwitchScene(NextScene);
|
||||
GlobalRegistry.RootScene.SwitchScene(NextScene);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ using Godot;
|
||||
using Polonium.Attributes;
|
||||
using Polonium.Interfaces;
|
||||
|
||||
namespace Polonium.Scenes;
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
public partial class RootScene : Node2D
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
[RegistryEntity]
|
||||
public partial class RootScene : Scene
|
||||
{
|
||||
private Scene CurrentScene { get; set; }
|
||||
|
||||
@@ -18,7 +21,7 @@ public partial class RootScene : Node2D
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
PoloniumRegistry.Instance.RootScene = this;
|
||||
GlobalRegistry.RootScene = this;
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
@@ -35,10 +38,9 @@ public partial class RootScene : Node2D
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if(!PoloniumRegistry.Instance.Paused)
|
||||
foreach (ITimeConsumer tc in PoloniumRegistry.Instance.TimeConsumers)
|
||||
if(!GlobalRegistry.Paused)
|
||||
foreach (ITimeConsumer tc in GlobalRegistry.TimeConsumers)
|
||||
tc.Process(delta);
|
||||
base._Process(delta);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
namespace Polonium.Scenes;
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class Scene : Node2D
|
||||
{
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
</ItemGroup>
|
||||
<Target Name="GenerateProxyNodes" BeforeTargets="BeforeBuild">
|
||||
<GenerateProxyNodesTask
|
||||
SourceDirectory="$(ProjectDir)src/Scenes"
|
||||
OutputDirectory="$(ProjectDir)GlobalClasses"
|
||||
SourceDirectory="$(ProjectDir)GlobalClasses"
|
||||
TemplateDirectory="$(ProjectDir)polonium_templates"
|
||||
AttributeName="ProxyNode"
|
||||
/>
|
||||
@@ -27,23 +26,23 @@
|
||||
<ItemGroup>
|
||||
<None Include="NuGet.config" />
|
||||
<None
|
||||
Include="Package\build\$(AssemblyName).targets"
|
||||
Include="Package/build/$(AssemblyName).targets"
|
||||
Pack="true"
|
||||
PackagePath="build"
|
||||
/>
|
||||
<None
|
||||
Include="GlobalClasses\**\*.cs"
|
||||
Include="GlobalClasses/**/*.cs"
|
||||
Pack="true"
|
||||
PackagePath="build\GlobalClasses"
|
||||
/>
|
||||
<None
|
||||
Include="polonium_templates\**\*.cs"
|
||||
Include="polonium_templates/**/*.cs"
|
||||
Pack="true"
|
||||
PackagePath="build\polonium_templates"
|
||||
PackagePath="build/polonium_templates"
|
||||
/>
|
||||
<None Include="publish" />
|
||||
<None Include="summerizer.py" />
|
||||
<Compile Remove="polonium_templates\**\*.*"/>
|
||||
<Compile Remove="polonium_templates/**/*.*" />
|
||||
<Compile Remove="GlobalClasses/**/*.cs" />
|
||||
<Folder Include="polonium_templates" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -66,9 +65,10 @@
|
||||
<Message Text="Pkgs: @(NuGetPackages)" Importance="high"/>
|
||||
<Copy SourceFiles="@(NuGetPackages)" DestinationFolder="/NuGetFeed"/>
|
||||
</Target>
|
||||
<Target Name="RestoreNoCache" BeforeTargets="Restore">
|
||||
<Target Name="RestoreNoCache" BeforeTargets="Build">
|
||||
<Message Text="Restoring packages with no chache" Importance="high"/>
|
||||
<Exec Command="dotnet restore --no-cache"/>
|
||||
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -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,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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user