Godot SDK and Blackholio tutorial#4920
Conversation
rekhoff
left a comment
There was a problem hiding this comment.
I was only able to get part-way through docs/docs/00100-intro/00300-tutorials/00500-godot-tutorial/00300-part-2.md before hitting a blocker with the implementation.
The tutorial so far it looks good with only some minor nits, but the NuGet package issue will need to get addressed before I can finish reviewing.
| } | ||
| } | ||
| } | ||
| #elif GODOT |
There was a problem hiding this comment.
I don't believe this will work to allow Godot to have code only relevant to it within the NuGet packages. Unity is able to get away with unique build flags because we have Unity developers Import the SpacetimeDB SDK using the C# SDK repo. This means for Unity developers, the original code is intact and constants like UNITY_5_3_OR_NEWER and UNITY_EDITOR are evaluated locally. Only the SpacetimeDB.BSATN.Codegen.dll and SpacetimeDB.BSATN.Runtime.dll are pre-built head of time.
When we publish the NuGet packages for the general C# developers, that will strip out the GODOT build flag because it's not included as a constant during compilation. If we did include it, that would make it available to all SDK users (which of course would break things since it's specifically imports using Godot.
We'll likely need another approch than using GODOT build flags, or would need to make a custom target framework specifically for this.
For additional context, if we follow the tutorial, but point at a local NuGet package build from the lisandro/godot-blackholio branch, we'd get the errors like:
GameManager.cs(43,23): Error CS0117 : 'AuthToken' does not contain a definition for 'TryGetToken'
GameManager.cs(49,9): Error CS0103 : The name 'STDBUpdateManager' does not exist in the current contextAnd again, this is because the code is getting stripped out.
There was a problem hiding this comment.
I was wondering if this was going to work. I couldn't get my local NuGet working because I was missing what you dm me yesterday.
I guess the onlybest solution we have is to compile with the GODOT preprocessor flag and publish a different NuGet package.
There was a problem hiding this comment.
In my most-recent testing, I was able to rebuild the NuGet packages with the SpacetimeDB.ClientSDK.Godot.2.1.0.nupkg package that is now getting generated.
dba5046 to
f9ee392
Compare
rekhoff
left a comment
There was a problem hiding this comment.
I have tested the C# Server implementation instructions of the Godot tutorial and left my comments below.
I have also tested the client-godot version in the demo folder and confirmed it works as intended.
|
|
||
| Let's also create an `EntityController` script which will serve as a base class for both our `CircleController` and `FoodController` classes since both `Circle`s and `Food` are entities. | ||
|
|
||
| Create a new C# script called `EntityController.cs` and replace its contents with: |
There was a problem hiding this comment.
When creating this EntityController.cs script using Godot's Create Script dialog, you can't select Circle2D as what it Inherits from.
Since we aren't really asking them to define inheritance elsewhere and the code we copy in puts the correct inheritance in place anyway, this is just an optional thing.
If actually wanted them to be able to select our C# classes in this manner though, by having the Circle2D class defined with the [GlobalClass] attribute. Documentation around this is at https://docs.godotengine.org/en/4.4/tutorials/scripting/c_sharp/c_sharp_global_classes.html
With that in place, if we then press play once, so the project rebuilds, Circle2D shows up under Node2D as something that can be inherited from.
Since we don't actually ask them to do this, it would purely be for teaching users how to interact between the Godot Editor side of the house, and C# backend code that works with SpacetimeDB.
| ```csharp | ||
| public partial struct MoveAllPlayersTimer | ||
| { |
There was a problem hiding this comment.
| ```csharp | |
| public partial struct MoveAllPlayersTimer | |
| { | |
| ```csharp | |
| [Table(Accessor = "move_all_players_timer", Scheduled = nameof(MoveAllPlayers), ScheduledAt = nameof(scheduled_at))] | |
| public partial struct MoveAllPlayersTimer | |
| { |
Without this, we'll get an error on the C# step that reads
Add the following to your
Initreducer to schedule theMoveAllPlayersreducer to run every 50 milliseconds.
| <AssemblyVersion>2.1.0</AssemblyVersion> | ||
| <Version>2.1.0</Version> |
There was a problem hiding this comment.
| <AssemblyVersion>2.1.0</AssemblyVersion> | |
| <Version>2.1.0</Version> | |
| <AssemblyVersion>2.2.0</AssemblyVersion> | |
| <Version>2.2.0</Version> |
As a note, we'll need to make sure the process we are using to update version numbers includes SpacetimeDB.ClientSDK.Godot.csproj going forward. Since that last update was pulled in from the master branch, the other NuGet packages are all on 2.2.0 while the Godot was still on 2.1.0
Description of Changes
Very small additions to the C# SDK specific for Godot.
I wrote the Godot Blackholio tutorial and updated the Unity one.
I added the image assets necessary for the tutorial.
I added the files for the Godot demo.
API and ABI breaking changes
No breaking changes.
Expected complexity level and risk
Testing