Compare commits
14 Commits
1f2ba38f65
...
draft_text
| Author | SHA1 | Date | |
|---|---|---|---|
| a95de5aa59 | |||
| f9a6dbe55b | |||
| 604b7dd6d8 | |||
| f290b52fa3 | |||
| 5a981c91ee | |||
| 0d75ed106d | |||
| ca7e3c68a5 | |||
| 2323211a65 | |||
| f7da4ee8bb | |||
| aea9059e16 | |||
| ac1c93d1e5 | |||
| 3c1035bdfe | |||
| 0a8b275176 | |||
| 15c667c3c4 |
13
.idea/.idea.Polonium/.idea/.gitignore
generated
vendored
Normal file
13
.idea/.idea.Polonium/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Rider ignored files
|
||||||
|
/.idea.Hangman.SDK.iml
|
||||||
|
/modules.xml
|
||||||
|
/projectSettingsUpdater.xml
|
||||||
|
/contentModel.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
4
.idea/.idea.Polonium/.idea/encodings.xml
generated
Normal file
4
.idea/.idea.Polonium/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
8
.idea/.idea.Polonium/.idea/indexLayout.xml
generated
Normal file
8
.idea/.idea.Polonium/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
.idea/.idea.Polonium/.idea/vcs.xml
generated
Normal file
7
.idea/.idea.Polonium/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/../Polonium.Generators" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
NuGet.config
Normal file
8
NuGet.config
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="hangman-lab" value="https://git.hangman-lab.top/api/packages/hzhang/nuget/index.json"/>
|
||||||
|
<add key="Local" value="/NuGetFeed"/>
|
||||||
|
</packageSources>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
7
Package/build/Polonium.props
Normal file
7
Package/build/Polonium.props
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<PoloniumTemplateTargetPath>$(ProjectDir)script_templates/</PoloniumTemplateTargetPath>
|
||||||
|
<PoloniumTemplateManifest>$(ProjectDir)embedded/templates.polonium.manifest</PoloniumTemplateManifest>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -1,17 +1,69 @@
|
|||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup Label="Scene">
|
|
||||||
<AdditionalFiles Include="Assets/**/*.tscn"/>
|
|
||||||
</ItemGroup>
|
|
||||||
<Target Name="EnsureFolders" BeforeTargets="BeforeBuild">
|
|
||||||
<MakeDir Directories="$(ProjectDir)Assets" Condition="!Exists('$(ProjectDir)Assets')"/>
|
|
||||||
<MakeDir Directories="$(ProjectDir)Concepts" Condition="!Exists('$(ProjectDir)Concepts')"/>
|
|
||||||
<MakeDir Directories="$(ProjectDir)Registries" Condition="!Exists('$(ProjectDir)Registries')"/>
|
|
||||||
<MakeDir Directories="$(ProjectDir)Data" Condition="!Exists('$(ProjectDir)Data')"/>
|
|
||||||
</Target>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Concepts"/>
|
<Folder Include="Concepts"/>
|
||||||
<Folder Include="Assets"/>
|
<Folder Include="Assets"/>
|
||||||
<Folder Include="Registries"/>
|
<Folder Include="Registries"/>
|
||||||
<Folder Include="Data"/>
|
<Folder Include="Data"/>
|
||||||
|
<Folder Include="Resources"/>
|
||||||
|
<None Include="script_templates/**/*.*"/>
|
||||||
|
<Compile Remove="script_templates/**/*.*"/>
|
||||||
|
<Compile Remove="embedded/polonium_templates/**/*.cs"/>
|
||||||
|
<AdditionalFiles Include="Assets/**/*.tscn"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PoloniumPrepare" BeforeTargets="PoloniumClean">
|
||||||
|
<Message Text="Executing EnsureFolders target" Importance="High"/>
|
||||||
|
<Message Text="$(ProjectDir)" Importance="High"/>
|
||||||
|
<MakeDir Directories="$(ProjectDir)Assets" Condition="!Exists('$(ProjectDir)Assets')"/>
|
||||||
|
<MakeDir Directories="$(ProjectDir)Concepts" Condition="!Exists('$(ProjectDir)Concepts')"/>
|
||||||
|
<MakeDir Directories="$(ProjectDir)Registries" Condition="!Exists('$(ProjectDir)Registries')"/>
|
||||||
|
<MakeDir Directories="$(ProjectDir)Data" Condition="!Exists('$(ProjectDir)Data')"/>
|
||||||
|
<MakeDir Directories="$(ProjectDir)Resources" Condition="!Exists('$(ProjectDir)Resources')"/>
|
||||||
|
<MakeDir Directories="$(ProjectDir)Resources/ButtonTextureSet" Condition="!Exists('$(ProjectDir)Resources/ButtonTextureSet')"/>
|
||||||
|
<MakeDir Directories="$(ProjectDir)script_templates" Condition="!Exists('$(ProjectDir)script_templates')"/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PoloniumClean" DependsOnTargets="PoloniumPrepare" BeforeTargets="PoloniumRegenerate">
|
||||||
|
<ReadLinesFromFile
|
||||||
|
File="$(PoloniumTemplateManifest)"
|
||||||
|
Condition="Exists('$(PoloniumTemplateManifest)')"
|
||||||
|
>
|
||||||
|
<Output TaskParameter="Lines" ItemName="PreviousTemplateFiles"/>
|
||||||
|
</ReadLinesFromFile>
|
||||||
|
<Delete Files="@(PreviousTemplateFiles)" Condition="@(PreviousTemplateFiles) != ''" />
|
||||||
|
<RemoveDir Directories="$(ProjectDir)embedded" Condition="Exists('$(ProjectDir)embedded')"/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
|
||||||
|
<Target Name="PoloniumRegenerate" DependsOnTargets="PoloniumClean" BeforeTargets="CoreCompile">
|
||||||
|
<MakeDir Directories="$(ProjectDir)" Condition="!Exists('$(ProjectDir)embedded')"/>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedFiles Include="$(MSBuildThisFileDirectory)embedded/**/*.*"/>
|
||||||
|
</ItemGroup>
|
||||||
|
<Copy
|
||||||
|
SourceFiles="@(EmbeddedFiles)"
|
||||||
|
DestinationFolder="$(ProjectDir)embedded/%(RecursiveDir)"
|
||||||
|
/>
|
||||||
|
<ItemGroup>
|
||||||
|
<PoloniumTemplateFiles Include="$(MSBuildThisFileDirectory)embedded/polonium_templates/**/*.*" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Copy
|
||||||
|
SourceFiles="@(PoloniumTemplateFiles)"
|
||||||
|
DestinationFiles="@(PoloniumTemplateFiles->'$(PoloniumTemplateTargetPath)%(RecursiveDir)%(FileName)%(Extension)')"
|
||||||
|
>
|
||||||
|
<Output TaskParameter="CopiedFiles" ItemName="CopiedTemplates" />
|
||||||
|
</Copy>
|
||||||
|
<WriteLinesToFile
|
||||||
|
File="$(PoloniumTemplateManifest)"
|
||||||
|
Lines="@(CopiedTemplates)"
|
||||||
|
Overwrite="true"
|
||||||
|
Encoding="UTF-8"
|
||||||
|
/>
|
||||||
|
<GenerateTextureSetTask
|
||||||
|
RootPath="$(ProjectDir)Resources/ButtonTextureSet/"
|
||||||
|
OutputPath="$(ProjectDir)embedded/"
|
||||||
|
/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
dotnet nuget push "$(ls -t ../../.godot/mono/temp/bin/Debug/Polonium.*.nupkg | head -n 1)" --source hangman-lab
|
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
#pragma warning disable IDE0130
|
||||||
|
using Godot;
|
||||||
|
using Polonium.Attributes;
|
||||||
|
using Polonium.DataStructures;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Polonium.Interfaces;
|
||||||
|
|
||||||
|
// ReSharper disable once CheckNamespace
|
||||||
|
namespace GlobalClasses;
|
||||||
|
[GlobalClass]
|
||||||
|
[Tool]
|
||||||
|
[ProxyNode]
|
||||||
|
public partial class PoloniumTextureButton : TextureButton
|
||||||
|
{
|
||||||
|
[ProxyProperty]
|
||||||
|
public virtual TextureSet TextureSet => null;
|
||||||
|
|
||||||
|
private GlobalRegistry.TextureSetName PrivateTextureSetName { get; set; }
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public GlobalRegistry.TextureSetName TextureSetName
|
||||||
|
{
|
||||||
|
get => PrivateTextureSetName;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
PrivateTextureSetName = value;
|
||||||
|
t = GlobalRegistry.TextureSetMap.GetValueOrDefault(value, null);
|
||||||
|
if (t is not null)
|
||||||
|
{
|
||||||
|
TextureNormal = t.Normal;
|
||||||
|
TextureHover = t.Hover;
|
||||||
|
TexturePressed = t.Pressed;
|
||||||
|
TextureDisabled = t.Disabled;
|
||||||
|
TextureFocused = t.Focused;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed override void _Ready()
|
||||||
|
{
|
||||||
|
TextureSet t = TextureSet;
|
||||||
|
if (t is null)
|
||||||
|
t = GlobalRegistry.TextureSetMap.GetValueOrDefault(TextureSetName, null);
|
||||||
|
if (t is not null)
|
||||||
|
{
|
||||||
|
TextureNormal = t.Normal;
|
||||||
|
TextureHover = t.Hover;
|
||||||
|
TexturePressed = t.Pressed;
|
||||||
|
TextureDisabled = t.Disabled;
|
||||||
|
TextureFocused = t.Focused;
|
||||||
|
}
|
||||||
|
|
||||||
|
__Ready();
|
||||||
|
base._Ready();
|
||||||
|
}
|
||||||
|
[ProxyMethod]
|
||||||
|
public virtual void __Ready()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore IDE0130
|
||||||
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
|
||||||
57
Package/embedded/Patches/GlobalRegistry.p.cs
Normal file
57
Package/embedded/Patches/GlobalRegistry.p.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#pragma warning disable IDE0130
|
||||||
|
#pragma warning disable CA1000
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using Polonium.Attributes;
|
||||||
|
using Polonium;
|
||||||
|
using Polonium.Interfaces;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
// ReSharper disable once CheckNamespace
|
||||||
|
public static partial class GlobalRegistry
|
||||||
|
{
|
||||||
|
public static void Start()
|
||||||
|
{
|
||||||
|
PoloniumRegistry.Prepare();
|
||||||
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||||
|
IEnumerable<Type> registerTypes = Utils.GetLoadableTypes(assembly);
|
||||||
|
registerTypes = registerTypes.Where(t => t.IsClass && t.GetCustomAttributes(typeof(AutoRegister), false).Any());
|
||||||
|
foreach (Type t in registerTypes)
|
||||||
|
{
|
||||||
|
MethodInfo registerMethod = t.GetMethod("Register", BindingFlags.Static | BindingFlags.Public);
|
||||||
|
if (registerMethod != null)
|
||||||
|
registerMethod.Invoke(null, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Asset<T> where T : Node
|
||||||
|
{
|
||||||
|
private static readonly Queue<T> Pool = new();
|
||||||
|
// ReSharper disable once StaticMemberInGenericType
|
||||||
|
// ReSharper disable once UnusedAutoPropertyAccessor.Global
|
||||||
|
public static PackedScene Scene { get; set; }
|
||||||
|
private static T Instance => Scene.Instantiate<T>();
|
||||||
|
public static T Get() => Pool.Count > 0 ? Pool.Dequeue() : Instance;
|
||||||
|
|
||||||
|
public static void Return(T obj)
|
||||||
|
{
|
||||||
|
if(Pool.Count < 10)
|
||||||
|
Pool.Enqueue(obj);
|
||||||
|
else
|
||||||
|
obj.QueueFree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static PoloniumRegistry PoloniumRegistry => PoloniumRegistry.Instance;
|
||||||
|
public static bool Paused { get; set; }
|
||||||
|
public static HashSet<ITimeConsumer> TimeConsumers { get; } = [];
|
||||||
|
public static void Prepare() => PoloniumRegistry.Prepare();
|
||||||
|
|
||||||
|
// ReSharper disable once PartialTypeWithSinglePart
|
||||||
|
public static partial class TextureSets
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore IDE0130
|
||||||
|
#pragma warning restore CA1000
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Godot.NET.Sdk/4.4.0-beta.2">
|
<Project Sdk="Godot.NET.Sdk/4.4.0-beta.3">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
@@ -8,17 +8,55 @@
|
|||||||
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
|
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
|
||||||
<PackageId>Polonium</PackageId>
|
<PackageId>Polonium</PackageId>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Version>0.0.4</Version>
|
<Version>0.1.1-x</Version>
|
||||||
<Authors>Hangman</Authors>
|
<Authors>Hangman</Authors>
|
||||||
|
<DisableImplicitRestore>true</DisableImplicitRestore>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GodotSharp" Version="4.4.0-beta.2"/>
|
<PackageReference Include="Polonium.Tasks" Version="0.1.1-x" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<Target Name="Prepare" BeforeTargets="BeforeBuild">
|
||||||
|
<RemoveDir Directories="$(ProjectDir)Package/embedded/polonium_templates" Condition="Exists('$(ProjectDir)Package/polonium_templates')"/>
|
||||||
|
<MakeDir Directories="$(ProjectDir)Package/embedded/polonium_templates"/>
|
||||||
|
<GenerateProxyNodesTask
|
||||||
|
SourceDirectory="$(ProjectDir)Package/embedded/GlobalClasses"
|
||||||
|
TemplateDirectory="$(ProjectDir)Package/embedded/polonium_templates"
|
||||||
|
AttributeName="ProxyNode"
|
||||||
|
/>
|
||||||
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Package\build\$(AssemblyName).targets" Pack="true" PackagePath="build"/>
|
<None Include="NuGet.config" />
|
||||||
</ItemGroup>
|
<None Include="Package/build/$(AssemblyName).targets" Pack="true" PackagePath="build" />
|
||||||
<ItemGroup>
|
<None Include="Package/build/$(AssemblyName).props" Pack="true" PackagePath="build" />
|
||||||
<Content Include="summerizer.py" />
|
<None Include="Package/embedded/**/*.*" Pack="true" PackagePath="build/embedded" />
|
||||||
|
<None Include="publish" />
|
||||||
|
<None Include="build" />
|
||||||
|
<Compile Remove="Package/**/*.*"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="CleanPreviousPackages" BeforeTargets="Build">
|
||||||
|
<Message Text="Cleaning Previous Packages -------------------------" Importance="high" />
|
||||||
|
<Message Text="Cleaning --------------------------------------------" Importance="high" />
|
||||||
|
<ItemGroup>
|
||||||
|
<ExistingPackages Include="$(OutputPath)*.nupkg" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Delete Files="@(ExistingPackages)" ContinueOnError="true" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="CopyPackageToLocalFeed" AfterTargets="Pack">
|
||||||
|
<Message Text="Executing Copy Task ----------------------" Importance="high" />
|
||||||
|
<Message Text="OutputPath: $(OutputPath)" Importance="high" />
|
||||||
|
<ItemGroup>
|
||||||
|
<NuGetPackages Include="$(OutputPath)*.nupkg" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Message Text="Printing pkgs--------------------" Importance="high" />
|
||||||
|
<Message Text="Pkgs: @(NuGetPackages)" Importance="high" />
|
||||||
|
<Copy SourceFiles="@(NuGetPackages)" DestinationFolder="/NuGetFeed" />
|
||||||
|
</Target>
|
||||||
|
<Target Name="RestoreNoCache" BeforeTargets="Build">
|
||||||
|
<Message Text="Restoring packages with no chache" Importance="high" />
|
||||||
|
<Exec Command="dotnet restore --no-cache" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
12
Polonium.sln
12
Polonium.sln
@@ -2,10 +2,6 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Polonium", "Polonium.csproj", "{5BA39DF8-7098-4348-A670-B3F34269F48F}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Polonium", "Polonium.csproj", "{5BA39DF8-7098-4348-A670-B3F34269F48F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Polonium.Generators", "..\Polonium.Generators\Polonium.Generators.csproj", "{41B784D2-841C-44D6-90F3-9219BC264B19}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Polonium.Generators.Test", "..\Polonium.Generators.Test\Polonium.Generators.Test.csproj", "{3BADB215-214B-41C1-B94E-89AF4A972F30}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -14,15 +10,15 @@ Global
|
|||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{5BA39DF8-7098-4348-A670-B3F34269F48F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{5BA39DF8-7098-4348-A670-B3F34269F48F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{5BA39DF8-7098-4348-A670-B3F34269F48F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{5BA39DF8-7098-4348-A670-B3F34269F48F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{5BA39DF8-7098-4348-A670-B3F34269F48F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{5BA39DF8-7098-4348-A670-B3F34269F48F}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{41B784D2-841C-44D6-90F3-9219BC264B19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{41B784D2-841C-44D6-90F3-9219BC264B19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{41B784D2-841C-44D6-90F3-9219BC264B19}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{41B784D2-841C-44D6-90F3-9219BC264B19}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{41B784D2-841C-44D6-90F3-9219BC264B19}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{41B784D2-841C-44D6-90F3-9219BC264B19}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{41B784D2-841C-44D6-90F3-9219BC264B19}.Release|Any CPU.Build.0 = Release|Any CPU
|
{41B784D2-841C-44D6-90F3-9219BC264B19}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{3BADB215-214B-41C1-B94E-89AF4A972F30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{3BADB215-214B-41C1-B94E-89AF4A972F30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{3BADB215-214B-41C1-B94E-89AF4A972F30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{3BADB215-214B-41C1-B94E-89AF4A972F30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3BADB215-214B-41C1-B94E-89AF4A972F30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{5F0664A8-563F-408A-9EB6-05B2F25F5DC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{3BADB215-214B-41C1-B94E-89AF4A972F30}.Release|Any CPU.Build.0 = Release|Any CPU
|
{5F0664A8-563F-408A-9EB6-05B2F25F5DC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{5F0664A8-563F-408A-9EB6-05B2F25F5DC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{5F0664A8-563F-408A-9EB6-05B2F25F5DC5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
9
Polonium.sln.DotSettings.user
Normal file
9
Polonium.sln.DotSettings.user
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADynamicResolver_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb71753e8d7f5410a90c2ccab6d9fac7bd1be00_003F9b_003F0c3b144f_003FDynamicResolver_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGlobalRegistry_002Eg_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F2655819e4eaf2a7f63a82a59653d80b82de731_003FGlobalRegistry_002Eg_002Ecs_002Fz_003A4_002D3/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGlobalRegistry_002Eg_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F3cc424ce28293e197699c4e55c1b4a24aac9bd75_003FGlobalRegistry_002Eg_002Ecs_002Fz_003A3_002D2/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGlobalRegistry_002Eg_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F6f3e482ddee84872fa4917a75473b425c3154e_003FGlobalRegistry_002Eg_002Ecs_002Fz_003A5_002D4/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGlobalRegistry_002Eg_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fe6fa4548b681609c78398e67b195bc2a6e96a5e_003FGlobalRegistry_002Eg_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMethodBaseInvoker_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb71753e8d7f5410a90c2ccab6d9fac7bd1be00_003Fb6_003Fb10878e7_003FMethodBaseInvoker_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=Polonium_002EGenerators_002FResources/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
17
build
Executable file
17
build
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
rm -rf ~/.nuget/packages/polonium*
|
||||||
|
cd ../Polonium.Tasks
|
||||||
|
dotnet clean Polonium.Tasks.csproj
|
||||||
|
dotnet restore Polonium.Tasks.csproj
|
||||||
|
dotnet build Polonium.Tasks.csproj
|
||||||
|
|
||||||
|
cd ../Polonium.Generators
|
||||||
|
dotnet clean Polonium.Generators.csproj
|
||||||
|
dotnet restore Polonium.Generators.csproj
|
||||||
|
dotnet build Polonium.Generators.csproj
|
||||||
|
|
||||||
|
cd ../Polonium
|
||||||
|
rm -rf ~/.nuget/packages/polonium*
|
||||||
|
dotnet clean Polonium.csproj
|
||||||
|
dotnet restore Polonium.csproj
|
||||||
|
dotnet build Polonium.csproj
|
||||||
2
publish
Normal file
2
publish
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
dotnet nuget push "$(ls -t ./.godot/mono/temp/bin/Debug/Polonium.*.nupkg | head -n 1)" --source hangman-lab
|
||||||
51
src/Agents/Agent.cs
Normal file
51
src/Agents/Agent.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
namespace Polonium.Agents;
|
||||||
|
|
||||||
|
|
||||||
|
public abstract class Agent
|
||||||
|
{
|
||||||
|
protected static int ComputerCount = 0;
|
||||||
|
|
||||||
|
public string Name { get; init; }
|
||||||
|
|
||||||
|
public Agent(string name)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
PoloniumRegistry.Instance.Agents[name] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Level { get; private set; }
|
||||||
|
public abstract int MaxLevel { get; }
|
||||||
|
|
||||||
|
public virtual void LevelUp()
|
||||||
|
{
|
||||||
|
if(Level < MaxLevel)
|
||||||
|
Level++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class Agent<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction> : Agent
|
||||||
|
where TAgent : Agent<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentDecisionMaker : AgentDecisionMaker<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentKnowledge : AgentKnowledge<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentAction : AgentAction<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
{
|
||||||
|
|
||||||
|
public Dictionary<string, TAgentAction> Actions { get; } = new();
|
||||||
|
|
||||||
|
public TAgentDecisionMaker DecisionMaker { get; init; }
|
||||||
|
public TAgentKnowledge Knowledge { get; init; }
|
||||||
|
|
||||||
|
|
||||||
|
public Agent() : base($"Computer {ComputerCount++}")
|
||||||
|
{
|
||||||
|
DecisionMaker = new TAgentDecisionMaker();
|
||||||
|
Knowledge = new TAgentKnowledge();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Agent(string name, TAgentDecisionMaker decisionMaker, TAgentKnowledge knowledge) : base(name)
|
||||||
|
{
|
||||||
|
DecisionMaker = decisionMaker;
|
||||||
|
Knowledge = knowledge;
|
||||||
|
}
|
||||||
|
}
|
||||||
60
src/Agents/AgentAction.cs
Normal file
60
src/Agents/AgentAction.cs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
using Polonium.Interfaces;
|
||||||
|
|
||||||
|
namespace Polonium.Agents;
|
||||||
|
|
||||||
|
public abstract class AgentAction
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class AgentAction<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction> : AgentAction, ITimeConsumer
|
||||||
|
where TAgent : Agent<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentDecisionMaker : AgentDecisionMaker<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentKnowledge : AgentKnowledge<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentAction : AgentAction<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
{
|
||||||
|
|
||||||
|
public int Level { get; private set; }
|
||||||
|
|
||||||
|
public abstract int MaxLevel { get; }
|
||||||
|
|
||||||
|
public virtual void LevelUp()
|
||||||
|
{
|
||||||
|
if(Level < MaxLevel)
|
||||||
|
Level++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AgentAction(double coolDown)
|
||||||
|
{
|
||||||
|
CoolDown = coolDown;
|
||||||
|
PoloniumRegistry.Instance.TimeConsumers.Add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class ActionParameter
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Execute(ActionParameter parameter)
|
||||||
|
{
|
||||||
|
if (Disabled || CoolDown > 0)
|
||||||
|
return false;
|
||||||
|
CoolDownTime = CoolDown;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private double CoolDownTime { get; set; }
|
||||||
|
public bool Disabled { get; set; }
|
||||||
|
|
||||||
|
private double CoolDown { get; }
|
||||||
|
|
||||||
|
public void Process(double delta)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (Disabled || CoolDownTime <= 0)
|
||||||
|
return;
|
||||||
|
CoolDownTime -= delta;
|
||||||
|
if (CoolDownTime <= 0)
|
||||||
|
CoolDownTime = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/Agents/AgentDecisionMaker.cs
Normal file
17
src/Agents/AgentDecisionMaker.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
namespace Polonium.Agents;
|
||||||
|
|
||||||
|
public abstract class AgentDecisionMaker<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>(DecisionMakerType type)
|
||||||
|
where TAgent : Agent<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentDecisionMaker : AgentDecisionMaker<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentKnowledge : AgentKnowledge<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentAction : AgentAction<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public DecisionMakerType Type { get; init; } = type;
|
||||||
|
|
||||||
|
public AgentDecisionMaker() : this(DecisionMakerType.Computer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
18
src/Agents/AgentKnowledge.cs
Normal file
18
src/Agents/AgentKnowledge.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace Polonium.Agents;
|
||||||
|
|
||||||
|
public abstract class AgentKnowledge
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract class AgentKnowledge<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction> : AgentKnowledge
|
||||||
|
where TAgent : Agent<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentDecisionMaker : AgentDecisionMaker<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentKnowledge : AgentKnowledge<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
where TAgentAction : AgentAction<TAgent, TAgentDecisionMaker, TAgentKnowledge, TAgentAction>, new()
|
||||||
|
{
|
||||||
|
public AgentKnowledge()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void Update(TAgentKnowledge newKnowledge);
|
||||||
|
}
|
||||||
9
src/Agents/DecisionMakerType.cs
Normal file
9
src/Agents/DecisionMakerType.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Polonium.Agents;
|
||||||
|
|
||||||
|
public enum DecisionMakerType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Player = 1,
|
||||||
|
Computer = 2,
|
||||||
|
Global = 3,
|
||||||
|
}
|
||||||
6
src/Attributes/ProxyMethod.cs
Normal file
6
src/Attributes/ProxyMethod.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Polonium.Attributes;
|
||||||
|
[AttributeUsage(AttributeTargets.Method)]
|
||||||
|
public class ProxyMethod : Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
6
src/Attributes/ProxyNode.cs
Normal file
6
src/Attributes/ProxyNode.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Polonium.Attributes;
|
||||||
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
public class ProxyNode : Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
6
src/Attributes/ProxyProperty.cs
Normal file
6
src/Attributes/ProxyProperty.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Polonium.Attributes;
|
||||||
|
[AttributeUsage(AttributeTargets.Property)]
|
||||||
|
public class ProxyProperty : Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
6
src/Attributes/RegistryEntity.cs
Normal file
6
src/Attributes/RegistryEntity.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Polonium.Attributes;
|
||||||
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
|
public class RegistryEntity : Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
9
src/DataStructures/ProgressInfo.cs
Normal file
9
src/DataStructures/ProgressInfo.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Polonium.DataStructures;
|
||||||
|
|
||||||
|
public abstract class ProgressInfo
|
||||||
|
{
|
||||||
|
public int CurrentTaskIndex { get; set; }
|
||||||
|
public int TotalTasks { get; set; }
|
||||||
|
public abstract float Progress { get; }
|
||||||
|
public string Message { get; set; }
|
||||||
|
}
|
||||||
33
src/DataStructures/TextureSet.cs
Normal file
33
src/DataStructures/TextureSet.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using Godot;
|
||||||
|
using FileAccess = Godot.FileAccess;
|
||||||
|
|
||||||
|
namespace Polonium.DataStructures;
|
||||||
|
|
||||||
|
public class TextureSet
|
||||||
|
{
|
||||||
|
public TextureSet(string path)
|
||||||
|
{
|
||||||
|
Normal = LoadTexture($"{path}/Normal");
|
||||||
|
Pressed = LoadTexture($"{path}/Pressed");
|
||||||
|
Disabled = LoadTexture($"{path}/Disabled");
|
||||||
|
Hover = LoadTexture($"{path}/Hover");
|
||||||
|
Focused = LoadTexture($"{path}/Focused");
|
||||||
|
}
|
||||||
|
public Texture2D Normal { get; init; }
|
||||||
|
public Texture2D Pressed { get; init; }
|
||||||
|
public Texture2D Hover { get; init; }
|
||||||
|
public Texture2D Disabled { get; init; }
|
||||||
|
public Texture2D Focused { get; init; }
|
||||||
|
|
||||||
|
private static Texture2D LoadTexture(string path)
|
||||||
|
{
|
||||||
|
Texture2D res = new();
|
||||||
|
if(FileAccess.FileExists($"{path}.png"))
|
||||||
|
res = ResourceLoader.Load<Texture2D>($"{path}.png");
|
||||||
|
else if(DirAccess.DirExistsAbsolute($"{path}.at_dir"))
|
||||||
|
res = Utils.LoadAnimatedTextureFromDirectory($"{path}.at_dir");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
8
src/Interfaces/IGlobalRegistry.cs
Normal file
8
src/Interfaces/IGlobalRegistry.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Polonium.Interfaces;
|
||||||
|
|
||||||
|
public interface IGlobalRegistry
|
||||||
|
{
|
||||||
|
public bool Paused { get; set; }
|
||||||
|
public void Start();
|
||||||
|
public void Prepare();
|
||||||
|
}
|
||||||
6
src/Interfaces/ITimeConsumer.cs
Normal file
6
src/Interfaces/ITimeConsumer.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Polonium.Interfaces;
|
||||||
|
|
||||||
|
public interface ITimeConsumer
|
||||||
|
{
|
||||||
|
public void Process(double time);
|
||||||
|
}
|
||||||
29
src/Managers/LoaderManager.cs
Normal file
29
src/Managers/LoaderManager.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using Polonium.DataStructures;
|
||||||
|
|
||||||
|
namespace Polonium.Managers;
|
||||||
|
|
||||||
|
public abstract class LoaderManager<T>
|
||||||
|
where T : ProgressInfo
|
||||||
|
{
|
||||||
|
public bool Started { get; private set; } = false;
|
||||||
|
public bool Finished { get; protected set; } = false;
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
if(Started)
|
||||||
|
throw new InvalidOperationException("Loader is already started");
|
||||||
|
Started = true;
|
||||||
|
Thread load = new Thread(LoadTask);
|
||||||
|
load.Start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract T QueryProgress();
|
||||||
|
|
||||||
|
public abstract void Load();
|
||||||
|
|
||||||
|
public void LoadTask()
|
||||||
|
{
|
||||||
|
Load();
|
||||||
|
Finished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/PoloniumRegistry.cs
Normal file
25
src/PoloniumRegistry.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using Godot;
|
||||||
|
using Polonium.Agents;
|
||||||
|
using Polonium.Interfaces;
|
||||||
|
using Polonium.Resources;
|
||||||
|
|
||||||
|
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 Config Config { get; set; }
|
||||||
|
public Save Save { get; set; }
|
||||||
|
|
||||||
|
public static void Prepare()
|
||||||
|
{
|
||||||
|
DirAccess.MakeDirAbsolute("user://saves");
|
||||||
|
}
|
||||||
|
public Dictionary<string, Agent> Agents { get; set; } = new();
|
||||||
|
|
||||||
|
public HashSet<ITimeConsumer> TimeConsumers { get; set; } = new();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
16
src/Resources/Config.cs
Normal file
16
src/Resources/Config.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Polonium.Resources;
|
||||||
|
|
||||||
|
public partial class Config: Resource
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
public void Save() => ResourceSaver.Save(this, "user://Config.tres");
|
||||||
|
|
||||||
|
public static void Load<T>()
|
||||||
|
where T : Config, new()
|
||||||
|
{
|
||||||
|
PoloniumRegistry.Instance.Config = ResourceLoader.Load<T>("user://Config.tres") ?? new T();
|
||||||
|
}
|
||||||
|
}
|
||||||
49
src/Resources/Save.cs
Normal file
49
src/Resources/Save.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Polonium.Resources;
|
||||||
|
|
||||||
|
public abstract partial class Save : Resource
|
||||||
|
{
|
||||||
|
[Export]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public abstract class Preview
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveToUser() => ResourceSaver.Save(this, $"user://saves/{Name}.tres");
|
||||||
|
|
||||||
|
public static void LoadFromUser<T>(string name)
|
||||||
|
where T : Save, new()
|
||||||
|
{
|
||||||
|
T res = ResourceLoader.Load<T>($"user://saves/{name}.tres");
|
||||||
|
if (res is null)
|
||||||
|
{
|
||||||
|
res = new T();
|
||||||
|
res.Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
PoloniumRegistry.Instance.Save = res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Load() => PoloniumRegistry.Instance.Save = this;
|
||||||
|
|
||||||
|
public static IEnumerable<T> ListSaves<T>()
|
||||||
|
where T : Save
|
||||||
|
{
|
||||||
|
DirAccess dir = DirAccess.Open("user://saves");
|
||||||
|
if(dir is null)
|
||||||
|
{
|
||||||
|
DirAccess.MakeDirRecursiveAbsolute("user://saves");
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string save in dir.GetFiles())
|
||||||
|
{
|
||||||
|
if(!save.EndsWith(".tres"))
|
||||||
|
continue;
|
||||||
|
yield return ResourceLoader.Load<T>($"user://saves/{save}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Polonium.Scenes;
|
|
||||||
|
|
||||||
public abstract partial class CameraScene : Scene
|
|
||||||
{
|
|
||||||
private Camera2D Camera { get; set; }
|
|
||||||
protected abstract float MaxZoom { get; }
|
|
||||||
protected abstract float MinZoom { get; }
|
|
||||||
protected abstract float ZoomRate { get; }
|
|
||||||
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() => Mathf.Max(Zoom * (1 + ZoomRate), MaxZoom);
|
|
||||||
protected void ZoomOut() => Mathf.Min(Zoom * (1 - ZoomRate), MinZoom);
|
|
||||||
protected void ZoomAt(Vector2 pos) => Camera.Position = pos;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Polonium.Scenes;
|
|
||||||
|
|
||||||
public abstract partial class RootScene : Node2D
|
|
||||||
{
|
|
||||||
private Polonium.Scenes.Scene CurrentScene { get; set; }
|
|
||||||
|
|
||||||
public void SwitchScene(Polonium.Scenes.Scene scene)
|
|
||||||
{
|
|
||||||
if (CurrentScene != null)
|
|
||||||
RemoveChild(CurrentScene);
|
|
||||||
AddChild(scene);
|
|
||||||
CurrentScene = scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Polonium.Scenes;
|
|
||||||
|
|
||||||
public abstract partial class Scene : Node2D
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
31
src/Utils.cs
31
src/Utils.cs
@@ -1,4 +1,7 @@
|
|||||||
|
#pragma warning disable CS0618
|
||||||
|
#pragma warning disable CS0168
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
namespace Polonium;
|
namespace Polonium;
|
||||||
|
|
||||||
@@ -15,4 +18,32 @@ public static class Utils
|
|||||||
return e.Types.Where(t => t != null);
|
return e.Types.Where(t => t != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Dictionary<StringName, AnimatedTexture> AnimatedTextureCache { get; } = new();
|
||||||
|
|
||||||
|
public static AnimatedTexture LoadAnimatedTextureFromDirectory(StringName path)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!AnimatedTextureCache.ContainsKey(path))
|
||||||
|
{
|
||||||
|
AnimatedTextureCache[path] = new AnimatedTexture();
|
||||||
|
int f = 0;
|
||||||
|
foreach (string fname in DirAccess.GetFilesAt(path))
|
||||||
|
{
|
||||||
|
if (!fname.EndsWith(".png"))
|
||||||
|
continue;
|
||||||
|
AnimatedTextureCache[path].SetFrameTexture(f, ResourceLoader.Load<Texture2D>(fname));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return AnimatedTextureCache[path];
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma warning restore CS0618
|
||||||
|
#pragma warning restore CS0168
|
||||||
Reference in New Issue
Block a user