feat: add Godot C# compatibility and shared codegen weaving
Validate ShrinkSDK Workspace / unity (push) Failing after 3m18s
Validate ShrinkSDK Workspace / unity (push) Failing after 3m18s
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource path="res://SampleRoot.cs" type="Script" id="1"]
|
||||
|
||||
[node name="SampleRoot" type="Node"]
|
||||
script = ExtResource("1")
|
||||
@@ -0,0 +1,124 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
using ShrinkApp;
|
||||
using ShrinkApp.Starter.Basic;
|
||||
using ShrinkCommand;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using ShrinkDataSaver;
|
||||
using ShrinkEventBus;
|
||||
using ShrinkNetwork;
|
||||
using ShrinkSDK.Godot;
|
||||
using ShrinkTutorial;
|
||||
|
||||
public partial class SampleRoot : ShrinkGodotHost
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
RunSmokeAsync().Forget();
|
||||
}
|
||||
|
||||
private async UniTaskVoid RunSmokeAsync()
|
||||
{
|
||||
var marker = RequireWoven(GetType().Assembly);
|
||||
using var binding = EventBus.Attach(new GodotSubscriber());
|
||||
EventBus.Post(new GodotSmokeEvent());
|
||||
var assembly = GetType().Assembly;
|
||||
var registries = assembly.GetCustomAttributes(false).Select(value => value.GetType().Name).ToHashSet();
|
||||
var savedValue = 42;
|
||||
ShrinkDataSaverRuntime.Initialize(new ShrinkDataSaverRuntimeConfig
|
||||
{
|
||||
RootPath = PersistentDataPath,
|
||||
CurrentSaveVersion = 1
|
||||
});
|
||||
ShrinkSave.RegisterModule("godot-smoke", () => savedValue, value => savedValue = value);
|
||||
await ShrinkSave.SaveSlotAsync(0, new SaveOptions { SlotName = "Godot Smoke" });
|
||||
savedValue = 0;
|
||||
await ShrinkSave.LoadSlotAsync(0);
|
||||
var app = await StartAppAsync();
|
||||
var composition = ShrinkBasicComposition.CreateHost(app.Context.Services);
|
||||
var entries = ShrinkBasicComposition.CreateEntries(app.Context.Services);
|
||||
await composition.ApplyAsync(entries);
|
||||
await composition.ApplyAsync(entries);
|
||||
var activeFibers = composition.Runtime.Fibers.Count(fiber => fiber.State == ShrinkContext.ShrinkFiberState.Active);
|
||||
var tutorialStorage = new MemoryTutorialStorage();
|
||||
var tutorial = new ShrinkTutorialRunner(tutorialStorage);
|
||||
var tutorialStarted = tutorial.Start(new ShrinkTutorialData
|
||||
{
|
||||
TutorialId = "godot-smoke",
|
||||
Steps = { new ShrinkTutorialStep { StepId = "one", CompleteCondition = ShrinkTutorialCompleteCondition.AnyClick } }
|
||||
});
|
||||
var tutorialCompleted = tutorial.CompleteStep();
|
||||
|
||||
if (GodotSubscriber.Calls != 1 || GodotStaticSubscriber.Calls != 1 || savedValue != 42 ||
|
||||
!app.IsRunning || !GodotInstaller.Initialized ||
|
||||
activeFibers != 3 || !tutorialStarted || !tutorialCompleted || !tutorialStorage.Saved ||
|
||||
!registries.Contains(nameof(ShrinkCommandStaticRegistryAttribute)) ||
|
||||
!registries.Contains(nameof(ShrinkNetworkMessageRegistryAttribute)))
|
||||
{
|
||||
GD.PushError("ShrinkSDK Godot smoke failed.");
|
||||
GetTree().Quit(1);
|
||||
return;
|
||||
}
|
||||
await composition.ShutdownAsync();
|
||||
var smokePath = System.IO.Path.Combine(OS.GetUserDataDir(), "shrink_smoke_pass.txt");
|
||||
System.IO.File.WriteAllText(smokePath, $"CodeGen={marker.WeaverVersion};DataSaver={savedValue}");
|
||||
if (!System.IO.File.Exists(smokePath))
|
||||
throw new System.IO.IOException($"Failed to create smoke sentinel: {smokePath}");
|
||||
GD.Print($"SHRINK_GODOT_SMOKE_PASS CodeGen={marker.WeaverVersion} DataSaver={savedValue}");
|
||||
GetTree().Quit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class MemoryTutorialStorage : IShrinkTutorialStorage
|
||||
{
|
||||
private ShrinkTutorialProgress _progress = new();
|
||||
public bool Saved { get; private set; }
|
||||
public ShrinkTutorialProgress Load() => _progress;
|
||||
public void Save(ShrinkTutorialProgress progress) { _progress = progress; Saved = true; }
|
||||
public void Reset() { _progress = new ShrinkTutorialProgress(); Saved = false; }
|
||||
}
|
||||
|
||||
public readonly struct GodotSmokeEvent : IShrinkEvent { }
|
||||
|
||||
[ShrinkEventSubscriber]
|
||||
public sealed class GodotSubscriber
|
||||
{
|
||||
public static int Calls;
|
||||
[ShrinkSubscribe] private void Handle(GodotSmokeEvent value) => Calls++;
|
||||
}
|
||||
|
||||
[ShrinkEventSubscriber]
|
||||
public static class GodotStaticSubscriber
|
||||
{
|
||||
public static int Calls;
|
||||
[ShrinkSubscribe] private static void Handle(GodotSmokeEvent value) => Calls++;
|
||||
}
|
||||
|
||||
[ShrinkCommandSubscriber]
|
||||
public static class GodotCommands
|
||||
{
|
||||
[ShrinkCommand("godot/smoke")] public static void Smoke() { }
|
||||
}
|
||||
|
||||
[ShrinkNetworkMessage(42001, "godot/smoke")]
|
||||
public sealed class GodotSmokeMessage : IShrinkNetworkMessage { }
|
||||
|
||||
[ShrinkAppModuleInstaller]
|
||||
public sealed class GodotInstaller : IShrinkAppModuleInstaller
|
||||
{
|
||||
public static bool Initialized;
|
||||
public string ModuleId => "godot-smoke";
|
||||
public int Order => 0;
|
||||
public IReadOnlyList<string> DependsOn => Array.Empty<string>();
|
||||
public void RegisterServices(ShrinkAppContext context) => context.Services.Register(this);
|
||||
public UniTask InitializeAsync(ShrinkAppContext context)
|
||||
{
|
||||
Initialized = true;
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://j565ln7hmg6i
|
||||
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Godot.NET.Sdk/4.6.3">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||
<ShrinkCodeGenEnabled>true</ShrinkCodeGenEnabled>
|
||||
<_ShrinkCodeGenTaskAssembly>$(MSBuildThisFileDirectory)..\..\CodeGen\ShrinkSDK.CodeGen.Task\bin\$(Configuration)\net8.0\ShrinkSDK.CodeGen.Task.dll</_ShrinkCodeGenTaskAssembly>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Packages\ShrinkSDK.Runtime.Abstractions\ShrinkSDK.Runtime.Abstractions.csproj" />
|
||||
<ProjectReference Include="..\..\Packages\ShrinkSDK.EventBus\ShrinkSDK.EventBus.csproj" />
|
||||
<ProjectReference Include="..\..\Packages\ShrinkSDK.Command\ShrinkSDK.Command.csproj" />
|
||||
<ProjectReference Include="..\..\Packages\ShrinkSDK.Network\ShrinkSDK.Network.csproj" />
|
||||
<ProjectReference Include="..\..\Packages\ShrinkSDK.Godot\ShrinkSDK.Godot.csproj" />
|
||||
<ProjectReference Include="..\..\Packages\ShrinkSDK.App.Starter.Basic\ShrinkSDK.App.Starter.Basic.csproj" />
|
||||
<ProjectReference Include="..\..\Packages\ShrinkSDK.Tutorial\ShrinkSDK.Tutorial.csproj" />
|
||||
<ProjectReference Include="..\..\Packages\ShrinkSDK.Tutorial.Godot\ShrinkSDK.Tutorial.Godot.csproj" />
|
||||
<ProjectReference Include="..\..\CodeGen\ShrinkSDK.CodeGen.Task\ShrinkSDK.CodeGen.Task.csproj" ReferenceOutputAssembly="false" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\CodeGen\ShrinkSDK.CodeGen.Task\buildTransitive\ShrinkSDK.CodeGen.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShrinkSDK.Godot.Sample", "ShrinkSDK.Godot.Sample.csproj", "{8ED6C49D-909C-4A5A-B80C-3537D1349377}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
ExportDebug|Any CPU = ExportDebug|Any CPU
|
||||
ExportRelease|Any CPU = ExportRelease|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8ED6C49D-909C-4A5A-B80C-3537D1349377}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8ED6C49D-909C-4A5A-B80C-3537D1349377}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8ED6C49D-909C-4A5A-B80C-3537D1349377}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
|
||||
{8ED6C49D-909C-4A5A-B80C-3537D1349377}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
|
||||
{8ED6C49D-909C-4A5A-B80C-3537D1349377}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
|
||||
{8ED6C49D-909C-4A5A-B80C-3537D1349377}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
|
||||
{8ED6C49D-909C-4A5A-B80C-3537D1349377}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8ED6C49D-909C-4A5A-B80C-3537D1349377}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,12 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://TutorialDemo.cs" id="1"]
|
||||
|
||||
[node name="TutorialDemo" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1")
|
||||
@@ -0,0 +1,49 @@
|
||||
#nullable enable
|
||||
|
||||
using Godot;
|
||||
using ShrinkTutorial;
|
||||
using ShrinkTutorial.Godot;
|
||||
|
||||
public partial class TutorialDemo : Control
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
var target = new Button
|
||||
{
|
||||
Text = "Tutorial Target",
|
||||
Position = new Vector2(480, 260),
|
||||
CustomMinimumSize = new Vector2(220, 72)
|
||||
};
|
||||
target.AddToGroup("shrink_tutorial_primary");
|
||||
AddChild(target);
|
||||
|
||||
var overlay = new ShrinkGodotTutorialOverlay();
|
||||
AddChild(overlay);
|
||||
var runner = new ShrinkTutorialRunner(new MemoryTutorialStorage());
|
||||
runner.Start(new ShrinkTutorialData
|
||||
{
|
||||
TutorialId = "visual-smoke",
|
||||
Steps =
|
||||
{
|
||||
new ShrinkTutorialStep
|
||||
{
|
||||
StepId = "target",
|
||||
Title = "Godot Tutorial",
|
||||
Body = "Target hole, dialog and input blocker smoke test",
|
||||
TargetMode = ShrinkTutorialTargetMode.AnchorId,
|
||||
Target = "primary",
|
||||
CompleteCondition = ShrinkTutorialCompleteCondition.ClickTarget
|
||||
}
|
||||
}
|
||||
});
|
||||
overlay.Bind(runner);
|
||||
GetTree().CreateTimer(2).Timeout += QuitCleanly;
|
||||
}
|
||||
|
||||
private void QuitCleanly()
|
||||
{
|
||||
var tree = GetTree();
|
||||
tree.UnloadCurrentScene();
|
||||
tree.CreateTimer(0.1).Timeout += () => tree.Quit(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bhjfn5prdv2pw
|
||||
@@ -0,0 +1,52 @@
|
||||
[preset.0]
|
||||
|
||||
name="Windows Desktop"
|
||||
platform="Windows Desktop"
|
||||
runnable=true
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../../Exports/Windows/ShrinkSDKGodot.exe"
|
||||
script_export_mode=2
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
binary_format/architecture="x86_64"
|
||||
debug/export_console_wrapper=1
|
||||
|
||||
[preset.1]
|
||||
|
||||
name="Linux"
|
||||
platform="Linux"
|
||||
runnable=false
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../../Exports/Linux/ShrinkSDKGodot.x86_64"
|
||||
script_export_mode=2
|
||||
|
||||
[preset.1.options]
|
||||
|
||||
binary_format/architecture="x86_64"
|
||||
|
||||
[preset.2]
|
||||
|
||||
name="macOS"
|
||||
platform="macOS"
|
||||
runnable=false
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../../Exports/macOS/ShrinkSDKGodot.zip"
|
||||
script_export_mode=2
|
||||
|
||||
[preset.2.options]
|
||||
|
||||
application/bundle_identifier="work.crash.shrinksdk.sample"
|
||||
binary_format/architecture="universal"
|
||||
@@ -0,0 +1,30 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="ShrinkSDK Godot Sample"
|
||||
run/main_scene="res://Main.tscn"
|
||||
config/features=PackedStringArray("4.6", "C#")
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=960
|
||||
window/size/viewport_height=540
|
||||
|
||||
[dotnet]
|
||||
|
||||
project/assembly_name="ShrinkSDK.Godot.Sample"
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
||||
textures/vram_compression/import_etc2_astc=true
|
||||
Reference in New Issue
Block a user