Client: a Godot 4.7.2 C# project over BodyPainBoxSession, Godot physics set to Dummy, ymir_box3d resolver
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e4b1b4e1a3
commit
4f1686e096
4 changed files with 90 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
bin/
|
||||
obj/
|
||||
client/.godot/
|
||||
|
|
|
|||
13
client/BadDay.Client.csproj
Normal file
13
client/BadDay.Client.csproj
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<Project Sdk="Godot.NET.Sdk/4.7.2">
|
||||
<!-- The Godot client: presentation and input over BodyPainBoxSession. Building it builds Lodur, Ymir (cmake and a C compiler) and BDS into .godot/mono/temp/bin/Debug. -->
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyName>BadDay.Client</AssemblyName>
|
||||
<RootNamespace>BadDay.Client</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\src\BadDay.Ymir\BadDay.Ymir.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
43
client/NativeLibraries.cs
Normal file
43
client/NativeLibraries.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Godot;
|
||||
using Ymir.Box3D;
|
||||
|
||||
namespace BadDay.Client;
|
||||
|
||||
/// <summary>
|
||||
/// Finds ymir_box3d for Ymir.Box3D's DllImports. Godot loads game assemblies into its own load context, so the
|
||||
/// default probing does not look beside them. A run from the editor or <c>--path</c> loads the library from the
|
||||
/// project's build directory; an exported run from the data folder Godot puts beside the executable.
|
||||
/// </summary>
|
||||
internal static class NativeLibraries
|
||||
{
|
||||
private const string Library = "ymir_box3d";
|
||||
|
||||
#pragma warning disable CA2255 // application code: the resolver must exist before the first DllImport
|
||||
[ModuleInitializer]
|
||||
internal static void Register() =>
|
||||
NativeLibrary.SetDllImportResolver(typeof(Box3DSoaWorld).Assembly, Resolve);
|
||||
|
||||
private static IntPtr Resolve(string name, Assembly assembly, DllImportSearchPath? searchPath)
|
||||
{
|
||||
if (name != Library) return IntPtr.Zero;
|
||||
string dir = OS.HasFeature("template")
|
||||
? Path.Combine(Path.GetDirectoryName(OS.GetExecutablePath())!, $"data_BadDay.Client_{Platform()}_{Arch()}")
|
||||
: ProjectSettings.GlobalizePath("res://.godot/mono/temp/bin/Debug");
|
||||
string path = Path.Combine(dir, FileName());
|
||||
return File.Exists(path) && NativeLibrary.TryLoad(path, out var handle) ? handle : IntPtr.Zero;
|
||||
}
|
||||
|
||||
private static string FileName() =>
|
||||
OperatingSystem.IsWindows() ? "ymir_box3d.dll" : OperatingSystem.IsMacOS() ? "libymir_box3d.dylib" : "libymir_box3d.so";
|
||||
|
||||
private static string Platform() =>
|
||||
OperatingSystem.IsWindows() ? "windows" : OperatingSystem.IsMacOS() ? "macos" : "linuxbsd";
|
||||
|
||||
private static string Arch() =>
|
||||
RuntimeInformation.ProcessArchitecture == System.Runtime.InteropServices.Architecture.Arm64 ? "arm64" : "x86_64";
|
||||
}
|
||||
33
client/project.godot
Normal file
33
client/project.godot
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="Bad Day Simulator"
|
||||
run/main_scene="res://Main.tscn"
|
||||
config/features=PackedStringArray("4.7", "C#")
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1280
|
||||
window/size/viewport_height=720
|
||||
window/stretch/mode="canvas_items"
|
||||
|
||||
[dotnet]
|
||||
|
||||
project/assembly_name="BadDay.Client"
|
||||
|
||||
[physics]
|
||||
|
||||
; Godot's physics is switched off: Ymir is the only physics world. The client ticks BodyPainBoxSession at 120 Hz.
|
||||
3d/physics_engine="Dummy"
|
||||
common/physics_ticks_per_second=120
|
||||
common/physics_interpolation=true
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
||||
Loading…
Reference in a new issue