Factory System

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

Hi everyone,

I’m building a game that is procedurally generated. The world is separated into biomes and each biome has their own rooms.

Each biome constructs its graph which contains the room structure:

Then the biome chooses the right rooms from the prefabs I’ve made or just construct one according to a “basic prefab”.

I was wondering how I could implement this factory system in Godot.
My inital thought was to preload every room prefabs and then construct a dictionnary according to their properties but once I’ve preloaded them I can’t read their properties they aren’t instantiated.

Would it cause problem at a large scale to instantiate them, read their properties and then destroy them ?

Or have you any other idea on how to implement it ?

:bust_in_silhouette: Reply From: aXu_AP

Have you tried the solution you yourself suggested? I don’t think it should be a big problem, surely most weight is in actually loading the scenes, not instantiating them.

Another way to accomplish this would be having the properties written in another scene or file altogether, but this might be messier, less manageable way to do it if aforementioned system works well enough.