Feedback on item instantiating system

Hoping for feedback on if what I’m describing is scalable/obviously terrible as I think I’ve gotten myself confused with instancing :slight_smile:

I’ve been watching tutorials and exploring data/instancing options like using custom resources and PackedScenes.

I often see recommend a workflow where you create a Scene and then pass it data via a custom resource.

Here’s what I’m envisioning after seeing different options:

  1. Create a custom resource: GameItemData for reach object that will be in the game (stone.tres, iron.tres, copper.tres etc…)
  2. This has variables like health, texture, icon, name etc…
  3. This has has an export variable for a generic packed scene: GameItemTemplate.tscn

GameItemTemplates have a function like:

 func set_up_instance(data: GameItemData):
var self.texture = data.texture etc....

My workflow would then be to make a custom resource for Stone, Copper, Iron etc…and then use a Spawner class that takes a GameItemData:

func spawn_single_game_item(_item_def: GameItemData):	
        var item_instance = _item_def.game_item_template.instantiate()
	item_instance.set_up_instance(_item_def)
	add_child(item_instance)

I’m trying to avoid a scenario where I have to make a Node2D for Copper, then one for Iron and then the Spawner class uses those individual PackedScenes instead of just the resource.

Your approach seems sound to me.