refactor: move global classes def into package
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Polonium.Attributes;
|
using Polonium.Attributes;
|
||||||
|
|
||||||
namespace Polonium.Scenes;
|
namespace GlobalClasses;
|
||||||
[ProxyNode]
|
[ProxyNode]
|
||||||
|
[GlobalClass]
|
||||||
|
[Tool]
|
||||||
public partial class CameraScene : Scene
|
public partial class CameraScene : Scene
|
||||||
{
|
{
|
||||||
private Camera2D Camera { get; set; }
|
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 ZoomIn() => Zoom = Mathf.Max(Zoom * (1 + ZoomRate), MaxZoom);
|
||||||
protected void ZoomOut() => Zoom = Mathf.Min(Zoom * (1 - ZoomRate), MinZoom);
|
protected void ZoomOut() => Zoom = Mathf.Min(Zoom * (1 - ZoomRate), MinZoom);
|
||||||
protected void ZoomAt(Vector2 pos) => Camera.Position = pos;
|
protected void ZoomAt(Vector2 pos) => Camera.Position = pos;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
using System.Diagnostics;
|
|
||||||
using Godot;
|
using Godot;
|
||||||
using Polonium.Attributes;
|
using Polonium.Attributes;
|
||||||
|
|
||||||
namespace Polonium.Scenes;
|
namespace GlobalClasses;
|
||||||
[ProxyNode]
|
[ProxyNode]
|
||||||
|
[GlobalClass]
|
||||||
|
[Tool]
|
||||||
public partial class DissolveScene : Scene
|
public partial class DissolveScene : Scene
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
@@ -16,7 +17,7 @@ public partial class DissolveScene : Scene
|
|||||||
if(Finished && !Terminated)
|
if(Finished && !Terminated)
|
||||||
{
|
{
|
||||||
Terminated = true;
|
Terminated = true;
|
||||||
PoloniumRegistry.Instance.RootScene.SwitchScene(NextScene);
|
GlobalRegistry.RootScene.SwitchScene(NextScene);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2,9 +2,12 @@ using Godot;
|
|||||||
using Polonium.Attributes;
|
using Polonium.Attributes;
|
||||||
using Polonium.Interfaces;
|
using Polonium.Interfaces;
|
||||||
|
|
||||||
namespace Polonium.Scenes;
|
namespace GlobalClasses;
|
||||||
[ProxyNode]
|
[ProxyNode]
|
||||||
public partial class RootScene : Node2D
|
[GlobalClass]
|
||||||
|
[Tool]
|
||||||
|
[RegistryEntity]
|
||||||
|
public partial class RootScene : Scene
|
||||||
{
|
{
|
||||||
private Scene CurrentScene { get; set; }
|
private Scene CurrentScene { get; set; }
|
||||||
|
|
||||||
@@ -18,7 +21,7 @@ public partial class RootScene : Node2D
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
PoloniumRegistry.Instance.RootScene = this;
|
GlobalRegistry.RootScene = this;
|
||||||
base._Ready();
|
base._Ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,10 +38,9 @@ public partial class RootScene : Node2D
|
|||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
if(!PoloniumRegistry.Instance.Paused)
|
if(!GlobalRegistry.Paused)
|
||||||
foreach (ITimeConsumer tc in PoloniumRegistry.Instance.TimeConsumers)
|
foreach (ITimeConsumer tc in GlobalRegistry.TimeConsumers)
|
||||||
tc.Process(delta);
|
tc.Process(delta);
|
||||||
base._Process(delta);
|
base._Process(delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Polonium.Attributes;
|
using Polonium.Attributes;
|
||||||
|
|
||||||
namespace Polonium.Scenes;
|
namespace GlobalClasses;
|
||||||
[ProxyNode]
|
[ProxyNode]
|
||||||
|
[GlobalClass]
|
||||||
|
[Tool]
|
||||||
public partial class Scene : Node2D
|
public partial class Scene : Node2D
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,8 +18,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Target Name="GenerateProxyNodes" BeforeTargets="BeforeBuild">
|
<Target Name="GenerateProxyNodes" BeforeTargets="BeforeBuild">
|
||||||
<GenerateProxyNodesTask
|
<GenerateProxyNodesTask
|
||||||
SourceDirectory="$(ProjectDir)src/Scenes"
|
SourceDirectory="$(ProjectDir)GlobalClasses"
|
||||||
OutputDirectory="$(ProjectDir)GlobalClasses"
|
|
||||||
TemplateDirectory="$(ProjectDir)polonium_templates"
|
TemplateDirectory="$(ProjectDir)polonium_templates"
|
||||||
AttributeName="ProxyNode"
|
AttributeName="ProxyNode"
|
||||||
/>
|
/>
|
||||||
@@ -27,37 +26,37 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="NuGet.config" />
|
<None Include="NuGet.config" />
|
||||||
<None
|
<None
|
||||||
Include="Package\build\$(AssemblyName).targets"
|
Include="Package/build/$(AssemblyName).targets"
|
||||||
Pack="true"
|
Pack="true"
|
||||||
PackagePath="build"
|
PackagePath="build"
|
||||||
/>
|
/>
|
||||||
<None
|
<None
|
||||||
Include="GlobalClasses\**\*.cs"
|
Include="GlobalClasses/**/*.cs"
|
||||||
Pack="true"
|
Pack="true"
|
||||||
PackagePath="build\GlobalClasses"
|
PackagePath="build\GlobalClasses"
|
||||||
/>
|
/>
|
||||||
<None
|
<None
|
||||||
Include="polonium_templates\**\*.cs"
|
Include="polonium_templates/**/*.cs"
|
||||||
Pack="true"
|
Pack="true"
|
||||||
PackagePath="build\polonium_templates"
|
PackagePath="build/polonium_templates"
|
||||||
/>
|
/>
|
||||||
<None Include="publish" />
|
<None Include="publish" />
|
||||||
<None Include="summerizer.py" />
|
<Compile Remove="polonium_templates/**/*.*" />
|
||||||
<Compile Remove="polonium_templates\**\*.*"/>
|
<Compile Remove="GlobalClasses/**/*.cs" />
|
||||||
<Folder Include="polonium_templates" />
|
<Folder Include="polonium_templates" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="CleanPreviousPackages" BeforeTargets="Build">
|
<Target Name="CleanPreviousPackages" BeforeTargets="Build">
|
||||||
<Message Text="Cleaning Previous Packages -------------------------" Importance="high"/>
|
<Message Text="Cleaning Previous Packages -------------------------" Importance="high" />
|
||||||
<Message Text="Cleaning --------------------------------------------" Importance="high"/>
|
<Message Text="Cleaning --------------------------------------------" Importance="high" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ExistingPackages Include="$(OutputPath)*.nupkg"/>
|
<ExistingPackages Include="$(OutputPath)*.nupkg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Delete Files="@(ExistingPackages)" ContinueOnError="true"/>
|
<Delete Files="@(ExistingPackages)" ContinueOnError="true" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="CopyPackageToLocalFeed" AfterTargets="Pack">
|
<Target Name="CopyPackageToLocalFeed" AfterTargets="Pack">
|
||||||
<Message Text="Executing Copy Task ----------------------" Importance="high"/>
|
<Message Text="Executing Copy Task ----------------------" Importance="high" />
|
||||||
<Message Text="OutputPath: $(OutputPath)" Importance="high" />
|
<Message Text="OutputPath: $(OutputPath)" Importance="high" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<NuGetPackages Include="$(OutputPath)*.nupkg" />
|
<NuGetPackages Include="$(OutputPath)*.nupkg" />
|
||||||
@@ -66,9 +65,10 @@
|
|||||||
<Message Text="Pkgs: @(NuGetPackages)" Importance="high"/>
|
<Message Text="Pkgs: @(NuGetPackages)" Importance="high"/>
|
||||||
<Copy SourceFiles="@(NuGetPackages)" DestinationFolder="/NuGetFeed"/>
|
<Copy SourceFiles="@(NuGetPackages)" DestinationFolder="/NuGetFeed"/>
|
||||||
</Target>
|
</Target>
|
||||||
<Target Name="RestoreNoCache" BeforeTargets="Restore">
|
<Target Name="RestoreNoCache" BeforeTargets="Build">
|
||||||
<Message Text="Restoring packages with no chache" Importance="high"/>
|
<Message Text="Restoring packages with no chache" Importance="high"/>
|
||||||
<Exec Command="dotnet restore --no-cache"/>
|
<Exec Command="dotnet restore --no-cache"/>
|
||||||
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ using Godot;
|
|||||||
using Polonium.Agents;
|
using Polonium.Agents;
|
||||||
using Polonium.Interfaces;
|
using Polonium.Interfaces;
|
||||||
using Polonium.Resources;
|
using Polonium.Resources;
|
||||||
using Polonium.Scenes;
|
|
||||||
|
|
||||||
namespace Polonium;
|
namespace Polonium;
|
||||||
|
|
||||||
public class PoloniumRegistry
|
public class PoloniumRegistry
|
||||||
{
|
{
|
||||||
|
public static IGlobalRegistry GlobalRegistry { get; set; }
|
||||||
private static PoloniumRegistry InternalInstance { get; set; }
|
private static PoloniumRegistry InternalInstance { get; set; }
|
||||||
public static PoloniumRegistry Instance => InternalInstance ??= new PoloniumRegistry();
|
public static PoloniumRegistry Instance => InternalInstance ??= new PoloniumRegistry();
|
||||||
public RootScene RootScene { get; set; }
|
|
||||||
public Config Config { get; set; }
|
public Config Config { get; set; }
|
||||||
public Save Save { get; set; }
|
public Save Save { get; set; }
|
||||||
|
|
||||||
@@ -21,6 +20,6 @@ public class PoloniumRegistry
|
|||||||
public Dictionary<string, Agent> Agents { get; set; } = new();
|
public Dictionary<string, Agent> Agents { get; set; } = new();
|
||||||
|
|
||||||
public HashSet<ITimeConsumer> TimeConsumers { 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