Skip to content

Commit 010f5ac

Browse files
authored
Reforged modules changes (#24)
* Module Orgnization * Update reforged-modules.md * Content.Common
1 parent 9b3cd18 commit 010f5ac

1 file changed

Lines changed: 98 additions & 5 deletions

File tree

src/en/general-development/codebase-info/goob-reforged/reforged-modules.md

Lines changed: 98 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ Goob Reforged repository has a script to automatically create a module and conne
1818

1919
## Terminology
2020

21-
- **Core Module**: Modules belonging to the base space-station-14 repository. These include `Content.Client`, `Content.Server`, `Content.Shared`, and their dependencies like `Content.Shared.Database`.
21+
- **Core Module**: Modules belonging to the base space-station-14 repository. These include `Content.Client`, `Content.Server`, `Content.Shared`, their dependencies like `Content.Shared.Database`, and `Content.Common`.
2222

23-
- **Custom Module**: Modules that are part of the Client or Server process but don't belong to Core Modules. For example, in Goobstation's case, these are prefixed with `Content.Goobstation.`.
23+
- **Custom Module**: Modules that are part of the Client or Server process but don't belong to Core Modules. They are located in the `/Modules/` folder and have an infix.
2424

2525
- **Engine Module**: Modules that are part of RobustToolbox (the game engine). These are prefixed with `Robust.`.
2626

27-
- **.Common**: A module type intended to be shared between Custom and Core modules. These hold interfaces, components, and other types that both module types need to share.
27+
- **.Common**: A module type intended to be shared between Custom and Core modules. These hold interfaces, components, and other types that both module types need to share. `Content.Common` is located on top of all other `.Common` modules.
2828

2929
- **Infix**: The module identifier, which is the middle part of a module name. For example, "Goobstation" in `Content.Goobstation.Common`.
3030

31+
- **Postfix**: The special module identifier, which specifies its special role, for example `.Database`. Read [Special module projects](#special-module-projects) for more details.
32+
3133
## How
3234

3335
### Module manager
@@ -49,6 +51,8 @@ flowchart TD
4951
style CoreClient stroke:#6b9bb3
5052
CoreShared[Content.Shared]
5153
style CoreShared stroke:#6b9bb3
54+
CoreCommon[Content.Common]
55+
style CoreShared stroke:#6b9bb3
5256
5357
GoobServer[Content.Goobstation.Server]
5458
style GoobServer stroke:#3498db
@@ -68,6 +72,7 @@ flowchart TD
6872
CoreServer
6973
CoreClient
7074
CoreShared
75+
CoreCommon
7176
end
7277
style CoreModules stroke:#e91e63
7378
@@ -86,6 +91,9 @@ flowchart TD
8691
GoobShared --> GoobClient
8792
8893
GoobCommon --> CoreShared
94+
CoreCommon --> GoobCommon
95+
CoreCommon --> CoreShared
96+
8997
CoreShared --> GoobShared
9098
CoreServer --> GoobServer
9199
CoreClient --> GoobClient
@@ -111,6 +119,91 @@ In order to fix this, each Core project should have a special .csproj `Target` t
111119

112120
Unfortunately, the method of Module Compilation described above doesn't solve the issue entirely. When no changes are made to any files in the core module, the .csproj `Target` doesn't trigger, and modules are ignored even if they have some changes.
113121

114-
This problem is solved by adding the `Content.Modules.Server` and `Content.Modules.Client` projects. They reference all modules at once as a direct Project reference, so when a change is made to any module, it gets recompiled correctly.
122+
Because of that, when you make changes to modules and not to the core projects, you have to compile the whole solution so the changes are applied correctly. This is done automatically if you launch from an IDE.
123+
124+
## Module organization
125+
126+
Modules are highly recommended to be independent of other modules. This means that each module references only the core and nothing else.
127+
128+
Here's a chart to represent this structure:
129+
130+
```mermaid
131+
flowchart TD
132+
Core[Core]
133+
style Core stroke:#6b9bb3
134+
Goobstation[Goobstation]
135+
style Goobstation stroke:#6b9bb3
136+
Lavaland[Lavaland]
137+
style Lavaland stroke:#6b9bb3
138+
Utils[Utils]
139+
style Utils stroke:#6b9bb3
140+
Modules[".Modules projects (end)"]
141+
style Utils stroke:#6b9bb3
142+
143+
subgraph CustomModules["Custom Modules"]
144+
Goobstation
145+
Lavaland
146+
Utils
147+
end
148+
style CustomModules stroke:#e91e63
149+
150+
Core --> Goobstation
151+
Core --> Lavaland
152+
Core --> Utils
153+
154+
Goobstation --> Modules
155+
Lavaland --> Modules
156+
Utils --> Modules
157+
```
158+
159+
The only exception for that convention are **library modules** that provide some general tools or API for other modules to use.
160+
161+
Those may be required if there are multiple modules that use same features.
162+
163+
For example, lets assume that both `Lavaland` and `Goobstation` modules need to use code from `Utils`.
164+
165+
Then it's okay to change the project structure like this:
166+
167+
```mermaid
168+
flowchart TD
169+
Core[Core]
170+
style Core stroke:#6b9bb3
171+
Goobstation[Goobstation]
172+
style Goobstation stroke:#6b9bb3
173+
Lavaland[Lavaland]
174+
style Lavaland stroke:#6b9bb3
175+
Utils[Utils]
176+
style Utils stroke:#6b9bb3
177+
Modules[".Modules projects (end)"]
178+
style Utils stroke:#6b9bb3
179+
180+
subgraph CustomModules["Custom Modules"]
181+
Goobstation
182+
Lavaland
183+
Utils
184+
end
185+
style CustomModules stroke:#e91e63
186+
187+
Core --> Utils
188+
189+
Utils --> Goobstation
190+
Utils --> Lavaland
191+
192+
Goobstation --> Modules
193+
Lavaland --> Modules
194+
```
195+
196+
## Special module projects
197+
198+
In `Goobstation` module folder, you can find some projects with weird Postfixes, such as `Content.Goobstation.Client.UIKit`, `Content.Goobstation.Server.Database`. Those are projects that have a unique role in code. Each of them has to be explained separately.
199+
200+
- `.Server.Database` - a project that specifies a single Database model. At the moment Goob Reforged uses the core model and the Goob model for proper modularity.
201+
- `.Client.UIKit` - a project that references `Robust.Client` and `Content.Shared`, and which is referenced directly by `Content.Client`. Contains custom UI elements that have to be usable in `Content.Client`, without making changes to it directly.
202+
203+
### Content.Common
204+
205+
`Common` modules sometimes need to use some of the game's code, for example to inherit an interface for a type or to use a general data structure.
206+
207+
Those are usually located at `Content.Shared`, and are inaccessible for Common modules. That's why `Content.Common` exists - it allows to use the code ported from `Content.Shared` in all `Content.*.Common` custom modules.
115208

116-
That's why you should **always use `Content.Modules` projects for development!**
209+
The files from `Content.Shared` are moved into `Content.Common` without changing the namespace. This is needed so no `using`s in the code of Core modules have to be changed. And even though it shows as a `Content.Shared.*` namespace, it's actually also available from `Content.*.Common` custom modules!

0 commit comments

Comments
 (0)