You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/en/general-development/codebase-info/goob-reforged/reforged-modules.md
+98-5Lines changed: 98 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,16 +18,18 @@ Goob Reforged repository has a script to automatically create a module and conne
18
18
19
19
## Terminology
20
20
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`.
22
22
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.
24
24
25
25
-**Engine Module**: Modules that are part of RobustToolbox (the game engine). These are prefixed with `Robust.`.
26
26
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.
28
28
29
29
-**Infix**: The module identifier, which is the middle part of a module name. For example, "Goobstation" in `Content.Goobstation.Common`.
30
30
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
+
31
33
## How
32
34
33
35
### Module manager
@@ -49,6 +51,8 @@ flowchart TD
49
51
style CoreClient stroke:#6b9bb3
50
52
CoreShared[Content.Shared]
51
53
style CoreShared stroke:#6b9bb3
54
+
CoreCommon[Content.Common]
55
+
style CoreShared stroke:#6b9bb3
52
56
53
57
GoobServer[Content.Goobstation.Server]
54
58
style GoobServer stroke:#3498db
@@ -68,6 +72,7 @@ flowchart TD
68
72
CoreServer
69
73
CoreClient
70
74
CoreShared
75
+
CoreCommon
71
76
end
72
77
style CoreModules stroke:#e91e63
73
78
@@ -86,6 +91,9 @@ flowchart TD
86
91
GoobShared --> GoobClient
87
92
88
93
GoobCommon --> CoreShared
94
+
CoreCommon --> GoobCommon
95
+
CoreCommon --> CoreShared
96
+
89
97
CoreShared --> GoobShared
90
98
CoreServer --> GoobServer
91
99
CoreClient --> GoobClient
@@ -111,6 +119,91 @@ In order to fix this, each Core project should have a special .csproj `Target` t
111
119
112
120
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.
113
121
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.
115
208
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