add: Scene

This commit is contained in:
h z
2025-02-05 15:01:43 +00:00
parent 3b62b0a348
commit c47c2088cf
6 changed files with 66 additions and 0 deletions

View File

@@ -6,9 +6,17 @@
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute> <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<PackageId>Hangman.SDK</PackageId>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.1</Version>
<Authors>Hangman</Authors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="GodotSharp" Version="4.4.0-beta.2"/> <PackageReference Include="GodotSharp" Version="4.4.0-beta.2"/>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="build\.targets" Pack="true" PackagePath="build\.targets"/>
<Content Include="build\publish"/>
</ItemGroup>
</Project> </Project>

11
build/.targets Normal file
View File

@@ -0,0 +1,11 @@
<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>
</Project>

2
build/publish Normal file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
dotnet nuget push "$(ls -t ../.godot/mono/temp/bin/Debug/Hangman.SDK.*.nupkg | head -n 1)" --source hangman-lab

19
src/Scenes/RootScene.cs Normal file
View File

@@ -0,0 +1,19 @@
using Godot;
namespace Hangman.SDK.Scenes;
public abstract partial class RootScene : Node2D
{
private Scene CurrentScene { get; set; }
public void SwitchScene(Scene scene)
{
if (CurrentScene != null)
RemoveChild(CurrentScene);
AddChild(scene);
CurrentScene = scene;
}
}

8
src/Scenes/Scene.cs Normal file
View File

@@ -0,0 +1,8 @@
using Godot;
namespace Hangman.SDK.Scenes;
public abstract partial class Scene : Node2D
{
}

18
src/Utils.cs Normal file
View File

@@ -0,0 +1,18 @@
using System.Reflection;
namespace Hangman.SDK;
public static class Utils
{
public static IEnumerable<Type> GetLoadableTypes(Assembly assembly)
{
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
return e.Types.Where(t => t != null);
}
}
}