Using tool with factory pattern doesnt work in editor, though everything works during run

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By random_char

You can find this sample project on github.

My intent is to create an Actor and Models scenes, which implement Type Object Pattern. In few words: an Actor is a container with common logic (say, movement, actions etc), Model should define the looks.

In the sample project there are Actor scene and class, Model1 and Model2 scenes with corresponding classes. Models has Sprite child node to distinguish between them. Also models inherit from ModelInterface (I really miss interface feature from other oop programming languages) and have an init method.

In res://Model folder there is a ModelFactory class to create models, base on some parameter (say their type id). Actor is a tool and I want to switch its model in the editor. Actor has current_model_type variable and corresponding setter, which calls ModelFactory to create a new model, runs its init method and attaches it to Actor.

The problem is, that in editor I get an error:
res://Actor/Actor.gd:27 - Invalid call. Nonexistent function 'init' in base 'Node2D (Model1.gd)'.
but when running the project everything works as intended. Should I load the scenes in a different way?

Thanks for any help!