Hi, I’m new to defold and trying to grasp the concepts. I’ve started to think about objects structure, and need your advices on better approach.
I will explain my thought process, and you can tell me that I’m totally wrong
Let’s start with the stats.go
(or collection?) and inventory.go
. They are two systems with their scripts, but affect each other. Equipped stuff changes some stats, and some stats limit what you can equip. So I want some common parent to control these common systems of a player and any enemy.
I can’t add one game object into another in a saved .go file, so I need a collection.
Let’s say it’s entity.collection
where I add stats.go
and inventory.go
and some common entity.script
to make some communication between these systems.
This collection I will add to player.collection
and any enemyXYZ.collection
.
Is it a correct way of doing things in defold, or I overengineer here? I feel like collections are maybe overkill, or it’s ok?
I see alternative here - create entity.go
(not collection) and stats.script
(not game object) + inventory.script
. However, I feel the code will be more coupled - stats should know about the inventory and vice versa. I’d like to decouple them by adding this main manager.
Also, thinking about stats.go
, I thought about composition of system. Like, I can have health.script
attached, but adding mana.script
is optional and could be added only to some enemies. The stats script will just check if there is mana attached and act accordingly.
I hope I expressed myself clear and happy to hear your advices. Maybe there are some good example projects to have an inspiration.
Thank you in advance!