Author Topic: When you are making add-ons, how do you divide it?  (Read 802 times)

Do you make a single server/client.cs and put all the stuff in there,

or do you make several files dedicated to doing something, and have the server/client.cs execute those other files?

It depends on the size of the add-on

You wouldn't want to have 2000 lines in one file because then you find nothing

If you break it up in multiple files each file should contain stuff to the same topic, for example one file for support functions, one for the main logic and one for datablocks etc




yes

no
2000 lines aren't easy to manage, separating them into different .cs will be easier to track down bugs.

no
2000 lines aren't easy to manage, separating them into different .cs will be easier to track down bugs.

I think I remember Mr. Nobody said he did something like this.
I don't really know how, but yeah

I generally like having multiple cs files especially when it is easily dividable in multiple because they handle different aspects of the add-on.

And here is an example of over-doing it with 29 .cs files in the root directory and more than 6 in other folders

Slayer has more than 20,000 lines AFAIK, so it's broken into many files.

For Land of blocks i use different .cs files for dufferent things.

For larger projects I break things into several files.
For example, in an RPG I might have one file for core functionality (such as tick function), another file for the profile saving/loading, another for class system, etc.
For a typical gun or vehicle or something, you shouldn't need more than one file for the datablock definitions, and if it has a large amount of script to go with it, maybe another support_ file (thought I usually just throw my script after the datablocks)


On a related note, one thing that annoys me: server.cs files that contain nothing but one exec call to exec another file that has all the add-ons code in it.


Depends on the size of the project.

For small projects, just the basic server/client scripts will do.

For medium-sized projects, I'll have multiple .cs files dedicated to certain aspects of the mod, and maybe a subfolder for any data files (e.g. .dts shapes, .blb files, sounds, etc.).

With large projects I go for an organised subfolder approach.
For example:
GameMode_buttsworld
|-server.cs
|-resources
|-|-bigbutts.dts
|-|-fantastic.wav
|-scripts
|-|-dependency
|-|-|-player.cs
|-|-|-client.cs


and so on