Compare commits
9 Commits
draft_text
...
8df4ebb6d5
| Author | SHA1 | Date | |
|---|---|---|---|
| 8df4ebb6d5 | |||
| 92770d3425 | |||
| 50ca3f75ec | |||
| 0e00bacfeb | |||
| ee4e489219 | |||
| d720b03480 | |||
| 2c32af6b42 | |||
| b21023ba24 | |||
| 2d0b25f65c |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -3,3 +3,9 @@ obj/
|
||||
/packages/
|
||||
riderModule.iml
|
||||
/_ReSharper.Caches/
|
||||
Package/embedded/polonium_templates/
|
||||
Package/embedded/Patches/RegistryPassThrough.p.cs
|
||||
VersionInfo.props
|
||||
Polonium.sln.DotSettings.user
|
||||
.godot
|
||||
.idea
|
||||
13
.idea/.idea.Polonium/.idea/.gitignore
generated
vendored
13
.idea/.idea.Polonium/.idea/.gitignore
generated
vendored
@@ -1,13 +0,0 @@
|
||||
# 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
4
.idea/.idea.Polonium/.idea/encodings.xml
generated
@@ -1,4 +0,0 @@
|
||||
<?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
8
.idea/.idea.Polonium/.idea/indexLayout.xml
generated
@@ -1,8 +0,0 @@
|
||||
<?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
7
.idea/.idea.Polonium/.idea/vcs.xml
generated
@@ -1,7 +0,0 @@
|
||||
<?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>
|
||||
@@ -9,6 +9,7 @@
|
||||
<Compile Remove="script_templates/**/*.*"/>
|
||||
<Compile Remove="embedded/polonium_templates/**/*.cs"/>
|
||||
<AdditionalFiles Include="Assets/**/*.tscn"/>
|
||||
<AdditionalFiles Include="Data/**/*" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PoloniumPrepare" BeforeTargets="PoloniumClean">
|
||||
@@ -41,8 +42,16 @@
|
||||
<EmbeddedFiles Include="$(MSBuildThisFileDirectory)embedded/**/*.*"/>
|
||||
</ItemGroup>
|
||||
<Copy
|
||||
SourceFiles="@(EmbeddedFiles)"
|
||||
DestinationFolder="$(ProjectDir)embedded/%(RecursiveDir)"
|
||||
SourceFiles="@(EmbeddedFiles)"
|
||||
DestinationFolder="$(ProjectDir)embedded/%(RecursiveDir)"
|
||||
/>
|
||||
<Copy
|
||||
SourceFiles="$(MSBuildThisFileDirectory)editorconfig"
|
||||
DestinationFiles="$(ProjectDir).editorconfig"
|
||||
/>
|
||||
<Copy
|
||||
SourceFiles="$(MSBuildThisFileDirectory)gitignore"
|
||||
DestinationFiles="$(ProjectDir)embedded/.gitignore"
|
||||
/>
|
||||
<ItemGroup>
|
||||
<PoloniumTemplateFiles Include="$(MSBuildThisFileDirectory)embedded/polonium_templates/**/*.*" />
|
||||
|
||||
2
Package/build/editorconfig
Normal file
2
Package/build/editorconfig
Normal file
@@ -0,0 +1,2 @@
|
||||
[embedded/*]
|
||||
generated_code = true
|
||||
1
Package/build/gitignore
Normal file
1
Package/build/gitignore
Normal file
@@ -0,0 +1 @@
|
||||
*
|
||||
@@ -17,6 +17,17 @@ public partial class PoloniumTextureButton : TextureButton
|
||||
|
||||
private GlobalRegistry.TextureSetName PrivateTextureSetName { get; set; }
|
||||
|
||||
public bool ButtonDisabled
|
||||
{
|
||||
get => Disabled;
|
||||
set
|
||||
{
|
||||
Disabled = value;
|
||||
FocusMode = Disabled ? FocusMode = Control.FocusModeEnum.None : FocusMode = Control.FocusModeEnum.All;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Export]
|
||||
public GlobalRegistry.TextureSetName TextureSetName
|
||||
{
|
||||
@@ -24,7 +35,7 @@ public partial class PoloniumTextureButton : TextureButton
|
||||
set
|
||||
{
|
||||
PrivateTextureSetName = value;
|
||||
t = GlobalRegistry.TextureSetMap.GetValueOrDefault(value, null);
|
||||
TextureSet t = GlobalRegistry.TextureSetMap.GetValueOrDefault(value, null);
|
||||
if (t is not null)
|
||||
{
|
||||
TextureNormal = t.Normal;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class MouseControlledCamera : Camera2D
|
||||
{
|
||||
private Vector2 DragStartPosition { get; set; }
|
||||
private bool IsDragging { get; set; }
|
||||
[Signal]
|
||||
public delegate void ZoomInEventHandler();
|
||||
[Signal]
|
||||
public delegate void ZoomOutEventHandler();
|
||||
|
||||
[Export]
|
||||
public MouseButton DragButton { get; set; } = MouseButton.Middle;
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventMouseButton mouseButtonEvent)
|
||||
{
|
||||
if(mouseButtonEvent.ButtonIndex == MouseButton.WheelUp)
|
||||
EmitSignalZoomIn();
|
||||
else if(mouseButtonEvent.ButtonIndex == MouseButton.WheelDown)
|
||||
EmitSignalZoomOut();
|
||||
else if (mouseButtonEvent.ButtonIndex == DragButton)
|
||||
{
|
||||
IsDragging = mouseButtonEvent.Pressed;
|
||||
if(IsDragging)
|
||||
DragStartPosition = GetGlobalMousePosition();
|
||||
}
|
||||
}
|
||||
else if (@event is InputEventMouseMotion mouseMotionEvent && IsDragging)
|
||||
{
|
||||
Vector2 mousePos = GetGlobalMousePosition();
|
||||
Vector2 offset = DragStartPosition - mousePos;
|
||||
Position += offset;
|
||||
DragStartPosition = mousePos;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,12 +7,12 @@ namespace GlobalClasses;
|
||||
[Tool]
|
||||
public partial class CameraScene : Scene
|
||||
{
|
||||
private Camera2D Camera { get; set; }
|
||||
|
||||
protected Camera2D Camera { get; set; }
|
||||
[Export]
|
||||
public float MaxZoom { get; set; }
|
||||
|
||||
[Export]
|
||||
public float MinZoom { get; set; }
|
||||
|
||||
[Export]
|
||||
public float ZoomRate { get; set; }
|
||||
|
||||
private float Zoom
|
||||
@@ -26,13 +26,18 @@ public partial class CameraScene : Scene
|
||||
{
|
||||
}
|
||||
|
||||
public sealed override void _Ready()
|
||||
protected virtual void _Ready_()
|
||||
{
|
||||
Camera = GetNode<Camera2D>("Camera");
|
||||
}
|
||||
|
||||
public sealed override void _Ready()
|
||||
{
|
||||
_Ready_();
|
||||
__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 ZoomIn() => Zoom = Mathf.Min(Zoom * (1 + ZoomRate), MaxZoom);
|
||||
protected void ZoomOut() => Zoom = Mathf.Max(Zoom * (1 - ZoomRate), MinZoom);
|
||||
protected void ZoomAt(Vector2 pos) => Camera.Position = pos;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
// ReSharper disable once CheckNamespace
|
||||
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class MouseControlledCameraScene : CameraScene
|
||||
{
|
||||
protected new MouseControlledCamera Camera
|
||||
{
|
||||
get => base.Camera as MouseControlledCamera;
|
||||
set => base.Camera = value;
|
||||
}
|
||||
|
||||
protected sealed override void _Ready_()
|
||||
{
|
||||
Camera = GetNode<MouseControlledCamera>("Camera");
|
||||
Camera.ZoomIn += ZoomIn;
|
||||
Camera.ZoomOut += ZoomOut;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Godot;
|
||||
using Polonium.Attributes;
|
||||
|
||||
namespace GlobalClasses;
|
||||
[ProxyNode]
|
||||
[GlobalClass]
|
||||
[Tool]
|
||||
public partial class SelectableTileMapLayer : TileMapLayer
|
||||
{
|
||||
[Signal]
|
||||
public delegate void CellSelectedEventHandler(Vector2I pos);
|
||||
|
||||
[Signal]
|
||||
public delegate void CellEnteredEventHandler(Vector2I pos);
|
||||
private Vector2I HoveredCell { get; set; } = new Vector2I(-1, -1);
|
||||
|
||||
public sealed override void _Process(double delta)
|
||||
{
|
||||
|
||||
Vector2 mousePos = GetGlobalMousePosition();
|
||||
Vector2 localMousePos = ToLocal(mousePos);
|
||||
Vector2I cell = LocalToMap(localMousePos);
|
||||
if(cell != HoveredCell)
|
||||
{
|
||||
EmitSignalCellEntered(cell);
|
||||
HoveredCell = cell;
|
||||
}
|
||||
__Process(delta);
|
||||
base._Process(delta);
|
||||
}
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (@event is InputEventMouseButton mouseEvent)
|
||||
if (mouseEvent.ButtonIndex == MouseButton.Left && mouseEvent.Pressed)
|
||||
EmitSignalCellSelected(HoveredCell);
|
||||
}
|
||||
[ProxyMethod]
|
||||
public virtual void __Process(double delta)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,6 @@ public static partial class GlobalRegistry
|
||||
}
|
||||
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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<Project Sdk="Godot.NET.Sdk/4.4.0-beta.3">
|
||||
|
||||
<Import Project="VersionInfo.props" Condition="Exists('VersionInfo.props')" />
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
@@ -8,12 +8,13 @@
|
||||
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
|
||||
<PackageId>Polonium</PackageId>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<Version>0.1.1-x</Version>
|
||||
<Version>$(PoloniumVersion)</Version>
|
||||
<Authors>Hangman</Authors>
|
||||
<DisableImplicitRestore>true</DisableImplicitRestore>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Polonium.Tasks" Version="0.1.1-x" />
|
||||
<PackageReference Include="Polonium.Tasks" Version="$(PoloniumTasksVersion)" />
|
||||
<None Include="VersionInfo.props" Pack="true" PackagePath="build" Condition="Exists('VersionInfo.props')" />
|
||||
</ItemGroup>
|
||||
<Target Name="Prepare" BeforeTargets="BeforeBuild">
|
||||
<RemoveDir Directories="$(ProjectDir)Package/embedded/polonium_templates" Condition="Exists('$(ProjectDir)Package/polonium_templates')"/>
|
||||
@@ -23,16 +24,23 @@
|
||||
TemplateDirectory="$(ProjectDir)Package/embedded/polonium_templates"
|
||||
AttributeName="ProxyNode"
|
||||
/>
|
||||
<Delete
|
||||
Files="$(ProjectDir)Package/embedded/RegistryPassThrough.p.cs"
|
||||
Condition="Exists('$(ProjectDir)Package/embedded/RegistryPassThrough.p.cs')"
|
||||
/>
|
||||
<GenerateRegistryPassThrough ProjectDir="$(ProjectDir)" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="NuGet.config" />
|
||||
<None Include="Package/build/$(AssemblyName).targets" Pack="true" PackagePath="build" />
|
||||
<None Include="Package/build/$(AssemblyName).props" Pack="true" PackagePath="build" />
|
||||
<None Include="Package/build/**/*" Pack="true" PackagePath="build" />
|
||||
<None Include="Package/embedded/**/*.*" Pack="true" PackagePath="build/embedded" />
|
||||
<None Include="publish" />
|
||||
<None Include="build" />
|
||||
<Compile Remove="Package/**/*.*"/>
|
||||
<Compile Remove="Package/**/*.*" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Package\build\editorconfig" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="CleanPreviousPackages" BeforeTargets="Build">
|
||||
@@ -57,6 +65,7 @@
|
||||
<Target Name="RestoreNoCache" BeforeTargets="Build">
|
||||
<Message Text="Restoring packages with no chache" Importance="high" />
|
||||
<Exec Command="dotnet restore --no-cache" />
|
||||
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
||||
17
build
17
build
@@ -1,17 +0,0 @@
|
||||
#! /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
|
||||
13
publish
Normal file → Executable file
13
publish
Normal file → Executable file
@@ -1,2 +1,13 @@
|
||||
#!/bin/bash
|
||||
dotnet nuget push "$(ls -t ./.godot/mono/temp/bin/Debug/Polonium.*.nupkg | head -n 1)" --source hangman-lab
|
||||
|
||||
SCRIPT_DIR=$(dirname "$(realpath "${BASH_SOURCE[0]}")")/
|
||||
LATEST_PACKAGE=$(ls -t "${SCRIPT_DIR}".godot/mono/temp/bin/Debug/Polonium.*.nupkg 2>/dev/null | head -n 1)
|
||||
|
||||
if [[ -z "$LATEST_PACKAGE" ]]; then
|
||||
echo "❌ Error: No .nupkg file found in ${SCRIPT_DIR}/bin/Debug/"
|
||||
exit 1
|
||||
fi
|
||||
echo "🚀 Pushing NuGet package: $LATEST_PACKAGE"
|
||||
dotnet nuget push "$LATEST_PACKAGE" --source hangman-lab
|
||||
|
||||
|
||||
|
||||
6
src/Attributes/RegistryPassThrough.cs
Normal file
6
src/Attributes/RegistryPassThrough.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Polonium.Attributes;
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class RegistryPassThrough(bool getterOnly = false) : Attribute
|
||||
{
|
||||
public bool GetterOnly { get; set; } = getterOnly;
|
||||
}
|
||||
9
src/Attributes/TemplateDefines/TemplateBlock.cs
Normal file
9
src/Attributes/TemplateDefines/TemplateBlock.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Polonium.Attributes.TemplateDefines;
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class TemplateBlock(string signature, string template, string dataFile, string deps="") : Attribute
|
||||
{
|
||||
public string Signature { get; set; } = signature;
|
||||
public string Template { get; set; } = template;
|
||||
public string DataFile { get; set; } = dataFile;
|
||||
public string Deps { get; set; } = deps;
|
||||
}
|
||||
9
src/Attributes/TemplateDefines/TemplateInline.cs
Normal file
9
src/Attributes/TemplateDefines/TemplateInline.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Polonium.Attributes.TemplateDefines;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
|
||||
public class TemplateInline(string template, string dataFile, string deps="") : Attribute
|
||||
{
|
||||
public string Template { get; set; } = template;
|
||||
public string DataFile { get; set; } = dataFile;
|
||||
public string Deps { get; set; } = deps;
|
||||
}
|
||||
12
src/Extensions/LinqExtensions.cs
Normal file
12
src/Extensions/LinqExtensions.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Godot;
|
||||
|
||||
namespace Polonium.Extensions;
|
||||
|
||||
public static class LinqExtensions
|
||||
{
|
||||
public static T RandomSelect<T>(this IEnumerable<T> source)
|
||||
{
|
||||
T[] s = source.ToArray();
|
||||
return s[GD.Randi() % s.Length];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Godot;
|
||||
using Polonium.Agents;
|
||||
using Polonium.Attributes;
|
||||
using Polonium.Interfaces;
|
||||
using Polonium.Resources;
|
||||
|
||||
@@ -7,19 +8,24 @@ namespace Polonium;
|
||||
|
||||
public class PoloniumRegistry
|
||||
{
|
||||
public static IGlobalRegistry GlobalRegistry { get; set; }
|
||||
private static PoloniumRegistry InternalInstance { get; set; }
|
||||
public static PoloniumRegistry Instance => InternalInstance ??= new PoloniumRegistry();
|
||||
[RegistryPassThrough]
|
||||
public Config Config { get; set; }
|
||||
[RegistryPassThrough]
|
||||
public Save Save { get; set; }
|
||||
|
||||
public static void Prepare()
|
||||
{
|
||||
DirAccess.MakeDirAbsolute("user://saves");
|
||||
}
|
||||
public Dictionary<string, Agent> Agents { get; set; } = new();
|
||||
// ReSharper disable once CollectionNeverQueried.Global
|
||||
[RegistryPassThrough(true)]
|
||||
public Dictionary<string, Agent> Agents { get; } = new();
|
||||
|
||||
public HashSet<ITimeConsumer> TimeConsumers { get; set; } = new();
|
||||
// ReSharper disable once CollectionNeverQueried.Global
|
||||
[RegistryPassThrough(true)]
|
||||
public HashSet<ITimeConsumer> TimeConsumers { get; } = new();
|
||||
|
||||
|
||||
}
|
||||
@@ -33,8 +33,13 @@ public static class Utils
|
||||
{
|
||||
if (!fname.EndsWith(".png"))
|
||||
continue;
|
||||
AnimatedTextureCache[path].SetFrameTexture(f, ResourceLoader.Load<Texture2D>(fname));
|
||||
AnimatedTextureCache[path].SetFrameTexture(f, ResourceLoader.Load<Texture2D>($"{path}/{fname}"));
|
||||
f += 1;
|
||||
}
|
||||
|
||||
AnimatedTextureCache[path].SetFrames(f + 1);
|
||||
AnimatedTextureCache[path].SetOneShot(false);
|
||||
AnimatedTextureCache[path].SetSpeedScale(4);
|
||||
}
|
||||
|
||||
return AnimatedTextureCache[path];
|
||||
@@ -44,6 +49,7 @@ public static class Utils
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#pragma warning restore CS0618
|
||||
#pragma warning restore CS0168
|
||||
Reference in New Issue
Block a user