AutoInject icon indicating copy to clipboard operation
AutoInject copied to clipboard

Godot notifications changed, IAutoOn callbacks work differently

Open rmvermeulen opened this issue 1 year ago • 2 comments

Firstly, thanks for all the great work on Chickensoft's libraries and articles! I like it a lot :smile:

Unless I'm overlooking something silly, it appears Godot (v4.3.stable.mono.official [77dcf97d8]) does no longer emit notifications for unimplemented methods. Which is great, in principle! It seems the following example does not work unless I uncomment the override void _PhysicProcess(double delta){}...

[Meta(typeof(IAutoNode))]
public partial class Player : CharacterBody3D
{
    // mixin contract
    public override void _Notification(int what)
    {
        GD.PrintS("Notification", what);
        this.Notify(what);
    }

    // public override void _PhysicsProcess(double delta) { }

    public void OnPhysicsProcess(double delta)
    {
        GD.Print("OnPhysicsProcess");
    }
}

Unfortunate, but I can just use the default method names.

rmvermeulen avatar Nov 15 '24 22:11 rmvermeulen

Physics and normal processing update callbacks are expensive and unnecessary if not customized, so they are not enabled if you don't override the method the Godot source generators expect.

I simply enable the relevant updates in the game demo: https://github.com/chickensoft-games/GameDemo/blob/f5f36ff3d6cb5c1a65c2b9ad91933dc5f923df49/src/player/Player.cs#L146

I need to get this documented in the AutoInject readme because this comes up pretty often.

jolexxa avatar Nov 15 '24 23:11 jolexxa

Thanks, that makes total sense!

I figured it was something along those lines, but I didn't realize override _PhysicsProcess implicitly set SetPhysicsProcess(true). It's documentation does explain:

Note: If _physics_process is overridden, this will be automatically enabled before _ready is called.

I lazily assumed it was just based on the codegen. A reminder of this intended behavior in the readme would defenitely help avoid this pitfall. EDIT: clarification

rmvermeulen avatar Nov 16 '24 15:11 rmvermeulen