Skip to content

Commit a721eaf

Browse files
Major repo wide refactor
1 parent 4f3460f commit a721eaf

261 files changed

Lines changed: 5531 additions & 3457 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.githooks/pre-commit

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ build_godotutils=false
3030
build_visualize=false
3131
build_packetgen=false
3232

33+
# Only run full solution validation when staged files can affect compilation.
34+
requires_full_build=false
35+
3336
echo "$STAGED" | grep -q "^Template\.GodotUtils/" && build_godotutils=true || true
3437
echo "$STAGED" | grep -q "^Template\.Visualize/" && build_visualize=true || true
3538
echo "$STAGED" | grep -q "^Template\.PacketGen/" && build_packetgen=true || true
@@ -39,6 +42,17 @@ if $build_visualize; then
3942
build_godotutils=true
4043
fi
4144

45+
while IFS= read -r staged_path; do
46+
[ -z "$staged_path" ] && continue
47+
48+
case "$staged_path" in
49+
*.cs|*.csproj|*.sln|*.props|*.targets|global.json|NuGet.config|nuget.config|*/NuGet.config|*/nuget.config)
50+
requires_full_build=true
51+
break
52+
;;
53+
esac
54+
done <<< "$STAGED"
55+
4256
# ------------------------------------------------------------
4357
# Sync .editorconfig
4458
# ------------------------------------------------------------
@@ -144,24 +158,28 @@ fi
144158
# Verify everything still works by building all projects
145159
# ------------------------------------------------------------
146160

147-
echo "[pre-commit] Running full solution build..."
161+
if $requires_full_build; then
162+
echo "[pre-commit] Running full solution build (build-affecting changes detected)..."
148163

149-
if ! BUILD_OUTPUT=$(dotnet_cmd build 2>&1); then
150-
echo ""
151-
echo "========================================"
152-
echo "[pre-commit] ❌ FINAL BUILD FAILED"
153-
echo "========================================"
154-
echo ""
155-
echo "$BUILD_OUTPUT"
156-
echo ""
157-
echo "[pre-commit] Commit aborted due to build failure."
158-
echo "Fix the errors above before committing."
159-
echo "========================================"
160-
echo ""
164+
if ! BUILD_OUTPUT=$(dotnet_cmd build 2>&1); then
165+
echo ""
166+
echo "========================================"
167+
echo "[pre-commit] ❌ FINAL BUILD FAILED"
168+
echo "========================================"
169+
echo ""
170+
echo "$BUILD_OUTPUT"
171+
echo ""
172+
echo "[pre-commit] Commit aborted due to build failure."
173+
echo "Fix the errors above before committing."
174+
echo "========================================"
175+
echo ""
161176

162-
exit 1
163-
fi
177+
exit 1
178+
fi
164179

165-
echo "[pre-commit] ✅ Full build succeeded"
180+
echo "[pre-commit] ✅ Full build succeeded"
181+
else
182+
echo "[pre-commit] Skipping full solution build (no build-affecting staged files)."
183+
fi
166184

167185
exit 0

.github/workflows/build_and_test.yml.disabled renamed to .github/workflows/build_and_test.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ name: GdUnit4 Tests
33
on:
44
push: &project_change_filter
55
paths:
6-
- '**/*.cs'
7-
- '**/*.gd'
8-
- '**/*.tscn'
9-
- '**/*.tres'
10-
- '**/*.import'
11-
- '**/*.csproj'
12-
- '**/*.sln'
13-
- '**/*.yml'
14-
- 'NuGet.config'
15-
- 'project.godot'
6+
- 'Template/**/*.cs'
7+
- 'Template/**/*.gd'
8+
- 'Template/**/*.tscn'
9+
- 'Template/**/*.tres'
10+
- 'Template/**/*.import'
11+
- 'Template/**/*.csproj'
12+
- 'Template/**/*.sln'
13+
- 'Template/NuGet.config'
14+
- 'Template/project.godot'
15+
- '.github/workflows/build_and_test.yml'
1616

1717
pull_request: *project_change_filter
1818

@@ -29,7 +29,10 @@ jobs:
2929
godot-version: '4.6'
3030
godot-status: 'stable'
3131
godot-net: true
32-
paths: 'res://Setup/Testing'
32+
project_dir: './Template'
33+
paths: |
34+
res://Framework/Testing
35+
res://Framework/Netcode/Testing
3336
console-verbosity: 'normal'
3437
publish-report: false
3538
upload-report: true

.github/workflows/pr_ci.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: PR CI
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
verify:
15+
name: Format, Build, Test
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
submodules: recursive
23+
24+
- uses: actions/setup-dotnet@v4
25+
with:
26+
dotnet-version: |
27+
10.0.x
28+
8.0.x
29+
30+
- name: Detect changed projects
31+
id: changes
32+
shell: bash
33+
run: |
34+
set -euo pipefail
35+
36+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
37+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
38+
CHANGED="$(git diff --name-only "$BASE_SHA" "$HEAD_SHA")"
39+
40+
echo "Changed files:"
41+
printf '%s\n' "$CHANGED"
42+
43+
build_godotutils=false
44+
build_visualize=false
45+
build_packetgen=false
46+
build_template=false
47+
48+
echo "$CHANGED" | grep -q "^Template\.GodotUtils/" && build_godotutils=true || true
49+
echo "$CHANGED" | grep -q "^Template\.Visualize/" && build_visualize=true || true
50+
echo "$CHANGED" | grep -q "^Template\.PacketGen/" && build_packetgen=true || true
51+
echo "$CHANGED" | grep -q "^Template/" && build_template=true || true
52+
53+
if $build_visualize; then
54+
build_godotutils=true
55+
fi
56+
57+
if echo "$CHANGED" | grep -Eq "^(Template\.sln|\.editorconfig|NuGet\.config|\.githooks/|\.github/workflows/)"; then
58+
build_godotutils=true
59+
build_visualize=true
60+
build_packetgen=true
61+
build_template=true
62+
fi
63+
64+
if ! $build_godotutils && ! $build_visualize && ! $build_packetgen && ! $build_template; then
65+
echo "No known project paths changed. Falling back to full validation."
66+
build_godotutils=true
67+
build_visualize=true
68+
build_packetgen=true
69+
build_template=true
70+
fi
71+
72+
{
73+
echo "build_godotutils=$build_godotutils"
74+
echo "build_visualize=$build_visualize"
75+
echo "build_packetgen=$build_packetgen"
76+
echo "build_template=$build_template"
77+
} >> "$GITHUB_OUTPUT"
78+
79+
- name: Restore
80+
run: dotnet restore Template.sln
81+
82+
- name: Format checks (targeted)
83+
shell: bash
84+
run: |
85+
set -euo pipefail
86+
87+
if [[ "${{ steps.changes.outputs.build_godotutils }}" == "true" ]]; then
88+
dotnet format Template.GodotUtils/GodotUtils.csproj --verify-no-changes
89+
fi
90+
91+
if [[ "${{ steps.changes.outputs.build_visualize }}" == "true" ]]; then
92+
dotnet format Template.Visualize/Visualize.csproj --verify-no-changes
93+
fi
94+
95+
if [[ "${{ steps.changes.outputs.build_packetgen }}" == "true" ]]; then
96+
dotnet format Template.PacketGen/PacketGen.sln --verify-no-changes
97+
fi
98+
99+
if [[ "${{ steps.changes.outputs.build_template }}" == "true" ]]; then
100+
dotnet format Template/Template.csproj --verify-no-changes
101+
fi
102+
103+
- name: Targeted builds
104+
shell: bash
105+
run: |
106+
set -euo pipefail
107+
108+
if [[ "${{ steps.changes.outputs.build_godotutils }}" == "true" ]]; then
109+
dotnet build Template.GodotUtils/GodotUtils.csproj --no-restore -p:BuildExtras=true
110+
fi
111+
112+
if [[ "${{ steps.changes.outputs.build_visualize }}" == "true" ]]; then
113+
dotnet build Template.Visualize/Visualize.csproj --no-restore -p:BuildExtras=true
114+
fi
115+
116+
if [[ "${{ steps.changes.outputs.build_packetgen }}" == "true" ]]; then
117+
dotnet build Template.PacketGen/PacketGen/PacketGen.csproj -c Release --no-restore
118+
fi
119+
120+
if [[ "${{ steps.changes.outputs.build_template }}" == "true" ]]; then
121+
dotnet build Template/Template.csproj --no-restore
122+
fi
123+
124+
- name: Full solution build
125+
run: dotnet build Template.sln --no-restore
126+
127+
- name: Tests
128+
run: dotnet test Template.PacketGen/PacketGen.Tests/PacketGen.Tests.csproj --no-build

.vscode/mcp.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"servers": {
3+
"godot": {
4+
"command": "npx",
5+
"args": ["@coding-solo/godot-mcp"],
6+
"env": {
7+
"GODOT_PATH": "/opt/godot-4.6.1/Godot_v4.6.1-stable_mono_linux.x86_64",
8+
"DEBUG": "true"
9+
}
10+
}
11+
}
12+
}

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,16 +523,19 @@ public partial class Player : Node
523523
// Use _EnterTree() if the service is not being registered soon enough
524524
public override void _Ready()
525525
{
526-
Services.Register(this);
526+
Game.Services.Register(this);
527527
}
528528
}
529529
```
530530

531531
```cs
532532
// Get the service from anywhere in your code
533-
Player player = Services.Get<Player>();
533+
Player player = Game.Services.Get<Player>();
534534
```
535535

536+
> [!TIP]
537+
> Runtime framework services are exposed via `Game`. Use `Game.OptionsManager` for updates, `Game.Options.Settings` for reads, and `Game.Application.ExitGameAsync()` for shutdown.
538+
536539
### Custom Main Run Args
537540

538541
In Godot top left `Debug > Customize Run Instances...` there are custom defined arguments you can use.

Template.GodotUtils/Debugging/JsonExceptionHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Godot;
2+
using System;
23
using System.IO;
34
using System.Text;
4-
using System;
55
using System.Text.Json;
66

77
namespace GodotUtils.Debugging;

Template.GodotUtils/Debugging/ParamValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static void ThrowIfNull(Node node, object obj, [CallerArgumentExpression(
2424

2525
node.ProcessMode = Node.ProcessModeEnum.Disabled;
2626

27-
throw new Exception($"Value cannot be null. (Parameter '{paramName}' in {scriptName})");
27+
throw new ArgumentNullException(paramName, $"Value cannot be null. (In {scriptName})");
2828
}
2929
}
3030
}

Template.GodotUtils/Deprecated/EventManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Linq;
3-
using System;
44

55
namespace GodotUtils.Deprecated;
66

Template.GodotUtils/Extensions/CanvasItemExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static Vector2 GetScreenPosition(this CanvasItem canvasItem)
2727
// Relevant Godot Docs at https://docs.godotengine.org/en/stable/tutorials/2d/2d_transforms.html#transform-functions
2828
Window root = canvasItem.GetTree().Root;
2929

30-
return (root.GetFinalTransform() * canvasItem.GetGlobalTransformWithCanvas()).Origin
30+
return (root.GetFinalTransform() * canvasItem.GetGlobalTransformWithCanvas()).Origin
3131
+ root.Position;
3232
}
3333

Template.GodotUtils/Extensions/CollectionsExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System.Collections.Generic;
21
using System;
2+
using System.Collections.Generic;
33

44
namespace GodotUtils;
55

0 commit comments

Comments
 (0)