#Need help for structuring my project

17 messages · Page 1 of 1 (latest)

small ferry
#

I want to make a easily reusable project, so I want to make an easy structure for everyone to be able to understand, so here we have the src folder (first picture).

But since I'm making really small components with one variable, should I be making a lot of file or just one file named "base_components" would be enough for all these little components ?

#

my npc components (I will be splitting it with all the components it contains)
Also, should I make them all with #[derive(Component)] ?

ivory granite
#

honestly, I'd recommend you group those components and systems based on what they do in the game.

eg a npc.rs file that has the resources, systems, and components for npcs. same for ui.

You can break them up later but gosh you will have a lot of files with one thing per file strategy.

ornate bramble
#

Yeah, in my experience with programming, it is usually a bad idea to make hierarchies based on Types. Implementing a single feature will then require modifying multiple files across different locations. For me, it's ever hard to find those files and remember where should I look for them.

Bevy has a very nice plugin system, so I prefer to have every (semi-)independent "actor" as a separate Plugin. E.g. NPC plugin which handles spawning and AI logic, Player plugin which handles controls and animations, Camera plugin responsible for camera movements, Level plugins for individual levels, and so on.

I'm new to Bevy myself, so this might not be the best advice.

small ferry
#

is it too much or it's good ?

upper galleon
#

I went from a folder for e c and s to a folder per mechanic like let's say combat which has folders for the related entity systems and components

Honestly bad idea I have so many folders might take it back to single per mechanic with all the e c s stuff in one file.

severe chasm
#

i typically want to reorganise/split up when my files reach ~400 lines

#

in bevy itself, though, there are files that are 1.5k+ lines

severe chasm
# small ferry

this is not an answer to your question, but Mathematics_skill_component isn't technically a component here

#

you might want to look into making Npc_skills_component derive Bundle instead

small ferry
#

Oh, I could only add the skills an NPC have, I didn't know about that

chrome gull
#

This isn't about file organisation, but I would highly encourage you to not add _component to every component. It gets very verbose very quickly and doesn't add much. The compiler will tell you if you are trying to use a struct that isn't a component. That was one of the main reason why we added #[derive(Component)]

#

As for file organization, like other people say, group things by features/behaviour. So if you have an health component and a damage system put both of them next to each other in the same file.