Improved CSharp documentation

This commit is contained in:
EvilFactory
2024-08-25 14:06:17 -03:00
parent 74d27d8fd3
commit 3788e4641c
15 changed files with 3027 additions and 861 deletions

View File

@@ -47,7 +47,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = "Barotrauma Doc"
PROJECT_NAME = "LuaCsForBarotrauma"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
@@ -348,6 +348,7 @@ OPTIMIZE_OUTPUT_SLICE = NO
# Note see also the list of default file extension mappings.
EXTENSION_MAPPING =
EXTENSION_MAPPING += dox=md
# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
# according to the Markdown format, which allows for more readable
@@ -912,7 +913,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.
INPUT = .
INPUT = ./
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1110,7 +1111,7 @@ FILTER_SOURCE_PATTERNS =
# (index.html). This can be useful if you have a project on for instance GitHub
# and want to reuse the introduction page also for the doxygen output.
USE_MDFILE_AS_MAINPAGE = ./intro.md
USE_MDFILE_AS_MAINPAGE = ./manual/intro.md
#---------------------------------------------------------------------------
# Configuration options related to source browsing
@@ -1334,7 +1335,7 @@ HTML_STYLESHEET =
# list). For an example see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET = custom.css
HTML_EXTRA_STYLESHEET =
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
@@ -2742,3 +2743,9 @@ GENERATE_LEGEND = YES
# The default value is: YES.
DOT_CLEANUP = YES
HTML_EXTRA_STYLESHEET = doxygen-awesome-css/doxygen-awesome.css \
doxygen-awesome-css/doxygen-awesome-sidebar-only.css
HTML_COLORSTYLE = LIGHT # required with Doxygen >= 1.9.5

View File

@@ -1,8 +1,14 @@
<doxygenlayout version="1.0">
<navindex>
<tab type="user" url="./index.html" title="Documentation introduction"/>
<tab type="user" url="../baro-server/html/index.html" title="Server class documentation"/>
<tab type="user" url="../baro-client/html/index.html" title="Client class documentation"/>
<tab type="mainpage" visible="yes" title=""/>
<tab type="usergroup" title="Development">
<tab type="user" url="md_manual_2inmemorymod.html" title="In-memory CSharp Mod" />
<tab type="user" url="md_manual_2assemblymod.html" title="Assembly CSharp Mod" />
<tab type="user" url="md_manual_2harmony.html" title="Using Harmony" />
</tab>
<tab type="usergroup" title="Generated Documentation">
<tab type="user" url="../baro-server/html/index.html" title="Server Documentation"/>
<tab type="user" url="../baro-client/html/index.html" title="Client Documentation"/>
</tab>
</navindex>
</doxygenlayout>

View File

@@ -41,7 +41,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = "Barotrauma Client Doc"
PROJECT_NAME = "Client LuaCsForBarotrauma"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
@@ -1329,7 +1329,7 @@ HTML_STYLESHEET =
# list). For an example see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET = ../custom.css
HTML_EXTRA_STYLESHEET =
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
@@ -2735,3 +2735,7 @@ GENERATE_LEGEND = YES
# The default value is: YES.
DOT_CLEANUP = YES
HTML_EXTRA_STYLESHEET = ../doxygen-awesome-css/doxygen-awesome.css \
../doxygen-awesome-css/doxygen-awesome-sidebar-only.css
HTML_COLORSTYLE = LIGHT # required with Doxygen >= 1.9.5

View File

@@ -2,7 +2,7 @@
<!-- Generated by doxygen 1.9.4 -->
<!-- Navigation index tabs for HTML output -->
<navindex>
<tab type="user" url="../../html/index.html" title="Documentation introduction"/>
<tab type="user" url="/index.html" title="Documentation introduction"/>
<tab type="user" url="../../baro-server/html/index.html" title="Server class documentation"/>
<tab type="user" url="./index.html" title="Client class documentation"/>
<tab type="mainpage" visible="yes" title=""/>

View File

@@ -41,7 +41,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = "Barotrauma Server Doc"
PROJECT_NAME = "Server LuaCsForBarotrauma"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
@@ -1329,7 +1329,7 @@ HTML_STYLESHEET =
# list). For an example see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET = ../custom.css
HTML_EXTRA_STYLESHEET =
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
@@ -2735,3 +2735,7 @@ GENERATE_LEGEND = YES
# The default value is: YES.
DOT_CLEANUP = YES
HTML_EXTRA_STYLESHEET = ../doxygen-awesome-css/doxygen-awesome.css \
../doxygen-awesome-css/doxygen-awesome-sidebar-only.css
HTML_COLORSTYLE = LIGHT # required with Doxygen >= 1.9.5

View File

@@ -2,7 +2,7 @@
<!-- Generated by doxygen 1.9.4 -->
<!-- Navigation index tabs for HTML output -->
<navindex>
<tab type="user" url="../../html/index.html" title="Documentation introduction"/>
<tab type="user" url="/index.html" title="Documentation introduction"/>
<tab type="user" url="./index.html" title="Server class documentation"/>
<tab type="user" url="../../baro-client/html/index.html" title="Client class documentation"/>
<tab type="mainpage" visible="yes" title=""/>

View File

@@ -1,512 +0,0 @@
@namespace url(http://www.w3.org/1999/xhtml);
/* i really want this to be global */
/* @-moz-document url-prefix("file:///") { */
code {
font-family: monospace, fixed !important;
background-color: #3f3f3f;
color: #999;
border-radius: 5px;
padding-left: 3px;
padding-right: 3px;
}
div.fragment {
border-radius: 5px;
padding-left: 3px;
padding-right: 3px;
}
body {
background-color: #333333;
/** for docs **/
color: #a1a1a1;
}
#page-content {
background-color: #333333;
color: #bcbcbc;
}
pre, pre.fragment {
background-color: #282828;
}
.icon {
color: #333;
background-color: #2f436b;
/* from orig #728DC1; */;
}
.arrow {
color: #324872;
/* from orig #9CAFD4; */;
}
/* to make keyword visible for above 'pre' */
.highlight .nf {
color: #00adee;
}
img {
background-color: #333333;
}
/** Note/Message boxes **/
div.admonition, div.warning {
background-color: #474747;
}
div.admonition p.admonition-title, div.warning p.admonition-title {
background-color: #707070;
}
/**** News ***/
#content-outer {
background-color: #333333;
}
.postmeta {
background-color: #474747;
border-color: #595959;
}
/**** Blog ****/
div.blogpost {
background-color: #333;
}
div.blogpost-header {
background-color: #333;
}
div.blogbody {
background-color: #474747;
}
/**** Jobs ****/
.dataTable tbody .even {
background-color: #474747;
}
.dataTable thead th {
background-color: #6b6b6b;
}
/* Job Post Overlay */
#fancybox-outer {
color: #bcbcbc;
background-color: #282828;
}
/***** Search box *****/
#MSearchBox {
background-color: #333333;
}
#MSearchBox .left {
filter: invert(80%);
}
#MSearchSelect {
background-color: transparent;
}
.MSearchBoxActive #MSearchField {
color: #333333;
/* this is inverted */
}
#MSearchBox .right {
filter: invert(80%);
}
#MSearchCloseImg {
background-color: transparent;
}
/** Magnifying glass dropdown list **/
#MSearchSelectWindow {
background-color: #333333;
border-color: #404040;
}
a.SelectItem, a.SelectItem:focus, a.SelectItem:active {
color: #999;
}
a.SelectItem:hover {
color: #bcbcbc;
}
/** Query Results dropdown list **/
#MSearchResultsWindow {
/* left: !important; / * from orig 992px; * / dynamically generated value */
border-color: #404040;
}
/* iframe#MSearchResults {
width: !important; / * from orig 60ex; * /
height: !important; / * from orig 15em; * /
} */
/* #MSearchCloseImg {
} */
.SRPage .SREntry {
font-size: 80%;
}
.SRResult:hover {
background-color: #404040;
}
.SRSymbol:hover {
color: #4a69a9;
/* from orig #425E97; */;
}
/***** For Docs *****/
div.header {
background-color: #333333;
border-bottom-color: #001;
background-image: none;
}
div.directory {
border-top-color: #404040;
border-bottom-color: #404040;
}
td.memItemLeft,
td.memItemRight,
.mdescLeft,
.mdescRight,
.memdoc,
.memTemplParams,
.memTemplItemLeft,
.memTemplItemRight {
background-color: #282828;
}
.memSeparator {
border-bottom-color: #333333;
}
.memtitle {
background-color: #333333;
background-image: none;
border-top-color: #404040;
border-left-color: #404040;
border-right-color: #404040;
}
.memproto, dl.reflist dt {
/* 2nd for ToDo List */
color: #949b8c;
/* #878f7e; */
background-color: #333333;
text-shadow: unset;
background-image: none;
border-top-color: #404040;
border-left-color: #404040;
border-right-color: #404040;
}
.memname {
background-color: #333333;
}
a {
color: #adb8a1;
}
a.el, a.el:visited {
color: #6f8b4c;
/* #6d7c5d; */;
}
.memdoc {
background-image: none;
}
.memdoc, dl.reflist dd {
/* 2nd for ToDo List */
background-color: #282828;
border-bottom-color: #404040;
border-left-color: #404040;
border-right-color: #404040;
}
.paramname {
color: #8f6262;
}
img.formulaInl {
filter: invert(84%);
background-color: #fff;
}
/* Template box headers */
.memtemplate {
color: #607fbb;
/* from orignial #4665A2; */;
}
/* Labels - protected, static, virtual */
span.mlabel {
background-color: #282828;
border-color: #333;
color: #aaa;
/* font-size: 80%; */;
}
/* Header */
h2.groupheader {
color: #4c6db0;
/* from orig. #354C7B; */
border-bottom-color: #333333;
}
.inherit_header img {
background-color: #333333;
}
/* To make comments visible */
span.comment {
color: #7b7b7b;
}
/* Even rows of lists */
.directory tr.even {
background-color: #303030;
}
/* Tables */
table.fieldtable {
border-color: #404040;
}
.fieldtable th {
color: #aaa;
background-color: #333333;
border-bottom-color: #404040;
background-image: none;
}
.fieldtable td.fieldtype, .fieldtable td.fieldname {
border-right-color: #404040;
border-bottom-color: #404040;
}
.fieldtable td.fielddoc {
border-bottom-color: #404040;
}
div.center > img {
background-color: #cccccc;
filter: invert(100%);
}
/**** Source Code View ****/
div.fragment {
background-color: #282828;
border-color: #333333;
}
.navpath li.navelem a {
color: #d1d1d1;
text-shadow: none;
}
.navpath li.navelem a:hover {
color: #f1f1f1;
text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9);
}
span.lineno {
background-color: #333333;
border-right-color: #333333;
color: #666;
}
span.line {
background-color: #3f3f3f;
}
span.lineno a {
background-color: #333333;
}
span.lineno a:hover {
background-color: #444444;
}
a.code, a.code:visited, a.line, a.line:visited {
color: #4fa2b3;
}
span.keyword {
color: #00b300;
}
span.keywordtype {
color: #ac7339;
}
span.stringliteral {
color: #0140ff;
}
#powerTip {
background-color: #282828;
}
#powerTip div {
background-color: #282828;
}
/**** Navigation ****/
#nav-tree {
background-color: #282828;
background-image: none;
}
#nav-tree img {
background-color: #282828;
}
#nav-tree .selected a {
color: #bcbcbc;
}
/** Split bar **/
.ui-resizable-e {
filter: invert(70%);
opacity: 0.2;
}
/**** Top Tab ****/
/*** Type 1 e.g. https://dartsim.github.io/api/ ***/
.tabs, .tabs2, .tabs3 {
background-image: none;
}
.tablist li {
background-image: none;
}
.tablist li.current a {
color: #aaa;
background-image: none;
background-color: #444;
}
.tablist a {
color: #bcbcbc;
text-shadow: none;
background-image: none;
}
.tablist a:hover {
color: #bcbcbc;
background-color: #444444;
background-image: none;
}
/*** Type 2 e.g. https://clang.llvm.org/doxygen/ ***/
.sm-dox {
background-image: none;
}
.sm-dox a, .sm-dox a.highlighted {
color: #bcbcbc;
text-shadow: none;
background-image: none;
}
.sm-dox a:focus, .sm-dox a:active, .sm-dox a:hover {
color: #bcbcbc;
background-color: #444444;
background-image: none;
}
/** Pop-Pane **/
.sm-dox ul {
background-color: #333333;
border-color: #666;
}
.sm-dox ul a, .sm-dox ul a:focus, .sm-dox ul a:hover, .sm-dox ul a:active {
background-color: #333333;
}
.sm-dox span.scroll-up, .sm-dox span.scroll-down {
background-color: #333333;
}
.sm-dox span.scroll-up:hover, .sm-dox span.scroll-down:hover {
background-color: #444444;
}
.sm-dox a span.sub-arrow {
border-top-color: #bcbcbc;
}
.sm-dox a:hover span.sub-arrow {
border-top-color: #cccccc;
}
.sm-dox ul a, .sm-dox ul a:hover, .sm-dox ul a:focus, .sm-dox ul a:active, .sm-dox ul a.highlighted {
color: #bcbcbc;
}
.sm-dox > li > ul::before, .sm-dox > li > ul::after {
border-bottom-color: #333333;
}
/* Top menu-item highlighted only, for contrast with arrow */
.sm-dox a.highlighted {
background-color: #444444;
}
.sm-dox ul a.highlighted {
background-color: #333333;
}
/**** Bottom Tab ****/
.navpath ul {
background-image: none;
border-color: #666;
}
img.footer {
background-color: #333333;
opacity: 0.1;
}
/**** Navigation Tab ****/ /* e.g. nlohmann.github.io/json */
div.navtab {
background-color: #333333;
}
/**** Classes ****/
/*** Class List, Member List ***/
td.indexkey, td.indexvalue, tr.memlist {
background-color: #333333;
}
/* } */

View File

@@ -0,0 +1,116 @@
/**
Doxygen Awesome
https://github.com/jothepro/doxygen-awesome-css
MIT License
Copyright (c) 2021 - 2023 jothepro
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
html {
/* side nav width. MUST be = `TREEVIEW_WIDTH`.
* Make sure it is wide enough to contain the page title (logo + title + version)
*/
--side-nav-fixed-width: 335px;
--menu-display: none;
--top-height: 120px;
--toc-sticky-top: -25px;
--toc-max-height: calc(100vh - 2 * var(--spacing-medium) - 25px);
}
#projectname {
white-space: nowrap;
}
@media screen and (min-width: 768px) {
html {
--searchbar-background: var(--page-background-color);
}
#side-nav {
min-width: var(--side-nav-fixed-width);
max-width: var(--side-nav-fixed-width);
top: var(--top-height);
overflow: visible;
}
#nav-tree, #side-nav {
height: calc(100vh - var(--top-height)) !important;
}
#nav-tree {
padding: 0;
}
#top {
display: block;
border-bottom: none;
height: var(--top-height);
margin-bottom: calc(0px - var(--top-height));
max-width: var(--side-nav-fixed-width);
overflow: hidden;
background: var(--side-nav-background);
}
#main-nav {
float: left;
padding-right: 0;
}
.ui-resizable-handle {
cursor: default;
width: 1px !important;
background: var(--separator-color);
box-shadow: 0 calc(-2 * var(--top-height)) 0 0 var(--separator-color);
}
#nav-path {
position: fixed;
right: 0;
left: var(--side-nav-fixed-width);
bottom: 0;
width: auto;
}
#doc-content {
height: calc(100vh - 31px) !important;
padding-bottom: calc(3 * var(--spacing-large));
padding-top: calc(var(--top-height) - 80px);
box-sizing: border-box;
margin-left: var(--side-nav-fixed-width) !important;
}
#MSearchBox {
width: calc(var(--side-nav-fixed-width) - calc(2 * var(--spacing-medium)));
}
#MSearchField {
width: calc(var(--side-nav-fixed-width) - calc(2 * var(--spacing-medium)) - 65px);
}
#MSearchResultsWindow {
left: var(--spacing-medium) !important;
right: auto;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,335 +0,0 @@
# Barotrauma C# modding guide
## Introduction
C# modding is part of the **[Lua For Barotrauma](https://github.com/evilfactory/LuaCsForBarotrauma)** mod and requires the package `Cs For Barotrauma` to be turned on ([steam workshop](https://steamcommunity.com/sharedfiles/filedetails/?id=2795927223)), in some cases the package is not needed and a prompt in game will be shown to enable it automatically.
This modding requires strict source structure, but comes with the benefits of being handled natively by game engine, witch removes many hurdles with type casting or similar issues.
## Setting Up Assembly Mod
---
#### Part 1: General Project Setup
1. Download [Visual Studio](https://visualstudio.microsoft.com/vs/). You may use another version of VS, or another IDE like JetBrains Rider. However, it must support `.NET 6` as a platform/SDK target and there is no guarantee that the project will function as expected, although there should be little issue.
- Important: You must have `Visual Studio Build Tools` 2019 or later installed with the Individual Component under `SDKs, libraries, and frameworks` named `Visual Studio SDK Build Tools Core` installed.
2. Git Clone or Download the following:
- [Refs.zip](https://github.com/MapleWheels/LuaCsForBarotrauma/releases): This contains all references used in the project. Choose the one from the latest release on the Github repo.
- [VSProjectSkeleton](https://github.com/MapleWheels/VSProjectSkeleton): This contains the skeleton project that we will be using as the basis for this tutorial. Most things that need to be setup have already been done.
- If you do not have Git Tools installed, it is recommended that you get familiar with them as it makes life easier and is required for Part 2 (optional). [Download and install it](https://git-scm.com/downloads).
3. Extract the VS Project Skeleton to a folder that you are working out of.\
-- IMPORTANT: This folder should NOT be in your Barotrauma/Luatruama local mods folder!
4. Copy the contents of the Refs.zip into the `/Refs/` folder in the VS Skeleton Project. Your project should then have the below structure.
```asciidoc
./MyModName.sln
./.gitignore
./README.txt
./Build.props
=== Assets Here ===
./Assets
----/Content/ <<=== Your Non-CSharp Content Goes Here (including Lua, XML)!
Ex:----/Lua/...
Ex:----/Items/...
----/filelist.xml
----/RunConfig.xml
=== Client CSharp Code Here ===
./ClientProject
----/ClientSource/...
----/LinuxClient.csproj
----/OSXClient.csproj
----/WindowsClient.csproj
=== Server CSharp Code Here ===
./ServerProject
----/ServerSource/...
----/LinuxServer.csproj
----/OSXServer.csproj
----/WindowsServer.csproj
=== Shared CSharp Code Here ===
./SharedProject
----/SharedSource/...
./Refs
----/Linux/Barotrauma.dll
----/Linux/DedicatedServer.dll
----/Windows/Barotrauma.dll
----/Windows/DedicatedServer.dll
----/OSX/Barotrauma.dll
----/OSX/DedicatedServer.dll
----/0Harmony.dll
----/Farseer.NetStandard.dll
----/Lidgren.NetStandard.dll
----/Mono.Cecil.dll
----/MonoGame.Framework.Linux.NetStandard.dll
----/MonoGame.Framework.MacOS.NetStandard.dll
----/MonoGame.Framework.Windows.NetStandard.dll
----/MonoMod.Common.dll
----/MoonSharp.Interpreter.dll
----/XNATypes.dll
```
5. Rename the Skeleton Project folder to the name of your mod.
6. Open up the Solution file (`.sln`) from the Skeleton Project in Visual Studio. Just verify that there are not errors related to "Unable to find Reference", this means that all assemblies in `/Refs` have be found successfully.
7. Rename the `MyModName.sln` file to the name of your mod. IE: `ModdingToolkit.sln`.
8. Open the `.sln` Solution file. In your IDE, you will need to do the following for all `.csproj` files:
```asciidoc
- Assets.csproj
- LinuxClient.csproj
- LinuxServer.csproj
- OSXClient.csproj
- OSXServer.csproj
- WindowsClient.csproj
- WindowsServer.csproj
```
- A. Open the Project Configuration for the `.csproj` file by right-clicking and selecting `Properties`.
- B. Change the `AssemblyName` to the name of your mod WITHOUT SPACES OR SPECIAL CHARACTERS. Example: `ModdingToolkit`
- C. Change the `Root Namespace` to either your mod's Assembly Name or mod's short version without spaces in plain English. Example: `ModdingToolkit`.
---
#### Part 2 (Optional, Recommended): Setting up a debug build of LuaCsForBarotrauma
This will give us a debug build of LuaCsForBarotrauma. A debug build gives us access to many tools as well as the `DEBUG` symbol for writing test/print code that will not be run in the release version.
1. Clone the [LuaCsForBarotrauma](https://github.com/evilfactory/LuaCsForBarotrauma) repository to your local drive. If you do not have Git Tools installed, please [download and install it](https://git-scm.com/downloads).
- Important: When cloning, use the command `git clone --recurse-submodules --remote-submodules https://github.com/evilfactory/LuaCsForBarotrauma.git`. This will download the submodules automatically.
2. Open up the LuaCs Solution in your IDE based on your Operating System, one of:
```asciidoc
- WindowsSolution.sln
- MacSolution.sln
- LinuxSolution.sln
```
-- NOTE: This tutorial assumes that you are using the `WindowsSolution.sln`. For other platforms, the naming of files may be slightly different (MacXXX, LinuxXXX, where 'XXX' is either "Client" or "Server").
3. In the Project Settings for `WindowsClient` and `WindowsServer`, you want to change the `Platform Target` from `Any CPU` to `x64`. This is necessary for OpenAL code to build successfully.
4. Build the whole Solution (`Build -> Build Solution`). This will create the necessary dependencies from libraries and make sure that there are no errors at this point.\
5. For both the `WindowsClient` and `WindowsServer` projects, set their output/build type to `DEBUG` (should be in a drop-down menu at the top next to a green play button).\
6. Select `Build Solution`. This will generate Debug builds for use. This debug build will now exist in `./Barotrauma/bin/DebugXXX/net6.0/` where `XXX` is based on your Solution choice. IE. `./Barotrauma/bin/DebugWindows/net6.0`.
7. Make the local folder in Barotrauma/LocalMods/ for your mod:
- A. Navigate into the Client Debug Build folder (or game folder if you are coming from Part 3, Step 3) and then into `/LocalMods`.
- B. CREATE a folder with the name of your mod. Ideally, it should match the name of your `.sln` file with the extension.
- C. COPY the path to this directory (with your mod) and save it in a sticky note or .txt file. We will be using it shortly.
---
#### Part 3: Setting up MSBuild to Copy Files into Local Mods.
You will have to do the following for the `Build.props` file found in the main project directory:
1. Open the file in your Text Editor or IDE of choice.
2. Locate the line `ModDeployDir`, IE:
```xml
<PropertyGroup>
<!-- IMPORTANT: Should point to <Barotrauma_Install>\LocalMods\<MyModName>\ -->
<!-- IMPORTANT: ModDeplyDir Path must end with '\' -->
<ModDeployDir>..\LUATRAMA_DEBUG_LOCALMODS_MYMODDIR\</ModDeployDir>
<!-- IMPORTANT: Avoid the use of special (IE: / : ; , \ < > ?) (periods "." are good) and non-english characters in the AssemblyName.-->
<AssemblyName>MyModName</AssemblyName>
</PropertyGroup>
```
3. Change the `ModDeployDir` value from `..\LUATRAMA_DEBUG_LOCALMODS_MYMODDIR\` to the path to your mod's folder in the `/LocalMods` folder for LuaCsForBarotrauma from `Part 2, Step 7`.
- IMPORTANT: The value must end with `/` or `\ ` . IE: `\LocalMods\ModdingToolkit\`.
- Note: If you did not complete Part 2, then complete only Part 2, Step 7 but use your vanilla Barotrauma installation location instead.
- Note: If you do not want either the `Client` plugin or the `Server` plugin (IE. Client-side or Server-side ONLY mod), then you must delete all projects that end with `Server`. Example: `LinuxServer`, `WindowsServer`. Warning, this is generally irreversible and will require you to setup new Cs Projects if you want a client in the future.
4. Replace `MyModName` with a valid assembly name, this should be similar to your mod name but does not need to match. This name should:
- Not include spaces.
- Not include special characters except periods ( . ), which are allowed.
- Use english characters.
- Recommended: Follow the convention of `ModName` or `PackageName.LibraryName` for libraries, IE: `ModdingToolkit.GUI`.
---
#### Part 4: Adding Launch Configurations for Debug-Mode Barotrauma Client and Server to the IDE.
This part makes life very easy and gives you access to Edit and Continue. It'll let you Debug your build as you go and launch Barotrauma from the IDE. Note that this is IDE-specific so please follow the links for your IDE while doing the below:\
-- Make two launch options;
- A. One should target `Barotrauma.exe` or `Barotrauma.dll`, name it `Client`.
- B. The other should target `DedicatedServer.exe` or `DedicatedServer.dll` and name it `Server`.
Follow the link;
- For [Jetbrains Rider IDE](https://www.jetbrains.com/help/rider/Run_Debug_Configuration.html#envvars-progargs) (what I use).
- For [Visual Studio 2022](https://learn.microsoft.com/en-us/visualstudio/debugger/project-settings-for-csharp-debug-configurations-dotnetcore?view=vs-2022#launch-profile-net-core-net-5) IDE.
---
#### (Optional) Part 5: Adding Script Dependencies
This part is optional and only to be used if your mod relies on the assemblies/code from another mod to run/compile. This will allow you to add Script/Code ContentPackages as dependencies to make sure they load first.
1. Open `<ProjectDirectory>/Assets/RunConfig.cfg` it should look like this:
```xml
<?xml version="1.0" encoding="utf-8"?>
<RunConfig>
<!--Options: "None" / "Forced" (always) / "Standard" (when enabled)-->
<Server>Standard</Server>
<Client>Standard</Client>
</RunConfig>
```
2. Add a `Dependencies` section/node/element:
```xml
<?xml version="1.0" encoding="utf-8"?>
<RunConfig>
<!--Options: "None" / "Forced" (always) / "Standard" (when enabled)-->
<Server>Standard</Server>
<Client>Standard</Client>
<Dependencies>
</Dependencies>
</RunConfig>
```
3. Add the STEAMID **or** Name of your dependencies surrounded by `<Dependency></Dependency>` elements as follows:
- `<PackageName>Name</PackageName>` for name matching
- `<SteamWorkshopId>000000</SteamWorkshopId>` and replace zeroes with the dependency's workshop steam id.
```xml
<?xml version="1.0" encoding="utf-8"?>
<RunConfig>
<!--Options: "None" / "Forced" (always) / "Standard" (when enabled)-->
<Server>Standard</Server>
<Client>Standard</Client>
<Dependencies>
<Dependency>
<!-- You do not need both of these, the SteamWorkshopId is usually enough -->
<SteamWorkshopId><!--ID goes here--></SteamWorkshopId>
<PackageName><!--Name goes here--></PackageName>
</Dependency>
<Dependency> <!-- Dependency 2 Example -->
<PackageName>modding toolkit</PackageName>
</Dependency>
</Dependencies>
</RunConfig>
```
And you're good to go!
## Setting Up Simple Mod
The main star of the show is Barotrauma.ACsMod class. It is what most of your mods will use to hook game methods, and execute custom code. If you are planning on creating new components it's possible to just inherit from ItemComponent.
### Important features
- Mods have full access to Harmony to allow you to perform any patches you wish.
- All utility classes can be accessed either by their type (i.e that have name that starts with `LuaCs...`) or through `GameMain.LuaCs` property (refer to [class documentation](#ltcd)).
- All C# code files must be located in `<mod_root>/CSharp/*` otherwise they won't be compiled
- To configure **server / client** execution behaviour create `RunConfig.xml` in `CSharp` directory, like is shown below (run types are `Standard`, `Forced` and `None`)
- Additionally you can specify what code runs where by either ***filepath*** or ***pre-processor statements***
- In case of filepath, your files must be located in either `CSharp/Shared/*`, `CSharp/Server/*` or `CSharp/Client/*`, for *shared* code, *server-side* code or *client-side* code respectively (in any other case, the code is assumed to be shared)
- I case of pre-processor, you can use `SERVER` or `CLIENT` definitions to separate code into *server-side* code and *client-side* code respectively
### Code example
A generic C# mod boilerplate:
File-tree:
```
<mod_root>/
├─ CSharp/
│ ├─ RunConfig.xml
│ ├─ Shared/ExampleMod.cs
│ ├─ Server/ExampleMod.cs
│ └─ Client/ExampleMod.cs
└─ dummyitem.xml
```
____
`<mod_root>/CSharp/RunConfig.xml`
```xml
<?xml version="1.0" encoding="utf-8"?>
<RunConfig>
<Server>Standard</Server>
<Client>Standard</Client>
</RunConfig>
```
____
`<mod_root>/CSharp/Shared/ExampleMod.cs`
```csharp
using System;
using Barotrauma;
namespace ExampleNamespace {
partial class ExampleMod: ACsMod {
public ExampleMod() {
// shared code
...
#if SERVER
InitServer();
#elif CLIENT
InitClient();
#endif
}
public override void Stop() {
// stopping code, e.g. save custom data
#if SERVER
// server-side code
...
#elif CLIENT
// client-side code
...
#endif
}
}
}
```
____
`<mod_root>/CSharp/Server/ExampleMod.cs`
```csharp
using System;
using Barotrauma;
namespace ExampleNamespace {
partial class ExampleMod {
public void InitServer() {
// server-side initialization
...
}
}
}
```
____
`<mod_root>/CSharp/Client/ExampleMod.cs`
```csharp
using System;
using Barotrauma;
namespace ExampleNamespace {
partial class ExampleMod {
public void InitClient() {
// client-side initialization
...
}
}
}
```
____
`<mod_root>/dummyitem.xml`
```xml
<Items></Items>
```
## Links to class documentation {#ltcd}
- [Server documentation](../baro-server/html/index.html)
- [Client documentation](../baro-client/html/index.html)

View File

@@ -0,0 +1,115 @@
# Assembly CSharp Mod
One type of CSharp mod that can be created is an assembly mod. This type of mod is compiled into a .dll file and requires the distribution of dll files.
Assembly mods can be debugged in your favourite IDE and take full advantage of the entire .NET ecosystem. They take an initial effort to set up, but can be more powerful and flexible.
## Getting Started
---
### 1. IDE Setup
You will need an IDE that supports `.NET 6` as a platform/SDK target. Visual Studio 2022 is recommended. You can download it [here](https://visualstudio.microsoft.com/vs/). Other IDEs like JetBrains Rider also work, but there is no guarantee that the project will function as expected, although there should be little issue.
### 2. Project skeleton
Download or clone the following repository https://github.com/MapleWheels/VSProjectSkeleton, this contains the skeleton project that we will be using as the basis for this tutorial. Most things that need to be setup have already been done.
- If you do not have Git Tools installed, it is recommended that you get familiar with them as it makes life easier. [Download and install it](https://git-scm.com/downloads).
Make sure to extract the contents of the repository to a folder that you can easily access if you decided to manually download the zip file from github. You may also rename the directory to the name of your mod if you want.
### 3. Reference dlls
You also need to download the publicized reference dlls from https://github.com/evilfactory/LuaCsForBarotrauma/releases/download/latest/luacsforbarotrauma_refs.zip. This contains the publicized reference dlls that are required to build the project.
After downloading the zip file, extract the contents to the `Refs` folder in project skeleton directory. The directory structure should look like this:
```asciidoc
./Refs
----/Linux/Barotrauma.dll
----/Linux/DedicatedServer.dll
----/Windows/Barotrauma.dll
----/Windows/DedicatedServer.dll
...
```
### 4. Setup the project
First rename the `MyModName.sln` file to the name of your mod. IE: `ExampleMod.sln`.
Then open up the Solution file (`.sln`) from the Skeleton Project in Visual Studio. Just verify that there are not errors related to "Unable to find Reference", this means that all assemblies in `/Refs` have be found successfully.
After that, in your IDE, you will need to do the following for all `.csproj` files:
```asciidoc
- LinuxClient.csproj
- LinuxServer.csproj
- OSXClient.csproj
- OSXServer.csproj
- WindowsClient.csproj
- WindowsServer.csproj
```
- 1. Open the Project Configuration for the `.csproj` file by right-clicking and selecting `Properties`.
- 2. Change the `AssemblyName` to the name of your mod WITHOUT SPACES OR SPECIAL CHARACTERS. Example: `SampleMod`
- 3. Change the `Root Namespace` to either your mod's Assembly Name or mod's short version without spaces in plain English. Example: `SampleMod`.
Note: If you do not want either the `Client` plugin or the `Server` plugin (IE. Client-side or Server-side ONLY mod), then you must delete all projects that end with `Server`. Example: `LinuxServer`, `WindowsServer`. Warning, this is generally irreversible and will require you to setup new Cs Projects if you want a client in the future.
### 5. Setting up MSBuild to Copy Files into Local Mods.
You will have to do the following for the `Build.props` file found in the main project directory:
1. Open the file in your Text Editor or IDE of choice.
2. Locate the line `ModDeployDir`, IE:
```xml
<PropertyGroup>
<!-- IMPORTANT: Should point to <Barotrauma_Install>\LocalMods\<MyModName>\ -->
<!-- IMPORTANT: ModDeplyDir Path must end with '\' -->
<ModDeployDir>..\LUATRAMA_DEBUG_LOCALMODS_MYMODDIR\</ModDeployDir>
<!-- IMPORTANT: Avoid the use of special (IE: / : ; , \ < > ?) (periods "." are good) and non-english characters in the AssemblyName.-->
<AssemblyName>MyModName</AssemblyName>
</PropertyGroup>
```
3. Change the `ModDeployDir` value from `..\LUATRAMA_DEBUG_LOCALMODS_MYMODDIR\` to the path of your Barotrauma installation's `LocalMods` directory. IE: `C:\Program Files (x86)\Steam\steamapps\common\Barotrauma\LocalMods\MyModName\`.
- IMPORTANT: The value must end with `/` or `\ ` . IE: `...\LocalMods\ModdingToolkit\`.
4. Replace `MyModName` with a valid assembly name, this should be similar to your mod name but does not need to match. This name should:
- Not include spaces.
- Not include special characters except periods ( . ), which are allowed.
- Use english characters.
- Recommended: Follow the convention of `ModName` or `PackageName.LibraryName` for libraries, IE: `ModdingToolkit.GUI`.
### 6. Wrapping up
After setting up the project, you can start coding your mod. The project is already set up to build the mod into the `LocalMods` directory of your Barotrauma installation. You can now build the project and the mod dll files will be copied to the `LocalMods` directory.
## Extras
---
### Setting up a debug build of LuaCsForBarotrauma
This will give us a debug build of LuaCsForBarotrauma. A debug build gives us access to many tools as well as the `DEBUG` symbol for writing test/print code that will not be run in the release version.
1. Clone the [LuaCsForBarotrauma](https://github.com/evilfactory/LuaCsForBarotrauma) repository to your local drive. If you do not have Git Tools installed, please [download and install it](https://git-scm.com/downloads).
- Important: When cloning, use the command `git clone --recurse-submodules --remote-submodules https://github.com/evilfactory/LuaCsForBarotrauma.git`. This will download the submodules automatically.
2. Open up the LuaCs Solution in your IDE based on your Operating System, one of:
```asciidoc
- WindowsSolution.sln
- MacSolution.sln
- LinuxSolution.sln
```
-- NOTE: This assumes that you are using the `WindowsSolution.sln`. For other platforms, the naming of files may be slightly different (MacXXX, LinuxXXX, where 'XXX' is either "Client" or "Server").
3. In the Project Settings for `WindowsClient` and `WindowsServer`, you want to change the `Platform Target` from `Any CPU` to `x64`. This is necessary for OpenAL code to build successfully.
4. Build the whole Solution (`Build -> Build Solution`). This will create the necessary dependencies from libraries and make sure that there are no errors at this point.\
5. For both the `WindowsClient` and `WindowsServer` projects, set their output/build type to `DEBUG` (should be in a drop-down menu at the top next to a green play button).\
6. Select `Build Solution`. This will generate Debug builds for use. This debug build will now exist in `./Barotrauma/bin/DebugXXX/net6.0/` where `XXX` is based on your Solution choice. IE. `./Barotrauma/bin/DebugWindows/net6.0`.
Now instead of using your Barotrauma steam installation, you can use the debug build of LuaCsForBarotrauma to test your mods. Simply put your mod in the `LocalMods` directory of the debug build and set the ModDeployDir in the `Build.props` file.

View File

@@ -0,0 +1,5 @@
# Using Harmony
This is the main way you will be modifying the game. Harmony is a library that allows you to patch methods in the game's code. This allows you to change the behavior of the game without modifying the game's code directly.
You can find the Harmony documentation here https://harmony.pardeike.net/articles/basics.html it should explain everything you need to know about Harmony and how to use it.

View File

@@ -0,0 +1,57 @@
# In-memory CSharp Mod
---
One type of CSharp mod that can be created is an in-memory mod. This type of mod is compiled in memory and does not require the distribution of dll files. This type of mod is relatively easy to create and is useful for small mods that do not require a lot of complexity.
The disadvantage of in-memory mods is that they can take up a chunk of initialization time, as the mod must be compiled every time the mod is loaded. This type of mod also can't be easily debugged in your IDE or take full advantage of the entire .NET ecosystem.
## Getting Started
---
First you need to create a new Barotrauma mod as you are already familiar with. Then you need to create a folder named `CSharp` in the root of your mod folder. This is where you will put all your C# code files. All .cs source files in this folder will be compiled into the mod.
Source files inside the CSharp/Server and CSharp/Client folders will only be compiled for the server and client respectively. Files in the CSharp/Shared folder will be compiled for both the server and client.
### Example mod
____
`<mod_root>/CSharp/Shared/ExampleMod.cs`
```csharp
using System;
using Barotrauma;
// This is required so that the .NET runtime doesn't complain about you trying to access internal Types and Members
[assembly: IgnoreAccessChecksTo("Barotrauma")]
[assembly: IgnoreAccessChecksTo("BarotraumaCore")]
[assembly: IgnoreAccessChecksTo("DedicatedServer")]
namespace ExampleNamespace {
partial class ExampleMod : IAssemblyPlugin {
public void Initialize()
{
// When your plugin is loading, use this instead of the constructor
// Put any code here that does not rely on other plugins.
LuaCsLogger.Log("ExampleMod loaded!");
}
public void OnLoadCompleted()
{
// After all plugins have loaded
// Put code that interacts with other plugins here.
}
public void PreInitPatching()
{
// Not yet supported: Called during the Barotrauma startup phase before vanilla content is loaded.
}
public void Dispose()
{
// Cleanup your plugin!
LuaCsLogger.Log("ExampleMod disposed!");
}
}
}
```

View File

@@ -0,0 +1,22 @@
# Introduction
**[LuaCsForBarotrauma](https://github.com/evilfactory/LuaCsForBarotrauma)** also provides a way to write custom CSharp mods for %Barotrauma. Since this type of mod is not sandboxed, it's disabled by default and must be enabled in the LuaCs Settings menu.
If you are wondering how to get started with CSharp modding, this guide is for you. It will walk you through the process of setting up a new C# mod project, and provide you with a simple example to get you started.
## Enabling
To enable CSharp mod loading, you will have to go to your mainmenu, click top left LuaCs Settings, and enable the `Enable CSharp` option. If you do not have CSharp enabled and you join a server that has CSharp mods, you will receive a popup asking if you want to enable it for that session.
You can also enable by setting the `EnableCSharp` option in the `LuaCsConfig.xml` file found in the game root folder to `true`.
```xml
<?xml version="1.0" encoding="utf-8"?>
<LuaCsSetupConfig EnableCsScripting="true" TreatForcedModsAsNormal="false" PreferToUseWorkshopLuaSetup="false" DisableErrorGUIOverlay="false" HideUserNames="true" />
```
## Development
- [In-memory CSharp Mod](/md_manual_2inmemorymod.html)
- [Assembly CSharp Mod](/md_manual_2assemblymod.html)
- [Using Harmony](/md_manual_2harmony.html)

View File

@@ -3,7 +3,7 @@ Import-Module -DisableNameChecking $PSScriptRoot/../../scripts/location.psm1
try {
Change-Location $PSScriptRoot/..
if ((Get-Command "doxgen" -ErrorAction SilentlyContinue) -eq $null) {
if ((Get-Command "doxygen" -ErrorAction SilentlyContinue) -eq $null) {
echo "doxygen not found"
exit 1
}