diff --git a/.editorconfig b/.editorconfig index 8f0432e49..d1a5c2ee2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,38 @@ -[*.cs] +root = true +[*] +charset = utf-8 +insert_final_newline = true + +[*.{sln,cs}] +# VS defaults to utf-8 with BOM -- let's not create more merge conflicts +# XXX: csproj files dont't have a BOM for some reason? +charset = utf-8-bom + +[*.cs] +indent_style = space +indent_size = 4 +csharp_prefer_braces = when_multiline:warning +csharp_indent_case_contents_when_block = false # CS1591: Missing XML comment for publicly visible type or member dotnet_diagnostic.CS1591.severity = none + +[*.{html,xml,csproj}] +indent_style = space +indent_size = 2 + +[*.{sh,ps1}] +indent_style = space +indent_size = 2 + +[*.py] +indent_style = space +indent_size = 4 + +[*.{js,json}] +indent_style = space +indent_size = 2 + +[*.lua] +indent_style = space +indent_size = 2 diff --git a/.github/workflows/clean-docs.yml b/.github/workflows/clean-docs.yml deleted file mode 100644 index cc9e934f4..000000000 --- a/.github/workflows/clean-docs.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Clean Docs - -on: - workflow_dispatch: - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout branch - uses: actions/checkout@v2 - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs-landing-page diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml deleted file mode 100644 index a27daa0be..000000000 --- a/.github/workflows/dotnet-release.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: .NET Pre-Release - -on: - push: - branches: [ master ] - - workflow_dispatch: - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - include-prerelease: true - dotnet-version: | - 6.0.x - 5.0.x - - name: Restore dependencies - run: dotnet restore LinuxSolution.sln - - name: Build - run: dotnet build LinuxSolution.sln --no-restore - - name: Test - run: dotnet test LinuxSolution.sln --no-build --verbosity normal - - - name: Publish WindowsServer - run: dotnet publish Barotrauma/BarotraumaServer/WindowsServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r win-x64 \/p:Platform="x64" - - name: Publish WindowsClient - run: dotnet publish Barotrauma/BarotraumaClient/WindowsClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r win-x64 \/p:Platform="x64" - - - name: Publish LinuxServer - run: dotnet publish Barotrauma/BarotraumaServer/LinuxServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r linux-x64 \/p:Platform="x64" - - name: Publish LinuxClient - run: dotnet publish Barotrauma/BarotraumaClient/LinuxClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r linux-x64 \/p:Platform="x64" - - - name: Publish MacServer - run: dotnet publish Barotrauma/BarotraumaServer/MacServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r osx-x64 \/p:Platform="x64" - - name: Publish MacClient - run: dotnet publish Barotrauma/BarotraumaClient/MacClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r osx-x64 \/p:Platform="x64" - - - - name: Archive Windows Release - uses: thedoctor0/zip-release@main - with: - type: 'zip' - filename: 'barotrauma_lua_windows.zip' - #exclusions: '*.git* /*node_modules/* .editorconfig' - directory: 'Barotrauma/bin/ReleaseWindows/netcoreapp3.1/win-x64/publish' - - - name: Archive Linux Release - uses: thedoctor0/zip-release@main - with: - type: 'zip' - filename: 'barotrauma_lua_linux.zip' - #exclusions: '*.git* /*node_modules/* .editorconfig' - directory: 'Barotrauma/bin/ReleaseLinux/netcoreapp3.1/linux-x64/publish' - - - name: Archive Mac Release - uses: thedoctor0/zip-release@main - with: - type: 'zip' - filename: 'barotrauma_lua_mac.zip' - #exclusions: '*.git* /*node_modules/* .editorconfig' - directory: 'Barotrauma/bin/ReleaseMac/netcoreapp3.1/osx-x64/publish' - - - name: Automatic Release - uses: marvinpinto/action-automatic-releases@v1.2.1 - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - automatic_release_tag: "latest" - prerelease: false - title: "Automatic Build" - files: | - Barotrauma/bin/ReleaseWindows/netcoreapp3.1/win-x64/publish/barotrauma_lua_windows.zip - Barotrauma/bin/ReleaseLinux/netcoreapp3.1/linux-x64/publish/barotrauma_lua_linux.zip - Barotrauma/bin/ReleaseMac/netcoreapp3.1/osx-x64/publish/barotrauma_lua_mac.zip diff --git a/.github/workflows/generate-cs-docs.yml b/.github/workflows/generate-cs-docs.yml deleted file mode 100644 index 31fe41870..000000000 --- a/.github/workflows/generate-cs-docs.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Generate Docs - Cs - -on: - workflow_run: - workflows: ["Clean Docs"] - types: - - completed - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout branch - uses: actions/checkout@v2 - - - name: Create directories - run: mkdir -p doxygen/build ; mkdir -p doxygen/build/baro-server ; mkdir -p doxygen/build/baro-client - - - name: Build server documentation - uses: mattnotmitt/doxygen-action@v1.9.1 - with: - working-directory: 'doxygen/baro-server' - doxyfile-path: './Doxyfile' - - - name: Build client documentation - uses: mattnotmitt/doxygen-action@v1.9.1 - with: - working-directory: 'doxygen/baro-client' - doxyfile-path: './Doxyfile' - - - name: Build containing documentation - uses: mattnotmitt/doxygen-action@v1.9.1 - with: - working-directory: 'doxygen/' - doxyfile-path: './Doxyfile' - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: doxygen/build - destination_dir: cs-docs - keep_files: true diff --git a/.github/workflows/generate-lua-docs.yml b/.github/workflows/generate-lua-docs.yml deleted file mode 100644 index 42b930917..000000000 --- a/.github/workflows/generate-lua-docs.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Generate Docs - Lua - -on: - workflow_run: - workflows: ["Clean Docs"] - types: - - completed - -jobs: - docs: - runs-on: ubuntu-latest - - steps: - - name: Checkout branch - uses: actions/checkout@v2 - - - uses: leafo/gh-actions-lua@v8.0.0 - with: - luaVersion: "5.2" - - - uses: leafo/gh-actions-luarocks@v4.0.0 - - - name: Pull LDoc - uses: actions/checkout@v2 - with: - repository: impulsh/LDoc - path: ldoc - - - name: Build LDoc - working-directory: ldoc - run: luarocks make - - - name: Build docs - run: ldoc . - - - name: Copy assets - run: | - cp -v docs/css/* docs/html - cp -v docs/js/* docs/html - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/html - destination_dir: lua-docs - keep_files: true diff --git a/.github/workflows/on-push-master.yml b/.github/workflows/on-push-master.yml new file mode 100644 index 000000000..41fdb22ac --- /dev/null +++ b/.github/workflows/on-push-master.yml @@ -0,0 +1,17 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: On push to master branch + +on: + push: + branches: [master] + +jobs: + run-tests: + uses: ./.github/workflows/run-tests.yml + with: + ref: ${{ github.event.ref }} + + publish-release: + needs: [run-tests] + uses: ./.github/workflows/publish-release.yml diff --git a/.github/workflows/on-push-other-branch.yml b/.github/workflows/on-push-other-branch.yml new file mode 100644 index 000000000..c08bdbd1b --- /dev/null +++ b/.github/workflows/on-push-other-branch.yml @@ -0,0 +1,13 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: On push to a secondary branch + +on: + push: + branches-ignore: [master] + +jobs: + run-tests: + uses: ./.github/workflows/run-tests.yml + with: + ref: ${{ github.event.ref }} diff --git a/.github/workflows/on-push-pr.yml b/.github/workflows/on-push-pr.yml new file mode 100644 index 000000000..5a2f123fb --- /dev/null +++ b/.github/workflows/on-push-pr.yml @@ -0,0 +1,12 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: On push to a PR + +on: + pull_request: + +jobs: + run-tests-for-pr: + uses: ./.github/workflows/run-tests.yml + with: + ref: ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 000000000..c70115a52 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,72 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: Publish release + +on: + workflow_dispatch: + workflow_call: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout branch + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: | + 3.1.x + 6.0.x + + - name: "Build: WindowsServer" + run: dotnet publish Barotrauma/BarotraumaServer/WindowsServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r win-x64 \/p:Platform="x64" + - name: "Build: WindowsClient" + run: dotnet publish Barotrauma/BarotraumaClient/WindowsClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r win-x64 \/p:Platform="x64" + + - name: "Build: LinuxServer" + run: dotnet publish Barotrauma/BarotraumaServer/LinuxServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r linux-x64 \/p:Platform="x64" + - name: "Build: LinuxClient" + run: dotnet publish Barotrauma/BarotraumaClient/LinuxClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r linux-x64 \/p:Platform="x64" + + - name: "Build: MacServer" + run: dotnet publish Barotrauma/BarotraumaServer/MacServer.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r osx-x64 \/p:Platform="x64" + - name: "Build: MacClient" + run: dotnet publish Barotrauma/BarotraumaClient/MacClient.csproj -c Release -clp:"ErrorsOnly;Summary" --self-contained -r osx-x64 \/p:Platform="x64" + + - name: "Create zip file: windows" + uses: thedoctor0/zip-release@main + with: + type: zip + filename: barotrauma_lua_windows.zip + directory: Barotrauma/bin/ReleaseWindows/netcoreapp3.1/win-x64/publish + + - name: "Create zip file: linux" + uses: thedoctor0/zip-release@main + with: + type: zip + filename: barotrauma_lua_linux.zip + directory: Barotrauma/bin/ReleaseLinux/netcoreapp3.1/linux-x64/publish + + - name: "Create zip file: mac" + uses: thedoctor0/zip-release@main + with: + type: zip + filename: barotrauma_lua_mac.zip + directory: Barotrauma/bin/ReleaseMac/netcoreapp3.1/osx-x64/publish + + - name: Publish release + uses: marvinpinto/action-automatic-releases@v1.2.1 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + automatic_release_tag: latest + prerelease: false + title: Automatic Build + files: | + Barotrauma/bin/ReleaseWindows/netcoreapp3.1/win-x64/publish/barotrauma_lua_windows.zip + Barotrauma/bin/ReleaseLinux/netcoreapp3.1/linux-x64/publish/barotrauma_lua_linux.zip + Barotrauma/bin/ReleaseMac/netcoreapp3.1/osx-x64/publish/barotrauma_lua_mac.zip diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 000000000..1d7c3f22f --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,50 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: Run tests + +on: + workflow_call: + inputs: + ref: + required: true + type: string + +jobs: + run-tests: + runs-on: ubuntu-latest + steps: + - name: Checkout branch + uses: actions/checkout@v3 + with: + repository: ${{ inputs.repository }} + ref: ${{ inputs.ref }} + submodules: recursive + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: | + 3.1.x + 6.0.x + + - name: Initialize environment + run: | + mkdir -p ~/".local/share/Daedalic Entertainment GmbH/Barotrauma" + + - name: Run tests + continue-on-error: true + run: dotnet test LinuxSolution.sln -clp:"ErrorsOnly;Summary" --logger "trx;LogFileName=$PWD/test-results.trx" + + - name: Upload test results + uses: actions/upload-artifact@v3 + with: + name: test-results + path: test-results.trx + + - name: Report test results + uses: dorny/test-reporter@v1 + with: + name: Test results + path: test-results.trx + fail-on-error: true + reporter: dotnet-trx diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml new file mode 100644 index 000000000..b70fb300d --- /dev/null +++ b/.github/workflows/update-docs.yml @@ -0,0 +1,119 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: Update documentation + +on: + workflow_dispatch: + +env: + CI_DEPLOY_DIR: luacs-docs/ci-deploy + CI_ARTIFACTS_DIR: luacs-docs/ci-artifacts + DOCS_LUA_ROOT: luacs-docs/lua + DOCS_CS_ROOT: luacs-docs/cs + DOCS_LANDINGPAGE_ROOT: luacs-docs/landing-page + +jobs: + update-docs-lua: + runs-on: ubuntu-latest + steps: + - name: Checkout branch + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: | + 3.1.x + 6.0.x + + - uses: leafo/gh-actions-lua@v8 + with: + luaVersion: "5.2" + + - uses: leafo/gh-actions-luarocks@v4 + + - name: Run install script + working-directory: ${{ env.DOCS_LUA_ROOT }} + run: ./scripts/install.sh + + - name: Run docs generator script + working-directory: ${{ env.DOCS_LUA_ROOT }} + run: ./scripts/generate_docs.sh + + - name: Run build script + working-directory: ${{ env.DOCS_LUA_ROOT }} + run: ./scripts/build.sh + + - name: Create tarball + run: | + mkdir -p "$CI_ARTIFACTS_DIR" + tar -czf "$CI_ARTIFACTS_DIR"/lua.tar.gz -C "$DOCS_LUA_ROOT"/build . + + - name: Upload tarball + uses: actions/upload-artifact@v3 + with: + name: docs-lua + path: ${{ env.CI_ARTIFACTS_DIR }}/lua.tar.gz + + update-docs-cs: + runs-on: ubuntu-latest + steps: + - name: Checkout branch + uses: actions/checkout@v3 + + - name: Install doxygen + run: sudo apt-get update && sudo apt-get install -y doxygen + + - name: Run build script + working-directory: ${{ env.DOCS_CS_ROOT }} + run: ./scripts/build.sh + + - name: Create tarball + run: | + mkdir -p "$CI_ARTIFACTS_DIR" + tar -czf "$CI_ARTIFACTS_DIR"/cs.tar.gz -C "$DOCS_CS_ROOT"/build . + + - name: Upload tarball + uses: actions/upload-artifact@v3 + with: + name: docs-cs + path: ${{ env.CI_ARTIFACTS_DIR }}/cs.tar.gz + + deploy-docs: + runs-on: ubuntu-latest + needs: [update-docs-lua, update-docs-cs] + steps: + - name: Checkout branch + uses: actions/checkout@v3 + + - run: mkdir -p "$CI_ARTIFACTS_DIR" "$CI_DEPLOY_DIR" + + - name: "Download build artifacts: lua docs" + uses: actions/download-artifact@v3 + with: + name: docs-lua + path: ${{ env.CI_ARTIFACTS_DIR }} + + - name: "Download build artifacts: cs docs" + uses: actions/download-artifact@v3 + with: + name: docs-cs + path: ${{ env.CI_ARTIFACTS_DIR }} + + - name: Extract lua and cs tarballs + run: | + mkdir -p "$CI_DEPLOY_DIR"/{lua,cs}-docs + tar -xzf "$CI_ARTIFACTS_DIR"/lua.tar.gz -C "$CI_DEPLOY_DIR"/lua-docs + tar -xzf "$CI_ARTIFACTS_DIR"/cs.tar.gz -C "$CI_DEPLOY_DIR"/cs-docs + + - name: Copy landing page files + run: cp -r "$DOCS_LANDINGPAGE_ROOT"/. "$CI_DEPLOY_DIR" + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ${{ env.CI_DEPLOY_DIR }} + keep_files: true diff --git a/.gitignore b/.gitignore index 83b4a80fa..3009d17ba 100644 --- a/.gitignore +++ b/.gitignore @@ -13,12 +13,8 @@ bld/ [Rr]elease*/ *.o */Barotrauma*/doc/ -doxygen/html/ -doxygen/*/html/ -doxygen/*/*.tag -doxygen/build -# Misc vs crap +# Misc vs crap *.v12.suo *.suo *.csproj.user @@ -51,7 +47,6 @@ desktop.ini # Merge script temp.txt -docs/html # Private assets Barotrauma/BarotraumaShared/Content/* Barotrauma/**/GameAnalyticsKeys.cs diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..7717574dc --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "Libraries/moonsharp"] + path = Libraries/moonsharp + url = https://github.com/evilfactory/moonsharp.git +[submodule "luacs-docs/lua/libs/ldoc"] + path = luacs-docs/lua/libs/ldoc + url = https://github.com/evilfactory/LDoc.git diff --git a/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs b/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs index c7220c8c9..d52053c6e 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs @@ -3256,7 +3256,8 @@ namespace Barotrauma } }); - commands.Add(new Command("cl_lua", "lua_cl: runs a string on the client", (string[] args) => + const string CMD_CL_LUA = "cl_lua"; + commands.Add(new Command(CMD_CL_LUA, $"{CMD_CL_LUA}: runs a string on the client", (string[] args) => { if (GameMain.Client != null && !GameMain.Client.HasPermission(ClientPermissions.ConsoleCommands)) { @@ -3270,10 +3271,12 @@ namespace Barotrauma } catch(Exception ex) { - GameMain.LuaCs.HandleException(ex); + GameMain.LuaCs.HandleException(ex, LuaCsMessageOrigin.LuaMod); } })); - commands.Add(new Command("cl_cs", "cs_cl: runs a string on the client", (string[] args) => + + const string CMD_CL_CS = "cl_cs"; + commands.Add(new Command(CMD_CL_CS, $"{CMD_CL_CS}: runs a string on the client", (string[] args) => { if (LuaCsSetup.GetPackage("CsForBarotrauma", false, true) == null) { return; } diff --git a/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs b/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs index cdae6eae4..3fd8e318c 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/GameMain.cs @@ -20,7 +20,7 @@ namespace Barotrauma { class GameMain : Game { - public static LuaCsSetup LuaCs; + internal static LuaCsSetup LuaCs; public static bool ShowFPS = false; public static bool ShowPerf = false; diff --git a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsUpdateChecker.cs b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsUpdateChecker.cs index 332fdad83..4fa29b0e1 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsUpdateChecker.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/LuaCs/LuaCsUpdateChecker.cs @@ -31,6 +31,7 @@ namespace Barotrauma { "Barotrauma.dll", "Barotrauma.deps.json", "0harmony.dll", "Mono.Cecil.dll", + "Sigil.dll", "Mono.Cecil.Mdb.dll", "Mono.Cecil.Pdb.dll", "Mono.Cecil.Rocks.dll", "MonoMod.Common.dll", "MoonSharp.Interpreter.dll", diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj index d51ae3431..e0ac1dffb 100644 --- a/Barotrauma/BarotraumaClient/LinuxClient.csproj +++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj @@ -1,5 +1,10 @@ + + + + + WinExe netcoreapp3.1 @@ -138,21 +143,10 @@ - - - - - ..\..\Libraries\0Harmony.dll - - - ..\..\Libraries\MoonSharp.Interpreter.dll - - - @@ -222,4 +216,4 @@ - \ No newline at end of file + diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj index fb9a8c51f..30b6ad713 100644 --- a/Barotrauma/BarotraumaClient/MacClient.csproj +++ b/Barotrauma/BarotraumaClient/MacClient.csproj @@ -1,5 +1,10 @@ + + + + + WinExe netcoreapp3.1 @@ -130,8 +135,6 @@ - - @@ -143,14 +146,6 @@ PreserveNewest - - - ..\..\Libraries\0Harmony.dll - - - ..\..\Libraries\MoonSharp.Interpreter.dll - - PreserveNewest @@ -224,4 +219,4 @@ - \ No newline at end of file + diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj index 1c96d533e..200e77b7b 100644 --- a/Barotrauma/BarotraumaClient/WindowsClient.csproj +++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj @@ -1,5 +1,10 @@  + + + + + WinExe netcoreapp3.1 @@ -137,21 +142,10 @@ - - - - - ..\..\Libraries\0Harmony.dll - - - ..\..\Libraries\MoonSharp.Interpreter.dll - - - Never diff --git a/Barotrauma/BarotraumaServer/LinuxServer.csproj b/Barotrauma/BarotraumaServer/LinuxServer.csproj index 0828ce53f..97aca5a84 100644 --- a/Barotrauma/BarotraumaServer/LinuxServer.csproj +++ b/Barotrauma/BarotraumaServer/LinuxServer.csproj @@ -1,5 +1,10 @@ + + + + + Exe netcoreapp3.1 @@ -86,19 +91,8 @@ - - - - - - ..\..\Libraries\0Harmony.dll - - - ..\..\Libraries\MoonSharp.Interpreter.dll - - diff --git a/Barotrauma/BarotraumaServer/MacServer.csproj b/Barotrauma/BarotraumaServer/MacServer.csproj index 731599318..90d94a8cf 100644 --- a/Barotrauma/BarotraumaServer/MacServer.csproj +++ b/Barotrauma/BarotraumaServer/MacServer.csproj @@ -1,5 +1,10 @@ + + + + + Exe netcoreapp3.1 @@ -83,8 +88,6 @@ - - @@ -95,14 +98,6 @@ PreserveNewest - - - ..\..\Libraries\0Harmony.dll - - - ..\..\Libraries\MoonSharp.Interpreter.dll - - diff --git a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs index 7c99f4369..5cd0bf125 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs @@ -1249,7 +1249,7 @@ namespace Barotrauma } catch (Exception ex) { - GameMain.LuaCs.HandleException(ex); + GameMain.LuaCs.HandleException(ex, LuaCsMessageOrigin.LuaMod); } })); commands.Add(new Command("cs", "cs: runs a string", (string[] args) => @@ -1284,6 +1284,7 @@ namespace Barotrauma { "Barotrauma.dll", "Barotrauma.deps.json", "0harmony.dll", "Mono.Cecil.dll", + "Sigil.dll", "Mono.Cecil.Mdb.dll", "Mono.Cecil.Pdb.dll", "Mono.Cecil.Rocks.dll", "MonoMod.Common.dll", "MoonSharp.Interpreter.dll", @@ -1318,13 +1319,13 @@ namespace Barotrauma } catch (UnauthorizedAccessException e) { - GameMain.LuaCs.PrintError("You seem to already have Client Side Lua installed, if you are trying to reinstall, make sure uninstall it first (mainmenu button located top left)."); + GameMain.LuaCs.PrintError("You seem to already have Client Side Lua installed, if you are trying to reinstall, make sure uninstall it first (mainmenu button located top left).", LuaCsMessageOrigin.LuaCs); return; } catch (Exception e) { - GameMain.LuaCs.HandleException(e); + GameMain.LuaCs.HandleException(e, LuaCsMessageOrigin.LuaCs); return; } diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj b/Barotrauma/BarotraumaServer/WindowsServer.csproj index d1e747e39..85c7e124e 100644 --- a/Barotrauma/BarotraumaServer/WindowsServer.csproj +++ b/Barotrauma/BarotraumaServer/WindowsServer.csproj @@ -1,5 +1,10 @@ + + + + + Exe netcoreapp3.1 @@ -85,19 +90,8 @@ - - - - - - ..\..\Libraries\0Harmony.dll - - - ..\..\Libraries\MoonSharp.Interpreter.dll - - diff --git a/Barotrauma/BarotraumaShared/Lua/DefaultHook.lua b/Barotrauma/BarotraumaShared/Lua/DefaultHook.lua index c5c964a4a..5ae912621 100644 --- a/Barotrauma/BarotraumaShared/Lua/DefaultHook.lua +++ b/Barotrauma/BarotraumaShared/Lua/DefaultHook.lua @@ -1,81 +1,87 @@ -Hook.HookMethod( - "Barotrauma.Item", "TryInteract", - { - "Barotrauma.Character", - "System.Boolean", - "System.Boolean", - "System.Boolean" - }, - function (instance, p) - if Hook.Call("item.interact", instance, p.picker, p.ignoreRequiredItems, p.forceSelectKey, p.forceActionKey) == true then - return false - end - end, - Hook.HookMethodType.Before +Hook.Patch( + "Barotrauma.Item", "TryInteract", + { + "Barotrauma.Character", + "System.Boolean", + "System.Boolean", + "System.Boolean" + }, + function(instance, p) + if Hook.Call("item.interact", instance, p["user"], p["ignoreRequiredItems"], p["forceSelectKey"], p["forceUseKey"]) == true then + p.PreventExecution = true + return false + end + end, + Hook.HookMethodType.Before ) -Hook.HookMethod( - "Barotrauma.Item", "ApplyTreatment", - { - "Barotrauma.Character", - "Barotrauma.Character", - "Barotrauma.Limb" - }, - function (instance, p) - if Hook.Call("item.applyTreatment", instance, p.user, p.character, p.targetLimb) then - return false - end - end, - Hook.HookMethodType.Before +Hook.Patch( + "Barotrauma.Item", "ApplyTreatment", + { + "Barotrauma.Character", + "Barotrauma.Character", + "Barotrauma.Limb" + }, + function(instance, p) + if Hook.Call("item.applyTreatment", instance, p["user"], p["character"], p["targetLimb"]) then + p.PreventExecution = true + return false + end + end, + Hook.HookMethodType.Before ) -Hook.HookMethod( - "Barotrauma.Item", "Combine", - { - "Barotrauma.Item", - "Barotrauma.Character" - }, - function (instance, p) - if Hook.Call("item.combine", instance, p.item, p.user) == true then - return false - end - end, - Hook.HookMethodType.Before +Hook.Patch( + "Barotrauma.Item", "Combine", + { + "Barotrauma.Item", + "Barotrauma.Character" + }, + function(instance, p) + if Hook.Call("item.combine", instance, p["item"], p["user"]) == true then + p.PreventExecution = true + return false + end + end, + Hook.HookMethodType.Before ) -Hook.HookMethod( - "Barotrauma.Item", "Drop", - function (instance, p) - if Hook.Call("item.drop", instance, p.dropper) == true then - return false - end - end, - Hook.HookMethodType.Before +Hook.Patch( + "Barotrauma.Item", "Drop", + function(instance, p) + if Hook.Call("item.drop", instance, p["dropper"]) == true then + p.PreventExecution = true + return false + end + end, + Hook.HookMethodType.Before ) -Hook.HookMethod( - "Barotrauma.Item", "Equip", - { - "Barotrauma.Character" - }, - function (instance, p) - if Hook.Call("item.equip", instance, p.character) == true then - return false - end - end, - Hook.HookMethodType.Before +Hook.Patch( + "Barotrauma.Item", "Equip", + { + "Barotrauma.Character" + }, + function(instance, p) + if Hook.Call("item.equip", instance, p["character"]) == true then + p.PreventExecution = true + return false + end + end, + Hook.HookMethodType.Before ) -Hook.HookMethod( - "Barotrauma.Item", "Unequip", - { - "Barotrauma.Character" - }, - function (instance, p) - if Hook.Call("item.unequip", instance, p.character) == true then - return false - end - end, - Hook.HookMethodType.Before +Hook.Patch( + "Barotrauma.Item", "Unequip", + { + "Barotrauma.Character" + }, + function(instance, p) + if Hook.Call("item.unequip", instance, p["character"]) == true then + p.PreventExecution = true + return false + end + end, + Hook.HookMethodType.Before ) diff --git a/Barotrauma/BarotraumaShared/Lua/DefaultLib/LibShared.lua b/Barotrauma/BarotraumaShared/Lua/DefaultLib/LibShared.lua index 72d3809a2..66eed4c4f 100644 --- a/Barotrauma/BarotraumaShared/Lua/DefaultLib/LibShared.lua +++ b/Barotrauma/BarotraumaShared/Lua/DefaultLib/LibShared.lua @@ -6,9 +6,21 @@ local CreateEnum = LuaSetup.LuaUserData.CreateEnumTable require("DefaultLib/Utils/SteamApi") +defaultLib["SByte"] = CreateStatic("Barotrauma.LuaSByte", true) defaultLib["Byte"] = CreateStatic("Barotrauma.LuaByte", true) -defaultLib["UShort"] = CreateStatic("Barotrauma.LuaUShort", true) -defaultLib["Float"] = CreateStatic("Barotrauma.LuaFloat", true) +defaultLib["Int16"] = CreateStatic("Barotrauma.LuaInt16", true) +defaultLib["UInt16"] = CreateStatic("Barotrauma.LuaUInt16", true) +defaultLib["Int32"] = CreateStatic("Barotrauma.LuaInt32", true) +defaultLib["UInt32"] = CreateStatic("Barotrauma.LuaUInt32", true) +defaultLib["Int64"] = CreateStatic("Barotrauma.LuaInt64", true) +defaultLib["UInt64"] = CreateStatic("Barotrauma.LuaUInt64", true) +defaultLib["Single"] = CreateStatic("Barotrauma.LuaSingle", true) +defaultLib["Double"] = CreateStatic("Barotrauma.LuaDouble", true) + +-- Backward compatibility +defaultLib["Float"] = CreateStatic("Barotrauma.LuaSingle", true) +defaultLib["Short"] = CreateStatic("Barotrauma.LuaInt16", true) +defaultLib["UShort"] = CreateStatic("Barotrauma.LuaUInt16", true) defaultLib["SpawnType"] = CreateEnum("Barotrauma.SpawnType") defaultLib["ChatMessageType"] = CreateEnum("Barotrauma.Networking.ChatMessageType") diff --git a/Barotrauma/BarotraumaShared/Lua/DefaultRegister/RegisterShared.lua b/Barotrauma/BarotraumaShared/Lua/DefaultRegister/RegisterShared.lua index 95b2910c4..b10842ef6 100644 --- a/Barotrauma/BarotraumaShared/Lua/DefaultRegister/RegisterShared.lua +++ b/Barotrauma/BarotraumaShared/Lua/DefaultRegister/RegisterShared.lua @@ -4,9 +4,16 @@ local RegisterBarotrauma = LuaSetup.LuaUserData.RegisterTypeBarotrauma Register("System.TimeSpan") Register("System.Exception") +RegisterBarotrauma("LuaSByte") RegisterBarotrauma("LuaByte") -RegisterBarotrauma("LuaUShort") -RegisterBarotrauma("LuaFloat") +RegisterBarotrauma("LuaInt16") +RegisterBarotrauma("LuaUInt16") +RegisterBarotrauma("LuaInt32") +RegisterBarotrauma("LuaUInt32") +RegisterBarotrauma("LuaInt64") +RegisterBarotrauma("LuaUInt64") +RegisterBarotrauma("LuaSingle") +RegisterBarotrauma("LuaDouble") RegisterBarotrauma("Range`1[System.Single]") RegisterBarotrauma("Range`1[System.Int32]") diff --git a/Barotrauma/BarotraumaShared/LuaCsDependencies.props b/Barotrauma/BarotraumaShared/LuaCsDependencies.props new file mode 100644 index 000000000..21439206a --- /dev/null +++ b/Barotrauma/BarotraumaShared/LuaCsDependencies.props @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Cs/ACsMod.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Cs/ACsMod.cs index 51cd49f37..8d7e352ec 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Cs/ACsMod.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Cs/ACsMod.cs @@ -37,7 +37,7 @@ namespace Barotrauma } catch (Exception e) { - GameMain.LuaCs.HandleException(e, null, LuaCsSetup.ExceptionType.CSharp); + GameMain.LuaCs.HandleException(e, LuaCsMessageOrigin.CSharpMod); } LoadedMods.Remove(this); diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs index cfe0d0418..381e6a081 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs @@ -367,13 +367,11 @@ namespace Barotrauma public void AddCommand(string name, string help, LuaCsAction onExecute, LuaCsFunc getValidArgs = null, bool isCheat = false) { - var cmd = new DebugConsole.Command(name, help, (string[] arg1) => { onExecute(new object[] { arg1 }); }, + var cmd = new DebugConsole.Command(name, help, (string[] arg1) => onExecute(new object[] { arg1 }), () => { - if (getValidArgs == null) { return null; } - var obj = getValidArgs(); - if (obj is LuaResult lr) { return lr.DynValue().ToObject(); } - return (string[][])obj; + if (getValidArgs == null) return null; + return getValidArgs().ToObject(); }, isCheat); luaAddedCommand.Add(cmd); diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaResult.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaResult.cs deleted file mode 100644 index c71cb9e50..000000000 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaResult.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using MoonSharp.Interpreter; -using Microsoft.Xna.Framework; -using Barotrauma.Networking; -using Barotrauma.Items.Components; -using System.IO; -using System.Net; -using System.Linq; -using System.Xml.Linq; -using FarseerPhysics.Dynamics; -using System.Reflection; -using HarmonyLib; -using MoonSharp.Interpreter.Interop; -using System.Diagnostics; - -namespace Barotrauma -{ - public class LuaResult - { - object result; - public LuaResult(object arg) - { - result = arg; - } - - public bool IsNull() - { - if (result == null) - return true; - - if (result is DynValue dynValue) - return dynValue.IsNil(); - - return false; - } - - public bool Bool() - { - if (result is DynValue dynValue) - { - return dynValue.CastToBool(); - } - - return false; - } - - public float Float() - { - if (result is DynValue dynValue) - { - var num = dynValue.CastToNumber(); - if (num == null) { return 0f; } - return (float)num.Value; - } - - return 0f; - } - - public double Double() - { - if (result is DynValue dynValue) - { - var num = dynValue.CastToNumber(); - if (num == null) { return 0f; } - return num.Value; - } - - return 0f; - } - - public string String() - { - if (result is DynValue dynValue) - { - var str = dynValue.CastToString(); - if (str == null) { return ""; } - return str; - } - - return ""; - } - - public object Object() - { - if (result is DynValue dynValue) - { - return dynValue.ToObject(); - } - - return null; - } - - public DynValue DynValue() - { - if (result is DynValue dynValue) - { - return dynValue; - } - - return null; - } - } -} \ No newline at end of file diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaTypes.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaTypes.cs index 26fc72d66..7ba5e796f 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaTypes.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaTypes.cs @@ -1,41 +1,184 @@ using System; -using System.ComponentModel; namespace Barotrauma { - public class LuaByte - { - public byte Value; + public struct LuaSByte + { + private readonly sbyte value; - public LuaByte(byte v) - { - Value = v; - } + public LuaSByte(double v) + { + value = (sbyte)v; + } - public static implicit operator byte(LuaByte lb) => lb.Value; - } + public LuaSByte(string v, int radix = 10) + { + value = Convert.ToSByte(v, radix); + } - public class LuaUShort - { - public ushort Value; + public static implicit operator sbyte(LuaSByte luaValue) => luaValue.value; + } - public LuaUShort(ushort v) - { - Value = v; - } + public struct LuaByte + { + private readonly byte value; - public static implicit operator ushort(LuaUShort lb) => lb.Value; - } + public LuaByte(double v) + { + value = (byte)v; + } - public class LuaFloat - { - public float Value; + public LuaByte(string v, int radix = 10) + { + value = Convert.ToByte(v, radix); + } - public LuaFloat(float v) - { - Value = v; - } + public static implicit operator byte(LuaByte luaValue) => luaValue.value; + } - public static implicit operator float(LuaFloat lb) => lb.Value; - } + public struct LuaInt16 + { + private readonly short value; + + public LuaInt16(double v) + { + value = (short)v; + } + + public LuaInt16(string v, int radix = 10) + { + value = Convert.ToInt16(v, radix); + } + + public static implicit operator short(LuaInt16 luaValue) => luaValue.value; + } + + public struct LuaUInt16 + { + private readonly ushort value; + + public LuaUInt16(double v) + { + value = (ushort)v; + } + + public LuaUInt16(string v, int radix = 10) + { + value = Convert.ToUInt16(v, radix); + } + + public static implicit operator ushort(LuaUInt16 luaValue) => luaValue.value; + } + + public struct LuaInt32 + { + private readonly int value; + + public LuaInt32(double v) + { + value = (int)v; + } + + public LuaInt32(string v, int radix = 10) + { + value = Convert.ToInt32(v, radix); + } + + public static implicit operator int(LuaInt32 luaValue) => luaValue.value; + } + + public struct LuaUInt32 + { + private readonly uint value; + + public LuaUInt32(double v) + { + value = (uint)v; + } + + public LuaUInt32(string v, int radix = 10) + { + value = Convert.ToUInt32(v, radix); + } + + public static implicit operator uint(LuaUInt32 luaValue) => luaValue.value; + } + + public struct LuaInt64 + { + private readonly long value; + + public LuaInt64(double v) + { + value = (long)v; + } + + public LuaInt64(double lo, double hi) + { + value = Convert.ToUInt32(lo) | (long)Convert.ToInt32(hi) << 32; + } + + public LuaInt64(string v, int radix = 10) + { + value = Convert.ToInt64(v, radix); + } + + public static implicit operator long(LuaInt64 luaValue) => luaValue.value; + } + + public struct LuaUInt64 + { + private readonly ulong value; + + public LuaUInt64(double v) + { + value = (ulong)v; + } + + public LuaUInt64(double lo, double hi) + { + value = Convert.ToUInt32(lo) | (ulong)Convert.ToUInt32(hi) << 32; + } + + public LuaUInt64(string v, int radix = 10) + { + value = Convert.ToUInt64(v, radix); + } + + public static implicit operator ulong(LuaUInt64 luaValue) => luaValue.value; + } + + public struct LuaSingle + { + private readonly float value; + + public LuaSingle(double v) + { + value = (float)v; + } + + public LuaSingle(string v) + { + value = float.Parse(v); + } + + public static implicit operator float(LuaSingle luaValue) => luaValue.value; + } + + public struct LuaDouble + { + private readonly double value; + + public LuaDouble(double v) + { + value = v; + } + + public LuaDouble(string v) + { + value = double.Parse(v); + } + + public static implicit operator double(LuaDouble luaValue) => luaValue.value; + } } \ No newline at end of file diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaUserData.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaUserData.cs index 6736d9723..94b74963e 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaUserData.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaUserData.cs @@ -11,20 +11,27 @@ namespace Barotrauma { public static Type GetType(string typeName) { + var byRef = false; + if (typeName.StartsWith("out ") || typeName.StartsWith("ref ")) + { + typeName = typeName.Remove(0, 4); + byRef = true; + } + var type = Type.GetType(typeName); - if (type != null) return type; + if (type != null) return byRef ? type.MakeByRefType() : type; foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) { if (CsScriptBase.LoadedAssemblyName.Contains(a.GetName().Name)) - { + { var attrs = a.GetCustomAttributes(); var revision = attrs.FirstOrDefault(attr => attr.Key == "Revision")?.Value; if (revision != null && int.Parse(revision) != (int)CsScriptBase.Revision[a.GetName().Name]) { continue; } - } + } type = a.GetType(typeName); if (type != null) { - return type; + return byRef ? type.MakeByRefType() : type; } } return null; diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaCustomConverters.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaCustomConverters.cs index ecae3a6cb..937cd26ae 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaCustomConverters.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaCustomConverters.cs @@ -1,127 +1,195 @@ using System; -using System.Collections.Generic; -using System.Text; using MoonSharp.Interpreter; using Microsoft.Xna.Framework; using FarseerPhysics.Dynamics; +using LuaCsCompatPatchFunc = Barotrauma.LuaCsPatch; namespace Barotrauma { + public delegate DynValue CallLuaFunctionFunc(object function, params object[] args); + + internal static class LuaCustomConverters + { + private static CallLuaFunctionFunc CallLuaFunction; + + public static void Initialize(CallLuaFunctionFunc callLuaFunction) + { + CallLuaFunction = callLuaFunction; - public static class LuaCustomConverters - { - public static void RegisterAll() - { RegisterAction(); RegisterAction(); RegisterAction(); RegisterAction(); - RegisterFunc(); RegisterFunc(); - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(LuaCsAction), v => (LuaCsAction)( args => GameMain.LuaCs.CallLuaFunction(v.Function, args) )); - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(LuaCsFunc), v => (LuaCsFunc)( args => new LuaResult(GameMain.LuaCs.CallLuaFunction(v.Function, args)) )); - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(LuaCsPatch), v => (LuaCsPatch)( (self, args) => new LuaResult(GameMain.LuaCs.CallLuaFunction(v.Function, self, args)) )); - Script.GlobalOptions.CustomConverters.SetClrToScriptCustomConversion(typeof(LuaResult), (Script s, object v) => (v as LuaResult).DynValue()); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + DataType.Function, + typeof(LuaCsAction), + v => (LuaCsAction)(args => CallLuaFunction(v.Function, args))); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + DataType.Function, + typeof(LuaCsFunc), + v => (LuaCsFunc)(args => CallLuaFunction(v.Function, args))); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + DataType.Function, + typeof(LuaCsCompatPatchFunc), + v => (LuaCsCompatPatchFunc)((self, args) => CallLuaFunction(v.Function, self, args))); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + DataType.Function, + typeof(LuaCsPatchFunc), + v => (LuaCsPatchFunc)((self, args) => CallLuaFunction(v.Function, self, args))); #if CLIENT RegisterAction(); RegisterAction(); { - object Call(object function, params object[] arguments) => GameMain.LuaCs.CallLuaFunction(function, arguments); + DynValue Call(object function, params object[] arguments) => CallLuaFunction(function, arguments); void RegisterHandler(Func converter) => Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(T), v => converter(v.Function)); RegisterHandler(f => (GUIComponent.SecondaryButtonDownHandler)( - (a1, a2) => new LuaResult(Call(f, a1, a2)).Bool())); + (a1, a2) => Call(f, a1, a2).CastToBool())); RegisterHandler(f => (GUIButton.OnClickedHandler)( - (a1, a2) => new LuaResult(Call(f, a1, a2)).Bool())); + (a1, a2) => Call(f, a1, a2).CastToBool())); RegisterHandler(f => (GUIButton.OnButtonDownHandler)( - () => new LuaResult(Call(f)).Bool())); + () => Call(f).CastToBool())); RegisterHandler(f => (GUIButton.OnPressedHandler)( - () => new LuaResult(Call(f)).Bool())); + () => Call(f).CastToBool())); RegisterHandler(f => (GUIColorPicker.OnColorSelectedHandler)( - (a1, a2) => new LuaResult(Call(f, a1, a2)).Bool())); + (a1, a2) => Call(f, a1, a2).CastToBool())); RegisterHandler(f => (GUIDropDown.OnSelectedHandler)( - (a1, a2) => new LuaResult(Call(f, a1, a2)).Bool())); + (a1, a2) => Call(f, a1, a2).CastToBool())); RegisterHandler(f => (GUIListBox.OnSelectedHandler)( - (a1, a2) => new LuaResult(Call(f, a1, a2)).Bool())); + (a1, a2) => Call(f, a1, a2).CastToBool())); RegisterHandler(f => (GUIListBox.OnRearrangedHandler)( - (a1, a2) => Call(f, a1, a2))); + (a1, a2) => Call(f, a1, a2))); RegisterHandler(f => (GUIListBox.CheckSelectedHandler)( - () => new LuaResult(Call(f)).Object())); + () => Call(f).ToObject())); RegisterHandler(f => (GUINumberInput.OnValueEnteredHandler)( (a1) => Call(f, a1))); RegisterHandler(f => (GUINumberInput.OnValueChangedHandler)( - (a1) => Call(f, a1))); + (a1) => Call(f, a1))); RegisterHandler(f => (GUIProgressBar.ProgressGetterHandler)( - () => new LuaResult(Call(f)).Float())); + () => (float)(Call(f).CastToNumber() ?? 0))); RegisterHandler(f => (GUIRadioButtonGroup.RadioButtonGroupDelegate)( - (a1, a2) => Call(f, a1, a2))); + (a1, a2) => Call(f, a1, a2))); RegisterHandler(f => (GUIScrollBar.OnMovedHandler)( - (a1, a2) => new LuaResult(Call(f, a1, a2)).Bool())); + (a1, a2) => Call(f, a1, a2).CastToBool())); RegisterHandler(f => (GUIScrollBar.ScrollConversion)( - (a1, a2) => new LuaResult(Call(f, a1, a2)).Float())); + (a1, a2) => (float)(Call(f, a1, a2).CastToNumber() ?? 0))); RegisterHandler(f => (GUITextBlock.TextGetterHandler)( - () => new LuaResult(Call(f, new object[] { })).String())); + () => Call(f, new object[0]).CastToString())); RegisterHandler(f => (GUITextBox.OnEnterHandler)( - (a1, a2) => new LuaResult(Call(f, a1, a2)).Bool())); + (a1, a2) => Call(f, a1, a2).CastToBool())); RegisterHandler(f => (GUITextBox.OnTextChangedHandler)( - (a1, a2) => new LuaResult(Call(f, a1, a2)).Bool())); + (a1, a2) => Call(f, a1, a2).CastToBool())); RegisterHandler(f => (TextBoxEvent)( - (a1, a2) => Call(f, a1, a2))); + (a1, a2) => Call(f, a1, a2))); RegisterHandler(f => (GUITickBox.OnSelectedHandler)( - (a1) => new LuaResult(Call(f, a1)).Bool())); + (a1) => Call(f, a1).CastToBool())); } #endif - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Table, typeof(Pair), v => { return new Pair((JobPrefab)v.Table.Get(1).ToObject(), (int)v.Table.Get(2).CastToNumber()); }); - Script.GlobalOptions.CustomConverters.SetClrToScriptCustomConversion((Script script, UInt64 v) => + Script.GlobalOptions.CustomConverters.SetClrToScriptCustomConversion((Script script, ulong v) => { return DynValue.NewString(v.ToString()); }); - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.String, typeof(UInt64), v => + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.String, typeof(ulong), v => { - return UInt64.Parse(v.String); + return ulong.Parse(v.String); }); - Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.UserData, typeof(object), v => - { - if (v.UserData.Object is LuaByte lbyte) - { - return lbyte.Value; - } - else if (v.UserData.Object is LuaUShort lushort) - { - return lushort.Value; - } - else if (v.UserData.Object is LuaFloat lfloat) - { - return lfloat.Value; - } - return v.UserData.Object; - }); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + scriptDataType: DataType.UserData, + clrDataType: typeof(sbyte), + canConvert: luaValue => luaValue.UserData?.Object is LuaSByte, + converter: luaValue => luaValue.UserData.Object is LuaSByte v + ? (sbyte)v + : throw new ScriptRuntimeException("use SByte(value) to pass primitive type 'sbyte' to C#")); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + scriptDataType: DataType.UserData, + clrDataType: typeof(byte), + canConvert: luaValue => luaValue.UserData?.Object is LuaByte, + converter: luaValue => luaValue.UserData.Object is LuaByte v + ? (byte)v + : throw new ScriptRuntimeException("use Byte(value) to pass primitive type 'byte' to C#")); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + scriptDataType: DataType.UserData, + clrDataType: typeof(short), + canConvert: luaValue => luaValue.UserData?.Object is LuaInt16, + converter: luaValue => luaValue.UserData.Object is LuaInt16 v + ? (short)v + : throw new ScriptRuntimeException("use Int16(value) to pass primitive type 'short' to C#")); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + scriptDataType: DataType.UserData, + clrDataType: typeof(ushort), + canConvert: luaValue => luaValue.UserData?.Object is LuaUInt16, + converter: luaValue => luaValue.UserData.Object is LuaUInt16 v + ? (ushort)v + : throw new ScriptRuntimeException("use UInt16(value) to pass primitive type 'ushort' to C#")); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + scriptDataType: DataType.UserData, + clrDataType: typeof(int), + canConvert: luaValue => luaValue.UserData?.Object is LuaInt32, + converter: luaValue => luaValue.UserData.Object is LuaInt32 v + ? (int)v + : throw new ScriptRuntimeException("use Int32(value) to pass primitive type 'int' to C#")); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + scriptDataType: DataType.UserData, + clrDataType: typeof(uint), + canConvert: luaValue => luaValue.UserData?.Object is LuaUInt32, + converter: luaValue => luaValue.UserData.Object is LuaUInt32 v + ? (uint)v + : throw new ScriptRuntimeException("use UInt32(value) to pass primitive type 'uint' to C#")); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + scriptDataType: DataType.UserData, + clrDataType: typeof(long), + canConvert: luaValue => luaValue.UserData?.Object is LuaInt64, + converter: luaValue => luaValue.UserData.Object is LuaInt64 v + ? (long)v + : throw new ScriptRuntimeException("use Int64(value) to pass primitive type 'long' to C#")); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + scriptDataType: DataType.UserData, + clrDataType: typeof(ulong), + canConvert: luaValue => luaValue.UserData?.Object is LuaUInt64, + converter: luaValue => luaValue.UserData.Object is LuaUInt64 v + ? (ulong)v + : throw new ScriptRuntimeException("use UInt64(value) to pass primitive type 'ulong' to C#")); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + scriptDataType: DataType.UserData, + clrDataType: typeof(float), + canConvert: luaValue => luaValue.UserData?.Object is LuaSingle, + converter: luaValue => luaValue.UserData.Object is LuaSingle v + ? (float)v + : throw new ScriptRuntimeException("use Single(value) to pass primitive type 'float' to C#")); + Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion( + scriptDataType: DataType.UserData, + clrDataType: typeof(double), + canConvert: luaValue => luaValue.UserData?.Object is LuaDouble, + converter: luaValue => luaValue.UserData.Object is LuaDouble v + ? (double)v + : throw new ScriptRuntimeException("use Double(value) to pass primitive type 'double' to C#")); } public static void RegisterAction() @@ -129,13 +197,13 @@ namespace Barotrauma Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action), v => { var function = v.Function; - return (Action)(p => GameMain.LuaCs.CallLuaFunction(function, p)); + return (Action)(p => CallLuaFunction(function, p)); }); Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.ClrFunction, typeof(Action), v => { var function = v.Function; - return (Action)(p => GameMain.LuaCs.CallLuaFunction(function, p)); + return (Action)(p => CallLuaFunction(function, p)); }); } @@ -144,13 +212,13 @@ namespace Barotrauma Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action), v => { var function = v.Function; - return (Action)((a1, a2) => GameMain.LuaCs.CallLuaFunction(function, a1, a2)); + return (Action)((a1, a2) => CallLuaFunction(function, a1, a2)); }); Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.ClrFunction, typeof(Action), v => { var function = v.Function; - return (Action)((a1, a2) => GameMain.LuaCs.CallLuaFunction(function, a1, a2)); + return (Action)((a1, a2) => CallLuaFunction(function, a1, a2)); }); } @@ -159,13 +227,13 @@ namespace Barotrauma Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(Action), v => { var function = v.Function; - return (Action)(() => GameMain.LuaCs.CallLuaFunction(function)); + return (Action)(() => CallLuaFunction(function)); }); Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.ClrFunction, typeof(Action), v => { var function = v.Function; - return (Action)(() => GameMain.LuaCs.CallLuaFunction(function)); + return (Action)(() => CallLuaFunction(function)); }); } @@ -213,7 +281,5 @@ namespace Barotrauma return (Func)((T1 a, T2 b, T3 c, T4 d) => function.Call(a, b, c, d).ToObject()); }); } - } - } diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaDocs.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaDocs.cs index 8079c42cc..955db080a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaDocs.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaDocs.cs @@ -1,263 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; -using MoonSharp.Interpreter; -using Microsoft.Xna.Framework; -using Barotrauma.Networking; -using System.Threading.Tasks; -using Barotrauma.Items.Components; -using System.IO; -using System.Net; -using System.Linq; -using System.Xml.Linq; -using System.Reflection; +using System.Runtime.CompilerServices; -namespace Barotrauma -{ - - public static class LuaDocs - { - - public static string ConvertTypeName(string type) - { - switch (type) - { - case "Boolean": - return "bool"; - case "String": - return "string"; - case "int": - return "number"; - case "Single": - return "number"; - case "Double": - return "number"; - case "float": - return "number"; - case "UInt16": - return "number"; - case "UInt32": - return "number"; - case "UInt64": - return "number"; - case "Int32": - return "number"; - case "List`1": - return "table"; - case "Dictionary`2": - return "table"; - } - - if (type.StartsWith("Action")) - return "function"; - - if (type.StartsWith("Func")) - return "function"; - - if (type.StartsWith("IEnumerable")) - return "Enumerable"; - - return type; - } - - public static string EscapeName(string n) - { - if (n == "end") - return "endparam"; - - return n; - } - - public static void GenerateDocsAll() - { - GenerateDocs(typeof(Character), "Character.lua"); - GenerateDocs(typeof(CharacterInfo), "CharacterInfo.lua"); - GenerateDocs(typeof(CharacterHealth), "CharacterHealth.lua"); - GenerateDocs(typeof(AnimController), "AnimController.lua"); - GenerateDocs(typeof(Client), "Client.lua"); - GenerateDocs(typeof(Entity), "Entity.lua"); - GenerateDocs(typeof(EntitySpawner), "Entity.Spawner.lua", "Entity.Spawner"); - GenerateDocs(typeof(Item), "Item.lua"); - GenerateDocs(typeof(ItemPrefab), "ItemPrefab.lua"); - GenerateDocs(typeof(Submarine), "Submarine.lua"); - GenerateDocs(typeof(SubmarineInfo), "SubmarineInfo.lua"); - GenerateDocs(typeof(Job), "Job.lua"); - GenerateDocs(typeof(JobPrefab), "JobPrefab.lua"); - GenerateDocs(typeof(GameSession), "GameSession.lua", "Game.GameSession"); - GenerateDocs(typeof(NetLobbyScreen), "NetLobbyScreen.lua", "Game.NetLobbyScreen"); - GenerateDocs(typeof(GameScreen), "GameScreen.lua", "Game.GameScreen"); - GenerateDocs(typeof(FarseerPhysics.Dynamics.World), "World.lua", "Game.World"); - GenerateDocs(typeof(Inventory), "Inventory.lua", "Inventory"); - GenerateDocs(typeof(ItemInventory), "ItemInventory.lua", "ItemInventory"); - GenerateDocs(typeof(CharacterInventory), "CharacterInventory.lua", "CharacterInventory"); - GenerateDocs(typeof(Hull), "Hull.lua", "Hull"); - GenerateDocs(typeof(Level), "Level.lua", "Level"); - GenerateDocs(typeof(Affliction), "Affliction.lua", "Affliction"); - GenerateDocs(typeof(AfflictionPrefab), "AfflictionPrefab.lua", "AfflictionPrefab"); - GenerateDocs(typeof(WayPoint), "WayPoint.lua", "WayPoint"); - GenerateDocs(typeof(ServerSettings), "ServerSettings.lua", "Game.ServerSettings"); - GenerateDocs(typeof(GameSettings), "GameSettings.lua", "Game.Settings"); - } - - public static void GenerateDocs(Type type, string name, string categoryName = null) - { - GenerateDocs(type, "../../../../docs/baseluadocs/" + name, "../../../../docs/lua/generated/" + name, categoryName); - } - - public static void GenerateDocs(Type type, string baselua, string fileresult, string categoryName = null) - { - var sb = new StringBuilder(); - - if (categoryName == null) - categoryName = type.Name; - - var baseluatext = ""; - - if (!File.Exists(baselua)) - { - const string EMPTY_TABLE = "{}"; - - baseluatext = @$"-- luacheck: ignore 111 - ---[[-- -{type.FullName} -]] --- @code {categoryName} --- @pragma nostrip -local {type.Name} = {EMPTY_TABLE}"; - - File.WriteAllText(baselua, baseluatext); - } - else - baseluatext = File.ReadAllText(baselua); - - HashSet removed = new HashSet(); - - foreach(var line in baseluatext.Split('\n')) - { - if(line.Contains("-- @remove ")) - { - var replaced = line.Replace("-- @remove ", "").Replace("\r", ""); - removed.Add(replaced); - } - } - - sb.Append(baseluatext + "\n\n"); - - var members = type.GetMembers(); - - foreach(var member in members) - { - Console.WriteLine("'{0}' is a {1}", member.Name, member.MemberType); - - if (member.MemberType == MemberTypes.Method) - { - var method = (MethodInfo)member; - - if (method.Name.StartsWith("get_") || method.Name.StartsWith("set_")) - continue; - - var lsb = new StringBuilder(); - - lsb.Append($"--- {method.Name}\n"); - lsb.Append($"-- @realm shared\n"); - - var paramNames = ""; - - var parameters = method.GetParameters(); - for(var i=0; i < parameters.Length; i++) - { - var parameter = parameters[i]; - - if(i == parameters.Length - 1) - paramNames = paramNames + EscapeName(parameter.Name); - else - paramNames = paramNames + EscapeName(parameter.Name) + ", "; - - lsb.Append($"-- @tparam {ConvertTypeName(parameter.ParameterType.Name)} {EscapeName(parameter.Name)}\n"); - } - - if (method.ReturnType != typeof(void)) - { - lsb.Append($"-- @treturn {ConvertTypeName(method.ReturnType.Name)}\n"); - } - - string functionDecoration; - - if (method.IsStatic) - functionDecoration = $"function {type.Name}.{method.Name}({paramNames}) end"; - else - functionDecoration = $"function {method.Name}({paramNames}) end"; - - if (removed.Contains(functionDecoration)) - { - continue; - } - - lsb.Append(functionDecoration); - - lsb.Append("\n\n"); - sb.Append(lsb); - } - - if (member.MemberType == MemberTypes.Field) - { - var lsb = new StringBuilder(); - - var field = (FieldInfo)member; - - lsb.Append($"---\n"); - lsb.Append($"-- "); - - var name = EscapeName(field.Name); - - var returnName = ConvertTypeName(field.FieldType.Name); - - if (field.IsStatic) - name = type.Name + "." + field.Name; - - if (removed.Contains(name)) - continue; - - lsb.Append(name); - lsb.Append($", Field of type {returnName}\n"); - lsb.Append($"-- @realm shared\n"); - lsb.Append($"-- @{returnName} {name}\n"); - - lsb.Append("\n"); - sb.Append(lsb); - } - - if (member.MemberType == MemberTypes.Property) - { - var lsb = new StringBuilder(); - - var property = (PropertyInfo)member; - - lsb.Append($"---\n"); - lsb.Append($"-- "); - - var name = EscapeName(property.Name); - - var returnName = ConvertTypeName(property.PropertyType.Name); - - if (property.GetGetMethod().IsStatic) - name = type.Name + "." + property.Name; - - if (removed.Contains(name)) - continue; - - lsb.Append(name); - lsb.Append($", Field of type {returnName}\n"); - lsb.Append($"-- @realm shared\n"); - lsb.Append($"-- @{returnName} {name}\n"); - - lsb.Append("\n"); - sb.Append(lsb); - } - } - - File.WriteAllText(fileresult, sb.ToString()); - } - } -} \ No newline at end of file +[assembly: InternalsVisibleTo("LuaDocsGenerator")] diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHook.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHook.cs index 0516f6344..2101af8b8 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHook.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHook.cs @@ -1,494 +1,1251 @@ -using System; -using System.Linq; -using System.Reflection; -using MoonSharp.Interpreter; -using HarmonyLib; +using System; +using System.Collections; using System.Collections.Generic; -using System.Text; -using MoonSharp.Interpreter.Interop; -using static Barotrauma.LuaCsSetup; -using System.Threading; using System.Diagnostics; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using System.Reflection.Emit; +using System.Text; +using System.Text.RegularExpressions; +using HarmonyLib; +using Microsoft.Xna.Framework; +using MoonSharp.Interpreter; +using MoonSharp.Interpreter.Interop; +using Sigil; +using Sigil.NonGeneric; namespace Barotrauma { - public delegate void LuaCsAction(params object[] args); - public delegate object LuaCsFunc(params object[] args); - public delegate object LuaCsPatch(object self, Dictionary args); + public delegate void LuaCsAction(params object[] args); + public delegate DynValue LuaCsFunc(params object[] args); + public delegate DynValue LuaCsPatchFunc(object instance, LuaCsHook.ParameterTable ptable); - public partial class LuaCsHook - { - public enum HookMethodType - { - Before, After - } - - private class LuaHookFunction - { - public string name; - public string hookName; - public object function; - - public LuaHookFunction(string n, string hn, object func) - { - name = n; - hookName = hn; - function = func; - } - } - private class LuaCsHookCallback - { - public string name; - public string hookName; - public LuaCsFunc func; - - public LuaCsHookCallback(string name, string hookName, LuaCsFunc func) - { - this.name = name; - this.hookName = hookName; - this.func = func; - } - } - - private const BindingFlags DefaultBindingFlags = BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; - private static readonly string[] prohibitedHooks = { - "Barotrauma.Lua", - "Barotrauma.Cs", - "ContentPackageManager", - }; - - private Harmony harmony; - - private Dictionary> hookFunctions; - private Dictionary> hookPrefixMethods; - private Dictionary> hookPostfixMethods; - - private static LuaCsHook instance; - - public LuaCsHook() { - instance = this; - - hookFunctions = new Dictionary>(); - - hookPrefixMethods = new Dictionary>(); - hookPostfixMethods = new Dictionary>(); - - compatHookPrefixMethods = new Dictionary>(); - compatHookPostfixMethods = new Dictionary>(); - } - - public void Initialize() + internal static class SigilExtensions + { + /// + /// Puts a type on the stack, as a object instead of a + /// runtime type token. + /// + /// The IL emitter. + /// The type to put on the stack. + public static void LoadType(this Emit il, Type type) { - harmony = new Harmony("LuaCsForBarotrauma"); + if (type == null) throw new ArgumentNullException(nameof(type)); + il.LoadConstant(type); // ldtoken + // This converts the type token into a Type object + il.Call(typeof(Type).GetMethod( + name: nameof(Type.GetTypeFromHandle), + bindingAttr: BindingFlags.Public | BindingFlags.Static, + binder: null, + types: new Type[] { typeof(RuntimeTypeHandle) }, + modifiers: null)); + } - var hookType = UserData.RegisterType(); - var hookDesc = (StandardUserDataDescriptor)hookType; - typeof(LuaCsHook).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).ToList().ForEach(m => { - if ( - m.Name.Contains("HookMethod") || - m.Name.Contains("UnhookMethod") || - m.Name.Contains("EnqueueFunction") || - m.Name.Contains("EnqueueTimedFunction") - ) - { - hookDesc.AddMember(m.Name, new MethodMemberDescriptor(m, InteropAccessMode.Default)); - } - }); - } - - public void Add(string name, string hookName, LuaCsFunc hook, ACsMod owner = null) - { - if (name == null || hookName == null || hook == null) - { - throw new ScriptRuntimeException("Hook.Add: name, hookName and hook must not be null."); - } - - name = name.ToLower(); - - if (!hookFunctions.ContainsKey(name)) - { - hookFunctions.Add(name, new Dictionary()); - } - - hookFunctions[name][hookName] = (new LuaCsHookCallback(name, hookName, hook), owner); - } - - public void Remove(string name, string hookName) - { - if (name == null || hookName == null) { return; } - - name = name.ToLower(); - - if (hookFunctions.ContainsKey(name) && hookFunctions[name].ContainsKey(hookName)) - { - hookFunctions[name].Remove(hookName); - } - } - - public void Clear() + /// + /// Converts the value on the stack to . + /// + /// The IL emitter. + /// The type of the value on the stack. + public static void ToObject(this Emit il, Type type) { - hookFunctions.Clear(); + if (type == null) throw new ArgumentNullException(nameof(type)); + il.DerefIfByRef(ref type); + if (type.IsValueType) + { + il.Box(type); + } + else if (type != typeof(object)) + { + il.CastClass(); + } + } - hookPrefixMethods.Clear(); - hookPostfixMethods.Clear(); + /// + /// Deferences the value on stack if the provided type is ByRef. + /// + /// The IL emitter. + /// The type to check if ByRef. + public static void DerefIfByRef(this Emit il, Type type) => il.DerefIfByRef(ref type); - compatHookPrefixMethods.Clear(); - compatHookPostfixMethods.Clear(); + /// + /// Deferences the value on stack if the provided type is ByRef. + /// + /// The IL emitter. + /// The type to check if ByRef. + public static void DerefIfByRef(this Emit il, ref Type type) + { + if (type == null) throw new ArgumentNullException(nameof(type)); + if (type.IsByRef) + { + type = type.GetElementType(); + if (type.IsValueType) + { + il.LoadObject(type); + } + else + { + il.LoadIndirect(type); + } + } + } - harmony?.UnpatchAll(); - } + // Copied from https://github.com/evilfactory/moonsharp/blob/5264656c6442e783f3c75082cce69a93d66d4cc0/src/MoonSharp.Interpreter/Interop/Converters/ScriptToClrConversions.cs#L79-L99 + private static MethodInfo HasImplicitConversion(Type baseType, Type targetType) + { + try + { + return Expression.Convert(Expression.Parameter(baseType, null), targetType).Method; + } + catch + { + if (baseType.BaseType != null) + { + return HasImplicitConversion(baseType.BaseType, targetType); + } + if (targetType.BaseType != null) + { + return HasImplicitConversion(baseType, targetType.BaseType); + } - public void Update() - { + return null; + } + } - } + /// + /// Loads a local variable and casts it to the target type. + /// + /// The IL emitter. + /// The value to cast. Must be of type . + /// The type to cast into. + public static void LoadLocalAndCast(this Emit il, Local value, Type targetType) + { + if (value == null) throw new ArgumentNullException(nameof(value)); + if (targetType == null) throw new ArgumentNullException(nameof(targetType)); + if (value.LocalType != typeof(object)) + { + throw new ArgumentException($"Expected local type {typeof(object)}; got {value.LocalType}.", nameof(value)); + } - private Stopwatch performanceMeasurement = new Stopwatch(); + var guid = Guid.NewGuid().ToString("N"); - [MoonSharpHidden] - public T Call(string name, params object[] args) - { - if (GameMain.LuaCs == null) { return default(T); } - if (name == null) { throw new ScriptRuntimeException("Hook.Call: name must not be null."); } - if (args == null) { args = new object[] { }; } + if (targetType.IsByRef) + { + targetType = targetType.GetElementType(); + } - name = name.ToLower(); + // IL: var baseType = value.GetType(); + var baseType = il.DeclareLocal(typeof(Type), $"cast_baseType_{guid}"); + il.LoadLocal(value); + il.Call(typeof(object).GetMethod("GetType")); + il.StoreLocal(baseType); - if (!hookFunctions.ContainsKey(name)) - { - return default(T); - } + // IL: var implicitConversionMethod = SigilExtensions.HasImplicitConversion(baseType, ); + var implicitConversionMethod = il.DeclareLocal(typeof(MethodInfo), $"cast_implicitConversionMethod_{guid}"); + il.LoadLocal(baseType); + il.LoadType(targetType); + il.Call(typeof(SigilExtensions).GetMethod(nameof(HasImplicitConversion), BindingFlags.NonPublic | BindingFlags.Static)); + il.StoreLocal(implicitConversionMethod); - T lastResult = default(T); + // IL: castValue; + var castValue = il.DeclareLocal(targetType, $"cast_castValue_{guid}"); - if (!hookFunctions.ContainsKey(name)) - { - return lastResult; - } + // IL: if (implicitConversionMethod != null) + il.LoadLocal(implicitConversionMethod); + il.Branch((il) => + { + // IL: var methodInvokeParams = new object[1]; + var methodInvokeParams = il.DeclareLocal(typeof(object[]), $"cast_methodInvokeParams_{guid}"); + il.LoadConstant(1); + il.NewArray(typeof(object)); + il.StoreLocal(methodInvokeParams); - var hooksToRemove = new List(); - foreach ((var key, var tuple) in hookFunctions[name]) - { - if (tuple.Item2 != null && tuple.Item2.IsDisposed) - { - hooksToRemove.Add(key); - continue; - } + // IL: methodInvokeParams[0] = value; + il.LoadLocal(methodInvokeParams); + il.LoadConstant(0); + il.LoadLocal(value); + il.StoreElement(); - try - { - if (GameMain.LuaCs.PerformanceCounter.EnablePerformanceCounter) - { - performanceMeasurement.Start(); - } + // IL: castValue = ()implicitConversionMethod.Invoke(null, methodInvokeParams); + il.LoadLocal(implicitConversionMethod); + il.LoadNull(); // first parameter is null because implicit cast operators are static + il.LoadLocal(methodInvokeParams); + il.Call(typeof(MethodInfo).GetMethod("Invoke", new[] { typeof(object), typeof(object[]) })); + if (targetType.IsValueType) + { + il.UnboxAny(targetType); + } + else + { + il.CastClass(targetType); + } + il.StoreLocal(castValue); + }, + (il) => + { + // IL: castValue = ()value; + il.LoadLocal(value); + if (targetType.IsValueType) + { + il.UnboxAny(targetType); + } + else + { + il.CastClass(targetType); + } + il.StoreLocal(castValue); + }); - var result = tuple.Item1.func(args); - if (result != null) - { - if (typeof(object) != typeof(T)) - { - if (result is LuaResult lRes) - { - if (!lRes.IsNull()) { lastResult = lRes.DynValue().ToObject(); } - } - else if (result is T cRes && cRes != null) - { - lastResult = cRes; - } - } - else - { - if (result is LuaResult lRes) - { - if (!lRes.IsNull()) { lastResult = (T)(object)lRes.DynValue(); } - } - else - { - lastResult = (T)result; - } - } - } + il.LoadLocal(castValue); + } - if (GameMain.LuaCs.PerformanceCounter.EnablePerformanceCounter) - { - performanceMeasurement.Stop(); - GameMain.LuaCs.PerformanceCounter.SetHookElapsedTicks(name, key, performanceMeasurement.ElapsedTicks); - performanceMeasurement.Reset(); - } - } - catch (Exception e) - { - StringBuilder argsSb = new StringBuilder(); - foreach (var arg in args) argsSb.Append(arg + " "); - GameMain.LuaCs.HandleException(e, $"Error in Hook '{name}'->'{key}', with args '{argsSb}':\n{e}", ExceptionType.Both); - } - } - foreach (var key in hooksToRemove) - { - hookFunctions[name].Remove(key); - } + /// + /// Emits a call to . + /// + /// The IL emitter. + /// The string format. + /// The local variables passed to string.Format. + public static void FormatString(this Emit il, string format, params Local[] args) + { + if (format == null) throw new ArgumentNullException(nameof(format)); + if (args == null) throw new ArgumentNullException(nameof(args)); - return lastResult; - } - public object Call(string name, params object[] args) => Call(name, args); + var guid = Guid.NewGuid().ToString("N"); + var listType = typeof(List<>).MakeGenericType(typeof(object)); + var list = il.DeclareLocal(listType, $"formatString_list_{guid}"); + il.NewObject(listType); + il.StoreLocal(list); - private static bool PatchPrefix(MethodBase __originalMethod, object[] __args, object __instance) - { - ExecutePatch(__originalMethod, __args, __instance, out object result, HookMethodType.Before); - return result == null; - } - private static void PatchPostfix(MethodBase __originalMethod, object[] __args, object __instance) => - ExecutePatch(__originalMethod, __args, __instance, out object _, HookMethodType.After); + foreach (var arg in args) + { + il.LoadLocal(list); + il.LoadLocal(arg); + il.ToObject(arg.LocalType); + il.CallVirtual(listType.GetMethod("Add", new[] { typeof(object) })); + } - private static bool PatchPrefixWithReturn(MethodBase __originalMethod, object[] __args, ref object __result, object __instance) - { - ExecutePatch(__originalMethod, __args, __instance, out object result, HookMethodType.Before); - if (result != null) - { - __result = result; - return false; - } - else { return true; } - } - private static void PatchPostfixWithReturn(MethodBase __originalMethod, object[] __args, ref object __result, object __instance) - { - ExecutePatch(__originalMethod, __args, __instance, out object result, HookMethodType.After); - if (result != null) { __result = result; } - } + var arr = il.DeclareLocal($"formatString_arr_{guid}"); + il.LoadLocal(list); + il.CallVirtual(listType.GetMethod("ToArray", new Type[0])); + il.StoreLocal(arr); + il.LoadConstant(format); + il.LoadLocal(arr); + il.Call(typeof(string).GetMethod("Format", new[] { typeof(string), typeof(object[]) })); + } - private static readonly MethodInfo miPatchPrefix = typeof(LuaCsHook).GetMethod("PatchPrefix", BindingFlags.NonPublic | BindingFlags.Static); - private static readonly MethodInfo miPatchPostfix = typeof(LuaCsHook).GetMethod("PatchPostfix", BindingFlags.NonPublic | BindingFlags.Static); - private static readonly MethodInfo miPatchPrefixWithReturn = typeof(LuaCsHook).GetMethod("PatchPrefixWithReturn", BindingFlags.NonPublic | BindingFlags.Static); - private static readonly MethodInfo miPatchPostfixWithReturn = typeof(LuaCsHook).GetMethod("PatchPostfixWithReturn", BindingFlags.NonPublic | BindingFlags.Static); + /// + /// Emits a call to . + /// + /// The IL emitter. + /// The message to print. + public static void NewMessage(this Emit il, string message) + { + var newMessage = typeof(DebugConsole).GetMethod( + name: nameof(DebugConsole.NewMessage), + bindingAttr: BindingFlags.Public | BindingFlags.Static, + binder: null, + types: new Type[] { typeof(string), typeof(Color?), typeof(bool) }, + modifiers: null); + il.LoadConstant(message); + il.Call(typeof(Color).GetProperty(nameof(Color.LightBlue), BindingFlags.Public | BindingFlags.Static).GetGetMethod()); + il.LoadConstant(false); + il.Call(newMessage); + } - private static MethodInfo ResolveMethod(string className, string methodName, string[] parameterNames) - { - var classType = LuaUserData.GetType(className); + /// + /// Emits a call to , + /// using the string on the stack. + /// + /// The IL emitter. + public static void NewMessage(this Emit il) + { + var newMessage = typeof(DebugConsole).GetMethod( + name: nameof(DebugConsole.NewMessage), + bindingAttr: BindingFlags.Public | BindingFlags.Static, + binder: null, + types: new Type[] { typeof(string), typeof(Color?), typeof(bool) }, + modifiers: null); + il.Call(typeof(Color).GetProperty(nameof(Color.LightBlue), BindingFlags.Public | BindingFlags.Static).GetGetMethod()); + il.LoadConstant(false); + il.Call(newMessage); + } - if (classType == null) - { - throw new ArgumentNullException($"Invalid class name '{className}'."); - } + /// + /// Emits a foreach loop that iterates over an local variable. + /// + /// The type of elements in the enumerable. + /// The IL emitter. + /// The enumerable. + /// The body of code to run on each iteration. + public static void ForEachEnumerable(this Emit il, Local enumerable, Action action) + { + if (enumerable == null) throw new ArgumentNullException(nameof(enumerable)); + if (action == null) throw new ArgumentNullException(nameof(action)); + if (!typeof(IEnumerable).IsAssignableFrom(enumerable.LocalType)) + { + throw new ArgumentException($"Expected local type {typeof(IEnumerator)}; got {enumerable.LocalType}.", nameof(enumerable)); + } - MethodInfo methodInfo = null; + var guid = Guid.NewGuid().ToString("N"); - if (parameterNames != null) - { - Type[] parameterTypes = parameterNames.Select(x => LuaUserData.GetType(x)).ToArray(); - methodInfo = classType.GetMethod(methodName, DefaultBindingFlags, null, parameterTypes, null); - } - else - { - methodInfo = classType.GetMethod(methodName, DefaultBindingFlags); - } + var enumerator = il.DeclareLocal>($"forEachEnumerable_enumerator_{guid}"); + il.LoadLocal(enumerable); + il.CallVirtual(typeof(IEnumerable).GetMethod("GetEnumerator")); + il.StoreLocal(enumerator); + ForEachEnumerator(il, enumerator, action); + } - if (methodInfo == null) - { - string parameterNamesStr = parameterNames == null ? "" : string.Join(", ", parameterNames); - throw new ArgumentNullException($"Method '{methodName}' with parameters '{parameterNamesStr}' not found in class '{className}'"); - } + /// + /// Emits a foreach loop that iterates over an local variable. + /// + /// The type of elements in the enumerable. + /// The IL emitter. + /// The enumerator. + /// The body of code to run on each iteration. + public static void ForEachEnumerator(this Emit il, Local enumerator, Action action) + { + if (enumerator == null) throw new ArgumentNullException(nameof(enumerator)); + if (action == null) throw new ArgumentNullException(nameof(action)); + if (!typeof(IEnumerator).IsAssignableFrom(enumerator.LocalType)) + { + throw new ArgumentException($"Expected local type {typeof(IEnumerator)}; got {enumerator.LocalType}.", nameof(enumerator)); + } - return methodInfo; - } + var guid = Guid.NewGuid().ToString("N"); + var labelLoopStart = il.DefineLabel($"forEach_loopStart_{guid}"); + var labelMoveNext = il.DefineLabel($"forEach_moveNext_{guid}"); + var labelLeave = il.DefineLabel($"forEach_leave_{guid}"); - public void Patch(string identifier, MethodInfo method, LuaCsFunc patch, HookMethodType hookType = HookMethodType.Before, ACsMod owner = null) - { - if (identifier == null || method == null || patch == null) - { - throw new ArgumentNullException("Identifier, Method and Patch arguments must not be null."); - } - if (prohibitedHooks.Any(h => method.DeclaringType.FullName.StartsWith(h))) - { - throw new ArgumentException("Hooks into Modding Environment are prohibited."); - } + il.BeginExceptionBlock(out var exceptionBlock); + il.Branch(labelMoveNext); // MoveNext() needs to be called at least once before iterating + il.MarkLabel(labelLoopStart); - var funcAddr = (long)method.MethodHandle.GetFunctionPointer(); - var patches = Harmony.GetPatchInfo(method); + // IL: var current = enumerator.Current; + var current = il.DeclareLocal($"forEachEnumerator_current_{guid}"); + il.LoadLocal(enumerator); + il.CallVirtual(enumerator.LocalType.GetProperty("Current").GetGetMethod()); + il.StoreLocal(current); - if (hookType == HookMethodType.Before) - { - if (method.ReturnType != typeof(void)) - { - if (patches == null || patches.Prefixes == null || patches.Prefixes.Find(patch => patch.PatchMethod == miPatchPrefixWithReturn) == null) - { - harmony.Patch(method, prefix: new HarmonyMethod(miPatchPrefixWithReturn)); - } - } - else - { - if (patches == null || patches.Prefixes == null || patches.Prefixes.Find(patch => patch.PatchMethod == miPatchPrefix) == null) - { - harmony.Patch(method, prefix: new HarmonyMethod(miPatchPrefix)); - } - } + action(il, current, labelLeave); - if (hookPrefixMethods.TryGetValue(funcAddr, out HashSet<(string, LuaCsFunc, ACsMod)> methodSet)) - { - if (identifier != "") - { - methodSet.RemoveWhere(tuple => tuple.Item1 == identifier); - } + il.MarkLabel(labelMoveNext); + il.LoadLocal(enumerator); + il.CallVirtual(typeof(IEnumerator).GetMethod("MoveNext")); + il.BranchIfTrue(labelLoopStart); // loop if MoveNext() returns true - methodSet.Add((identifier, patch, owner)); - } - else if (patch != null) - { - hookPrefixMethods.Add(funcAddr, new HashSet<(string, LuaCsFunc, ACsMod)>() { (identifier, patch, owner) }); - } + // IL: finally { enumerator.Dispose(); } + il.BeginFinallyBlock(exceptionBlock, out var finallyBlock); + il.LoadLocal(enumerator); + il.CallVirtual(typeof(IDisposable).GetMethod("Dispose")); + il.EndFinallyBlock(finallyBlock); - } - else if (hookType == HookMethodType.After) - { - if (method.ReturnType != typeof(void)) - { - if (patches == null || patches.Postfixes == null || patches.Postfixes.Find(patch => patch.PatchMethod == miPatchPostfixWithReturn) == null) - { - harmony.Patch(method, postfix: new HarmonyMethod(miPatchPostfixWithReturn)); - } - } - else - { - if (patches == null || patches.Postfixes == null || patches.Postfixes.Find(patch => patch.PatchMethod == miPatchPostfix) == null) - { - harmony.Patch(method, postfix: new HarmonyMethod(miPatchPostfix)); - } - } + il.EndExceptionBlock(exceptionBlock); - if (hookPostfixMethods.TryGetValue(funcAddr, out HashSet<(string, LuaCsFunc, ACsMod)> methodSet)) - { - if (identifier != "") - { - methodSet.RemoveWhere(tuple => tuple.Item1 == identifier); - } + il.MarkLabel(labelLeave); + } - methodSet.Add((identifier, patch, owner)); - } - else if (patch != null) - { - hookPostfixMethods.Add(funcAddr, new HashSet<(string, LuaCsFunc, ACsMod)>() { (identifier, patch, owner) }); - } + /// + /// Emits a branch that only executes if the last value on the stack + /// is truthy (e.g. non-null references, 1, etc). + /// + /// The IL emitter. + /// The body of code to run if the value is truthy. + public static void If(this Emit il, Action action) + { + if (action == null) throw new ArgumentNullException(nameof(action)); + il.Branch(@if: action); + } - } + /// + /// Emits a branch that only executes if the last value on the stack + /// is falsy (e.g. null references, 0, etc). + /// + /// The IL emitter. + /// The body of code to run if the value is falsy. + public static void IfNot(this Emit il, Action action) + { + if (action == null) throw new ArgumentNullException(nameof(action)); + il.Branch(@else: action); + } - } + /// + /// Emits two branches that diverge based on a condition -- analogous + /// to an if-else statement. If either + /// or are omitted, it behaves the same as + /// + /// and . + /// + /// The IL emitter. + /// The body of code to run if the value is truthy. + /// The body of code to run if the value is falsy. + public static void Branch(this Emit il, Action @if = null, Action @else = null) + { + if (@if == null && @else == null) throw new ArgumentException("At least one of the two branches must be defined."); - private static void ExecutePatch(MethodBase __originalMethod, object[] __args, object __instance, out object result, HookMethodType hookMethodType) - { - result = null; + var guid = Guid.NewGuid().ToString("N"); + var labelEnd = il.DefineLabel($"branch_end_{guid}"); + if (@if != null && @else != null) + { + var labelElse = il.DefineLabel($"branch_else_{guid}"); + il.BranchIfFalse(labelElse); + @if(il); + il.Branch(labelEnd); + il.MarkLabel(labelElse); + @else(il); + } + else if (@if != null) + { + il.BranchIfFalse(labelEnd); + @if(il); + } + else + { + il.BranchIfTrue(labelEnd); + @else(il); + } + il.MarkLabel(labelEnd); + } + } - try - { - long funcAddr = (long)__originalMethod.MethodHandle.GetFunctionPointer(); + public partial class LuaCsHook + { + public enum HookMethodType + { + Before, After + } - HashSet<(string, LuaCsFunc, ACsMod)> methodSet = null; - switch (hookMethodType) - { - case HookMethodType.Before: - instance.hookPrefixMethods.TryGetValue(funcAddr, out methodSet); - break; - case HookMethodType.After: - instance.hookPostfixMethods.TryGetValue(funcAddr, out methodSet); - break; - default: - break; - } + private class LuaCsHookCallback + { + public string name; + public string hookName; + public LuaCsFunc func; - if (methodSet == null) - { - return; - } + public LuaCsHookCallback(string name, string hookName, LuaCsFunc func) + { + this.name = name; + this.hookName = hookName; + this.func = func; + } + } - var patchesToRemove = new HashSet<(string, LuaCsFunc, ACsMod)>(); - foreach (var tuple in methodSet) - { - if (tuple.Item3 != null && tuple.Item3.IsDisposed) - { - patchesToRemove.Add(tuple); - continue; - } + private class LuaCsPatch + { + public string Identifier { get; set; } - object[] args = new object[] { __instance }.Concat(__args).ToArray(); - object _result = tuple.Item2(args); + public LuaCsPatchFunc PatchFunc { get; set; } + } - if (_result == null) - { - continue; - } + private class PatchedMethod + { + public PatchedMethod(MethodInfo harmonyPrefix, MethodInfo harmonyPostfix) + { + HarmonyPrefixMethod = harmonyPrefix; + HarmonyPostfixMethod = harmonyPostfix; + Prefixes = new Dictionary(); + Postfixes = new Dictionary(); + } - if (_result is LuaResult res) - { - if (!res.IsNull()) - { - if (__originalMethod is MethodInfo mi && mi.ReturnType != typeof(void)) - { - result = res.DynValue().ToObject(mi.ReturnType); - } - else - { - result = res.DynValue().ToObject(); - } - } - } - else - { - result = _result; - } - } + public MethodInfo HarmonyPrefixMethod { get; } - foreach (var tuple in patchesToRemove) - { - methodSet.Remove(tuple); - } - } - catch (Exception ex) - { - GameMain.LuaCs.HandleException(ex, $"Error in {__originalMethod.Name}:", exceptionType: LuaCsSetup.ExceptionType.Both); - } - } + public MethodInfo HarmonyPostfixMethod { get; } + public IEnumerator GetPrefixEnumerator() => Prefixes.Values.GetEnumerator(); - public void Patch(string identifier, string className, string methodName, string[] parameterNames, LuaCsFunc patch, HookMethodType hookMethodType = HookMethodType.Before) - { - MethodInfo methodInfo = ResolveMethod(className, methodName, parameterNames); - if (methodInfo == null) return; - Patch(identifier, methodInfo, patch, hookMethodType); - } - public void Patch(string identifier, string className, string methodName, LuaCsFunc patch, HookMethodType hookMethodType = HookMethodType.Before) => - Patch(identifier, className, methodName, null, patch, hookMethodType); - public void Patch(string className, string methodName, LuaCsFunc patch, HookMethodType hookMethodType = HookMethodType.Before) => - Patch("", className, methodName, null, patch, hookMethodType); - public void Patch(string className, string methodName, string[] parameterNames, LuaCsFunc patch, HookMethodType hookMethodType = HookMethodType.Before) => - Patch("", className, methodName, parameterNames, patch, hookMethodType); + public IEnumerator GetPostfixEnumerator() => Postfixes.Values.GetEnumerator(); + public Dictionary Prefixes { get; } - public void RemovePatch(string identifier, MethodInfo method, HookMethodType hookType = HookMethodType.Before) - { - var funcAddr = (long)method.MethodHandle.GetFunctionPointer(); + public Dictionary Postfixes { get; } + } - Dictionary> methods; - if (hookType == HookMethodType.Before) { methods = hookPrefixMethods; } - else if (hookType == HookMethodType.After) { methods = hookPostfixMethods; } - else { throw new NotImplementedException(); } + public class ParameterTable + { + private readonly Dictionary parameters; + private bool returnValueModified; + private object returnValue; - if (methods.ContainsKey(funcAddr)) - { - methods[funcAddr]?.RemoveWhere(t => t.Item1 == identifier); - } - } + public ParameterTable(Dictionary dict) + { + parameters = dict; + } - public void RemovePatch(string identifier, string className, string methodName, string[] parameterNames, HookMethodType hookType = HookMethodType.Before) - { - MethodInfo methodInfo = ResolveMethod(className, methodName, parameterNames); + public object this[string paramName] + { + get + { + if (ModifiedParameters.TryGetValue(paramName, out var value)) + { + return value; + } + return OriginalParameters[paramName]; + } + set + { + ModifiedParameters[paramName] = value; + } + } - if (methodInfo == null) - { - return; - } + public object OriginalReturnValue { get; private set; } - RemovePatch(identifier, methodInfo, hookType); - } - } -} \ No newline at end of file + public object ReturnValue + { + get + { + if (returnValueModified) return returnValue; + return OriginalReturnValue; + } + set + { + returnValueModified = true; + returnValue = value; + } + } + + public bool PreventExecution { get; set; } + + public Dictionary OriginalParameters => parameters; + + [MoonSharpHidden] + public Dictionary ModifiedParameters { get; } = new Dictionary(); + } + + private static readonly string[] prohibitedHooks = + { + "Barotrauma.Lua", + "Barotrauma.Cs", + "ContentPackageManager", + }; + + private static void ValidatePatchTarget(MethodInfo methodInfo) + { + if (prohibitedHooks.Any(h => methodInfo.DeclaringType.FullName.StartsWith(h))) + { + throw new ArgumentException("Hooks into the modding environment are prohibited."); + } + } + + private static string NormalizeIdentifier(string identifier) + { + return identifier?.Trim().ToLowerInvariant(); + } + + private Harmony harmony; + + private Lazy patchModuleBuilder; + + private readonly Dictionary> hookFunctions = new Dictionary>(); + + private readonly Dictionary registeredPatches = new Dictionary(); + + private LuaCsSetup luaCs; + + private static LuaCsHook instance; + + private struct MethodKey : IEquatable + { + public ModuleHandle ModuleHandle { get; set; } + + public int MetadataToken { get; set; } + + public override bool Equals(object obj) + { + return obj is MethodKey key && Equals(key); + } + + public bool Equals(MethodKey other) + { + return ModuleHandle.Equals(other.ModuleHandle) && MetadataToken == other.MetadataToken; + } + + public override int GetHashCode() + { + return HashCode.Combine(ModuleHandle, MetadataToken); + } + + public static bool operator ==(MethodKey left, MethodKey right) + { + return left.Equals(right); + } + + public static bool operator !=(MethodKey left, MethodKey right) + { + return !(left == right); + } + + public static MethodKey Create(MethodInfo method) => new MethodKey + { + ModuleHandle = method.Module.ModuleHandle, + MetadataToken = method.MetadataToken, + }; + } + + internal LuaCsHook(LuaCsSetup luaCs) + { + instance = this; + this.luaCs = luaCs; + } + + public void Initialize() + { + harmony = new Harmony("LuaCsForBarotrauma"); + patchModuleBuilder = new Lazy(CreateModuleBuilder); + + UserData.RegisterType(); + var hookType = UserData.RegisterType(); + var hookDesc = (StandardUserDataDescriptor)hookType; + typeof(LuaCsHook).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).ToList().ForEach(m => { + if ( + m.Name.Contains("HookMethod") || + m.Name.Contains("UnhookMethod") || + m.Name.Contains("EnqueueFunction") || + m.Name.Contains("EnqueueTimedFunction") + ) + { + hookDesc.AddMember(m.Name, new MethodMemberDescriptor(m, InteropAccessMode.Default)); + } + }); + } + + private ModuleBuilder CreateModuleBuilder() + { + var assemblyName = $"LuaCsHookPatch-{Guid.NewGuid():N}"; + var assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName(assemblyName), AssemblyBuilderAccess.RunAndCollect); + var moduleBuilder = assemblyBuilder.DefineDynamicModule("LuaCsHookPatch"); + + // This code emits the Roslyn attribute + // "IgnoresAccessChecksToAttribute" so we can freely access + // the Barotrauma assembly from our dynamic patches. + // This is important because the generated IL references + // non-public types/members. + + // class IgnoresAccessChecksToAttribute { + var typeBuilder = moduleBuilder.DefineType( + name: "System.Runtime.CompilerServices.IgnoresAccessChecksToAttribute", + attr: TypeAttributes.NotPublic | TypeAttributes.Sealed | TypeAttributes.Class, + parent: typeof(Attribute)); + + // [AttributeUsage(AllowMultiple = true)] + var attributeUsageAttribute = new CustomAttributeBuilder( + con: typeof(AttributeUsageAttribute).GetConstructor(new[] { typeof(AttributeTargets) }), + constructorArgs: new object[] { AttributeTargets.Assembly }, + namedProperties: new[] { typeof(AttributeUsageAttribute).GetProperty("AllowMultiple") }, + propertyValues: new object[] { true }); + typeBuilder.SetCustomAttribute(attributeUsageAttribute); + + // private readonly string assemblyName; + var attributeTypeFieldBuilder = typeBuilder.DefineField( + fieldName: "assemblyName", + type: typeof(string), + attributes: FieldAttributes.Private | FieldAttributes.InitOnly); + + var ctor = Emit.BuildConstructor( + parameterTypes: new[] { typeof(string) }, + type: typeBuilder, + attributes: MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, + callingConvention: CallingConventions.Standard | CallingConventions.HasThis); + // IL: this.assemblyName = arg; + ctor.LoadArgument(0); + ctor.LoadArgument(1); + ctor.StoreField(attributeTypeFieldBuilder); + ctor.Return(); + ctor.CreateConstructor(); + + // public string AttributeName => this.assemblyName; + var attributeNameGetter = Emit.BuildMethod( + returnType: typeof(string), + parameterTypes: new Type[0], + type: typeBuilder, + name: "get_AttributeName", + attributes: MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName, + callingConvention: CallingConventions.Standard | CallingConventions.HasThis); + attributeNameGetter.LoadArgument(0); + attributeNameGetter.LoadField(attributeTypeFieldBuilder); + attributeNameGetter.Return(); + + var attributeName = typeBuilder.DefineProperty( + name: "AttributeName", + attributes: PropertyAttributes.None, + returnType: typeof(string), + parameterTypes: null); + attributeName.SetGetMethod(attributeNameGetter.CreateMethod()); + // } + + var type = typeBuilder.CreateTypeInfo().AsType(); + + // The assembly names are hardcoded, otherwise it would + // break unit tests. + var assembliesToExpose = new[] { "Barotrauma", "DedicatedServer" }; + foreach (var name in assembliesToExpose) + { + var attr = new CustomAttributeBuilder( + con: type.GetConstructor(new[] { typeof(string)}), + constructorArgs: new[] { name }); + assemblyBuilder.SetCustomAttribute(attr); + } + + return moduleBuilder; + } + + public void Add(string name, string identifier, LuaCsFunc func, ACsMod owner = null) + { + if (name == null) throw new ArgumentNullException(nameof(name)); + if (identifier == null) throw new ArgumentNullException(nameof(identifier)); + if (func == null) throw new ArgumentNullException(nameof(func)); + + name = NormalizeIdentifier(name); + identifier = NormalizeIdentifier(identifier); + + if (!hookFunctions.ContainsKey(name)) + { + hookFunctions.Add(name, new Dictionary()); + } + + hookFunctions[name][identifier] = (new LuaCsHookCallback(name, identifier, func), owner); + } + + public void Remove(string name, string identifier) + { + if (name == null) throw new ArgumentNullException(nameof(name)); + if (identifier == null) throw new ArgumentNullException(nameof(identifier)); + + name = NormalizeIdentifier(name); + identifier = NormalizeIdentifier(identifier); + + if (hookFunctions.ContainsKey(name) && hookFunctions[name].ContainsKey(identifier)) + { + hookFunctions[name].Remove(identifier); + } + } + + public void Clear() + { + harmony?.UnpatchAll(); + + foreach (var (_, patch) in registeredPatches) + { + // Remove references stored in our dynamic types so the generated + // assembly can be garbage-collected. + patch.HarmonyPrefixMethod.DeclaringType + .GetField(FIELD_LUACS, BindingFlags.Public | BindingFlags.Static) + .SetValue(null, null); + patch.HarmonyPostfixMethod.DeclaringType + .GetField(FIELD_LUACS, BindingFlags.Public | BindingFlags.Static) + .SetValue(null, null); + } + + hookFunctions.Clear(); + registeredPatches.Clear(); + patchModuleBuilder = null; + + compatHookPrefixMethods.Clear(); + compatHookPostfixMethods.Clear(); + } + + public void Update() { } + + private Stopwatch performanceMeasurement = new Stopwatch(); + + [MoonSharpHidden] + public T Call(string name, params object[] args) + { + if (name == null) throw new ArgumentNullException(name); + if (args == null) args = new object[0]; + + name = NormalizeIdentifier(name); + if (!hookFunctions.ContainsKey(name)) return default; + + T lastResult = default; + + var hooksToRemove = new List(); + foreach ((var key, var tuple) in hookFunctions[name]) + { + if (tuple.Item2 != null && tuple.Item2.IsDisposed) + { + hooksToRemove.Add(key); + continue; + } + + try + { + if (luaCs.PerformanceCounter.EnablePerformanceCounter) + { + performanceMeasurement.Start(); + } + + var result = tuple.Item1.func(args); + // TODO(BREAKING): change this to !result.IsVoid() + if (result != null && !result.IsNil()) + { + lastResult = result.ToObject(); + } + + if (luaCs.PerformanceCounter.EnablePerformanceCounter) + { + performanceMeasurement.Stop(); + luaCs.PerformanceCounter.SetHookElapsedTicks(name, key, performanceMeasurement.ElapsedTicks); + performanceMeasurement.Reset(); + } + } + catch (Exception e) + { + var argsSb = new StringBuilder(); + foreach (var arg in args) + { + argsSb.Append(arg + " "); + } + luaCs.PrintError($"Error in Hook '{name}'->'{key}', with args '{argsSb}':\n{e}", LuaCsMessageOrigin.Unknown); + luaCs.HandleException(e, LuaCsMessageOrigin.Unknown); + } + } + foreach (var key in hooksToRemove) + { + hookFunctions[name].Remove(key); + } + + return lastResult; + } + + public object Call(string name, params object[] args) => Call(name, args); + + private static MethodInfo ResolveMethod(string className, string methodName, string[] parameterNames) + { + var classType = LuaUserData.GetType(className); + if (classType == null) throw new InvalidOperationException($"Invalid class name '{className}'"); + + const BindingFlags BINDING_FLAGS = BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + MethodInfo methodInfo = null; + if (parameterNames != null) + { + var parameterTypes = parameterNames.Select(x => LuaUserData.GetType(x)).ToArray(); + methodInfo = classType.GetMethod(methodName, BINDING_FLAGS, null, parameterTypes, null); + } + else + { + methodInfo = classType.GetMethod(methodName, BINDING_FLAGS); + } + + if (methodInfo == null) + { + var parameterNamesStr = parameterNames == null ? "" : string.Join(", ", parameterNames); + throw new InvalidOperationException($"Method '{methodName}({parameterNamesStr})' not found in class '{className}'"); + } + + return methodInfo; + } + + private class DynamicParameterMapping + { + public DynamicParameterMapping(string name, Type originalMethodParamType, Type harmonyPatchParamType) + { + ParameterName = name; + OriginalMethodParamType = originalMethodParamType; + HarmonyPatchParamType = harmonyPatchParamType; + } + + public string ParameterName { get; set; } + + public Type OriginalMethodParamType { get; set; } + + public Type HarmonyPatchParamType { get; set; } + } + + private static readonly Regex InvalidIdentifierCharsRegex = new Regex(@"[^\w\d]", RegexOptions.Compiled); + + private const string FIELD_LUACS = "LuaCs"; + + // If you need to debug this: + // - use https://sharplab.io ; it's a very useful for resource for writing IL by hand. + // - use il.NewMessage("") or il.WriteLine("") to see where the IL crashes at runtime. + private MethodInfo CreateDynamicHarmonyPatch(string identifier, MethodInfo original, HookMethodType hookType) + { + var parameters = new List + { + new DynamicParameterMapping("__originalMethod", null, typeof(MethodBase)), + new DynamicParameterMapping("__instance", null, typeof(object)), + }; + + var hasReturnType = original.ReturnType != typeof(void); + if (hasReturnType) + { + parameters.Add(new DynamicParameterMapping("__result", null, typeof(object).MakeByRefType())); + } + + foreach (var parameter in original.GetParameters()) + { + var paramName = parameter.Name; + var originalMethodParamType = parameter.ParameterType; + var harmonyPatchParamType = originalMethodParamType.IsByRef + ? originalMethodParamType + // Make all parameters modifiable by the harmony patch + : originalMethodParamType.MakeByRefType(); + parameters.Add(new DynamicParameterMapping(paramName, originalMethodParamType, harmonyPatchParamType)); + } + + static string MangleName(object o) => InvalidIdentifierCharsRegex.Replace(o?.ToString(), "_"); + + var moduleBuilder = patchModuleBuilder.Value; + var mangledName = original.DeclaringType != null + ? $"{MangleName(original.DeclaringType)}-{MangleName(original)}" + : MangleName(original); + var typeBuilder = moduleBuilder.DefineType($"Patch_{identifier}_{Guid.NewGuid():N}_{mangledName}", TypeAttributes.Public); + + var luaCsField = typeBuilder.DefineField(FIELD_LUACS, typeof(LuaCsSetup), FieldAttributes.Public | FieldAttributes.Static); + + var methodName = hookType == HookMethodType.Before ? "HarmonyPrefix" : "HarmonyPostfix"; + var il = Emit.BuildMethod( + returnType: hookType == HookMethodType.Before ? typeof(bool) : typeof(void), + parameterTypes: parameters.Select(x => x.HarmonyPatchParamType).ToArray(), + type: typeBuilder, + name: methodName, + attributes: MethodAttributes.Public | MethodAttributes.Static, + callingConvention: CallingConventions.Standard); + + var labelReturn = il.DefineLabel("endOfFunction"); + + il.BeginExceptionBlock(out var exceptionBlock); + + // IL: var harmonyReturnValue = true; + var harmonyReturnValue = il.DeclareLocal("harmonyReturnValue"); + il.LoadConstant(true); + il.StoreLocal(harmonyReturnValue); + + // IL: var patchKey = MethodKey.Create(__originalMethod); + var patchKey = il.DeclareLocal("patchKey"); + il.LoadArgument(0); // load __originalMethod + il.CastClass(); + il.Call(typeof(MethodKey).GetMethod(nameof(MethodKey.Create))); + il.StoreLocal(patchKey); + + // IL: var patchExists = instance.registeredPatches.TryGetValue(patchKey, out MethodPatches patches) + var patchExists = il.DeclareLocal("patchExists"); + var patches = il.DeclareLocal("patches"); + il.LoadField(typeof(LuaCsHook).GetField(nameof(instance), BindingFlags.NonPublic | BindingFlags.Static)); + il.LoadField(typeof(LuaCsHook).GetField(nameof(registeredPatches), BindingFlags.NonPublic | BindingFlags.Instance)); + il.LoadLocal(patchKey); + il.LoadLocalAddress(patches); // out parameter + il.Call(typeof(Dictionary).GetMethod("TryGetValue")); + il.StoreLocal(patchExists); + + // IL: if (!patchExists) + il.LoadLocal(patchExists); + il.IfNot((il) => + { + // XXX: if we get here, it's probably because a patched + // method was running when `reloadlua` was executed. + // This can happen with a postfix on + // `Barotrauma.Networking.GameServer#Update`. + il.Leave(labelReturn); + }); + + // IL: var parameterDict = new Dictionary(); + var parameterDict = il.DeclareLocal>("parameterDict"); + il.LoadConstant(parameters.Count(x => x.OriginalMethodParamType != null)); // preallocate the dictionary using the # of args + il.NewObject(typeof(Dictionary), typeof(int)); + il.StoreLocal(parameterDict); + + for (ushort i = 0; i < parameters.Count; i++) + { + // Skip parameters that don't exist in the original method + if (parameters[i].OriginalMethodParamType == null) continue; + + // IL: parameterDict.Add(, ); + il.LoadLocal(parameterDict); + il.LoadConstant(parameters[i].ParameterName); + il.LoadArgument(i); + il.ToObject(parameters[i].HarmonyPatchParamType); + il.Call(typeof(Dictionary).GetMethod("Add")); + } + + // IL: var ptable = new ParameterTable(parameterDict); + var ptable = il.DeclareLocal("ptable"); + il.LoadLocal(parameterDict); + il.NewObject(typeof(ParameterTable), typeof(Dictionary)); + il.StoreLocal(ptable); + + if (hasReturnType && hookType == HookMethodType.After) + { + // IL: ptable.OriginalReturnValue = __result; + il.LoadLocal(ptable); + il.LoadArgument(2); // ref __result + il.ToObject(parameters[2].HarmonyPatchParamType); + il.Call(typeof(ParameterTable).GetProperty(nameof(ParameterTable.OriginalReturnValue)).GetSetMethod(nonPublic: true)); + } + + // IL: var enumerator = patches.GetPrefixEnumerator(); + var enumerator = il.DeclareLocal>("enumerator"); + il.LoadLocal(patches); + il.CallVirtual(typeof(PatchedMethod).GetMethod( + name: hookType == HookMethodType.Before + ? nameof(PatchedMethod.GetPrefixEnumerator) + : nameof(PatchedMethod.GetPostfixEnumerator), + bindingAttr: BindingFlags.Public | BindingFlags.Instance)); + il.StoreLocal(enumerator); + + var labelUpdateParameters = il.DefineLabel("updateParameters"); + + // Iterate over prefixes/postfixes + il.ForEachEnumerator(enumerator, (il, current, labelLeave) => + { + // IL: var luaReturnValue = current.PatchFunc.Invoke(__instance, ptable); + var luaReturnValue = il.DeclareLocal("luaReturnValue"); + il.LoadLocal(current); + il.Call(typeof(LuaCsPatch).GetProperty(nameof(LuaCsPatch.PatchFunc)).GetGetMethod()); + il.LoadArgument(1); // __instance + il.LoadLocal(ptable); + il.CallVirtual(typeof(LuaCsPatchFunc).GetMethod("Invoke")); + il.StoreLocal(luaReturnValue); + + if (hasReturnType) + { + // IL: var ptableReturnValue = ptable.ReturnValue; + var ptableReturnValue = il.DeclareLocal("ptableReturnValue"); + il.LoadLocal(ptable); + il.Call(typeof(ParameterTable).GetProperty(nameof(ParameterTable.ReturnValue)).GetGetMethod()); + il.StoreLocal(ptableReturnValue); + + // IL: if (ptableReturnValue != null) + il.LoadLocal(ptableReturnValue); + il.If((il) => + { + // IL: __result = ptableReturnValue; + il.LoadArgument(2); // ref __result + il.LoadLocal(ptableReturnValue); + il.StoreIndirect(typeof(object)); + il.Break(); + }); + + // IL: if (luaReturnValue != null) + il.LoadLocal(luaReturnValue); + il.If((il) => + { + // IL: if (!luaReturnValue.IsVoid()) + il.LoadLocal(luaReturnValue); + il.Call(typeof(DynValue).GetMethod(nameof(DynValue.IsVoid))); + il.IfNot((il) => + { + // IL: var csReturnType = Type.GetTypeFromHandle(); + var csReturnType = il.DeclareLocal("csReturnType"); + il.LoadType(original.ReturnType); + il.StoreLocal(csReturnType); + + // IL: var csReturnValue = luaReturnValue.ToObject(csReturnValueType); + var csReturnValue = il.DeclareLocal("csReturnValue"); + il.LoadLocal(luaReturnValue); + il.LoadLocal(csReturnType); + il.Call(typeof(DynValue).GetMethod( + name: nameof(DynValue.ToObject), + bindingAttr: BindingFlags.Public | BindingFlags.Instance, + binder: null, + types: new Type[] { typeof(Type) }, + modifiers: null)); + il.StoreLocal(csReturnValue); + + // IL: __result = csReturnValue; + il.LoadArgument(2); // ref __result + il.LoadLocal(csReturnValue); + il.StoreIndirect(typeof(object)); + }); + }); + } + + // IL: if (ptable.PreventExecution) + il.LoadLocal(ptable); + il.Call(typeof(ParameterTable).GetProperty(nameof(ParameterTable.PreventExecution)).GetGetMethod()); + il.If((il) => + { + // IL: harmonyReturnValue = false; + il.LoadConstant(false); + il.StoreLocal(harmonyReturnValue); + + // IL: break; + il.Leave(labelLeave); + }); + }); + + // IL: var modifiedParameters = ptable.ModifiedParameters; + var modifiedParameters = il.DeclareLocal>("modifiedParameters"); + il.LoadLocal(ptable); + il.Call(typeof(ParameterTable).GetProperty(nameof(ParameterTable.ModifiedParameters)).GetGetMethod()); + il.StoreLocal(modifiedParameters); + // IL: object modifiedValue; + var modifiedValue = il.DeclareLocal("modifiedValue"); + + // Update the parameters + for (ushort i = 0; i < parameters.Count; i++) + { + // Skip parameters that don't exist in the original method + if (parameters[i].OriginalMethodParamType == null) continue; + + // IL: if (modifiedParameters.TryGetValue("parameterName", out modifiedValue)) + il.LoadLocal(modifiedParameters); + il.LoadConstant(parameters[i].ParameterName); + il.LoadLocalAddress(modifiedValue); // out parameter + il.Call(typeof(Dictionary).GetMethod(nameof(Dictionary.TryGetValue))); + il.If((il) => + { + // XXX: GetElementType() gets the "real" type behind + // the ByRef. This is safe because all the parameters + // are made into ByRef to support modification. + var paramType = parameters[i].HarmonyPatchParamType.GetElementType(); + + // IL: ref argName = modifiedValue; + il.LoadArgument(i); + il.LoadLocalAndCast(modifiedValue, paramType); + if (paramType.IsValueType) + { + il.StoreObject(paramType); + } + else + { + il.StoreIndirect(paramType); + } + }); + } + + il.MarkLabel(labelReturn); + + // IL: catch (Exception exception) + il.BeginCatchAllBlock(exceptionBlock, out var catchBlock); + var exception = il.DeclareLocal("exception"); + il.StoreLocal(exception); + + // IL: if (LuaCs != null) + il.LoadField(luaCsField); + il.If((il) => + { + // IL: LuaCs.HandleException(exception, LuaCsMessageOrigin.LuaMod); + il.LoadField(luaCsField); + il.LoadLocal(exception); + il.LoadConstant((int)LuaCsMessageOrigin.LuaMod); // underlying enum type is int + il.Call(typeof(LuaCsSetup).GetMethod(nameof(LuaCsSetup.HandleException), BindingFlags.NonPublic | BindingFlags.Instance)); + }); + + il.EndCatchBlock(catchBlock); + + il.EndExceptionBlock(exceptionBlock); + + // Only prefixes return a bool + if (hookType == HookMethodType.Before) + { + il.LoadLocal(harmonyReturnValue); + } + il.Return(); + + var method = il.CreateMethod(); + for (var i = 0; i < parameters.Count; i++) + { + method.DefineParameter(i + 1, ParameterAttributes.None, parameters[i].ParameterName); + } + + var type = typeBuilder.CreateType(); + type.GetField(FIELD_LUACS, BindingFlags.Public | BindingFlags.Static).SetValue(null, luaCs); + return type.GetMethod(methodName, BindingFlags.Public | BindingFlags.Static); + } + + private string Patch(string identifier, MethodInfo method, LuaCsPatchFunc patch, HookMethodType hookType = HookMethodType.Before) + { + if (method == null) throw new ArgumentNullException(nameof(method)); + if (patch == null) throw new ArgumentNullException(nameof(patch)); + ValidatePatchTarget(method); + + identifier ??= Guid.NewGuid().ToString("N"); + identifier = NormalizeIdentifier(identifier); + + var patchKey = MethodKey.Create(method); + if (!registeredPatches.TryGetValue(patchKey, out var methodPatches)) + { + var harmonyPrefix = CreateDynamicHarmonyPatch(identifier, method, HookMethodType.Before); + var harmonyPostfix = CreateDynamicHarmonyPatch(identifier, method, HookMethodType.After); + harmony.Patch(method, prefix: new HarmonyMethod(harmonyPrefix), postfix: new HarmonyMethod(harmonyPostfix)); + methodPatches = registeredPatches[patchKey] = new PatchedMethod(harmonyPrefix, harmonyPostfix); + } + + if (hookType == HookMethodType.Before) + { + if (methodPatches.Prefixes.Remove(identifier)) + { + luaCs.PrintMessage($"Replacing existing prefix: {identifier}"); + } + + methodPatches.Prefixes.Add(identifier, new LuaCsPatch + { + Identifier = identifier, + PatchFunc = patch, + }); + } + else if (hookType == HookMethodType.After) + { + if (methodPatches.Postfixes.Remove(identifier)) + { + luaCs.PrintMessage($"Replacing existing postfix: {identifier}"); + } + + methodPatches.Postfixes.Add(identifier, new LuaCsPatch + { + Identifier = identifier, + PatchFunc = patch, + }); + } + + return identifier; + } + + public string Patch(string identifier, string className, string methodName, string[] parameterTypes, LuaCsPatchFunc patch, HookMethodType hookType = HookMethodType.Before) + { + var methodInfo = ResolveMethod(className, methodName, parameterTypes); + return Patch(identifier, methodInfo, patch, hookType); + } + + public string Patch(string identifier, string className, string methodName, LuaCsPatchFunc patch, HookMethodType hookType = HookMethodType.Before) + { + var methodInfo = ResolveMethod(className, methodName, null); + return Patch(identifier, methodInfo, patch, hookType); + } + + public string Patch(string className, string methodName, string[] parameterTypes, LuaCsPatchFunc patch, HookMethodType hookType = HookMethodType.Before) + { + var methodInfo = ResolveMethod(className, methodName, parameterTypes); + return Patch(null, methodInfo, patch, hookType); + } + + public string Patch(string className, string methodName, LuaCsPatchFunc patch, HookMethodType hookType = HookMethodType.Before) + { + var methodInfo = ResolveMethod(className, methodName, null); + return Patch(null, methodInfo, patch, hookType); + } + + private bool RemovePatch(string identifier, MethodInfo method, HookMethodType hookType) + { + if (identifier == null) throw new ArgumentNullException(nameof(identifier)); + identifier = NormalizeIdentifier(identifier); + + var patchKey = MethodKey.Create(method); + if (!registeredPatches.TryGetValue(patchKey, out var methodPatches)) + { + return false; + } + + return hookType switch + { + HookMethodType.Before => methodPatches.Prefixes.Remove(identifier), + HookMethodType.After => methodPatches.Postfixes.Remove(identifier), + _ => throw new ArgumentException($"Invalid {nameof(HookMethodType)} enum value.", nameof(hookType)), + }; + } + + public bool RemovePatch(string identifier, string className, string methodName, string[] parameterTypes, HookMethodType hookType) + { + var methodInfo = ResolveMethod(className, methodName, parameterTypes); + return RemovePatch(identifier, methodInfo, hookType); + } + + public bool RemovePatch(string identifier, string className, string methodName, HookMethodType hookType) + { + var methodInfo = ResolveMethod(className, methodName, null); + return RemovePatch(identifier, methodInfo, hookType); + } + } +} diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHookCompat.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHookCompat.cs index dee8089e3..b3a4eb9be 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHookCompat.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHookCompat.cs @@ -1,31 +1,31 @@ using System; using System.Linq; using System.Reflection; -using MoonSharp.Interpreter; using HarmonyLib; using System.Collections.Generic; -using System.Text; -using MoonSharp.Interpreter.Interop; +using MoonSharp.Interpreter; using static Barotrauma.LuaCsSetup; -using System.Threading; -using System.Diagnostics; +using LuaCsCompatPatchFunc = Barotrauma.LuaCsPatch; namespace Barotrauma { - partial class LuaCsHook - { - private Dictionary> compatHookPrefixMethods; - private Dictionary> compatHookPostfixMethods; + // XXX: this can't be renamed because of backward compatibility with C# mods + public delegate object LuaCsPatch(object self, Dictionary args); - private static void _hookLuaCsPatch(MethodBase __originalMethod, object[] __args, object __instance, out object result, HookMethodType hookMethodType) + partial class LuaCsHook + { + private Dictionary> compatHookPrefixMethods = new Dictionary>(); + private Dictionary> compatHookPostfixMethods = new Dictionary>(); + + private static void _hookLuaCsPatch(MethodBase __originalMethod, object[] __args, object __instance, out object result, HookMethodType hookType) { result = null; try { var funcAddr = ((long)__originalMethod.MethodHandle.GetFunctionPointer()); - HashSet<(string, LuaCsPatch, ACsMod)> methodSet = null; - switch (hookMethodType) + HashSet<(string, LuaCsCompatPatchFunc, ACsMod)> methodSet = null; + switch (hookType) { case HookMethodType.Before: instance.compatHookPrefixMethods.TryGetValue(funcAddr, out methodSet); @@ -34,7 +34,7 @@ namespace Barotrauma instance.compatHookPostfixMethods.TryGetValue(funcAddr, out methodSet); break; default: - break; + throw new ArgumentException($"Invalid {nameof(HookMethodType)} enum value.", nameof(hookType)); } if (methodSet != null) @@ -46,7 +46,7 @@ namespace Barotrauma args.Add(@params[i].Name, __args[i]); } - var outOfSocpe = new HashSet<(string, LuaCsPatch, ACsMod)>(); + var outOfSocpe = new HashSet<(string, LuaCsCompatPatchFunc, ACsMod)>(); foreach (var tuple in methodSet) { if (tuple.Item3 != null && tuple.Item3.IsDisposed) @@ -58,17 +58,17 @@ namespace Barotrauma var _result = tuple.Item2(__instance, args); if (_result != null) { - if (_result is LuaResult res) + if (_result is DynValue res) { - if (!res.IsNull()) + if (!res.IsNil()) { if (__originalMethod is MethodInfo mi && mi.ReturnType != typeof(void)) { - result = res.DynValue().ToObject(mi.ReturnType); + result = res.ToObject(mi.ReturnType); } else { - result = res.DynValue().ToObject(); + result = res.ToObject(); } } } @@ -84,7 +84,8 @@ namespace Barotrauma } catch (Exception ex) { - GameMain.LuaCs.HandleException(ex, $"Error in {__originalMethod.Name}:", exceptionType: LuaCsSetup.ExceptionType.Both); + GameMain.LuaCs.PrintError($"Error in {__originalMethod.Name}:", LuaCsMessageOrigin.Unknown); + GameMain.LuaCs.HandleException(ex, LuaCsMessageOrigin.Unknown); } } @@ -94,6 +95,7 @@ namespace Barotrauma _hookLuaCsPatch(__originalMethod, __args, __instance, out object result, HookMethodType.Before); return result == null; } + private static void HookLuaCsPatchPostfix(MethodBase __originalMethod, object[] __args, object __instance) => _hookLuaCsPatch(__originalMethod, __args, __instance, out object _, HookMethodType.After); @@ -107,61 +109,27 @@ namespace Barotrauma } else return true; } + private static void HookLuaCsPatchRetPostfix(MethodBase __originalMethod, object[] __args, ref object __result, object __instance) { _hookLuaCsPatch(__originalMethod, __args, __instance, out object result, HookMethodType.After); if (result != null) __result = result; } - private static MethodInfo _miHookLuaCsPatchPrefix = typeof(LuaCsHook).GetMethod("HookLuaCsPatchPrefix", BindingFlags.NonPublic | BindingFlags.Static); private static MethodInfo _miHookLuaCsPatchPostfix = typeof(LuaCsHook).GetMethod("HookLuaCsPatchPostfix", BindingFlags.NonPublic | BindingFlags.Static); private static MethodInfo _miHookLuaCsPatchRetPrefix = typeof(LuaCsHook).GetMethod("HookLuaCsPatchRetPrefix", BindingFlags.NonPublic | BindingFlags.Static); private static MethodInfo _miHookLuaCsPatchRetPostfix = typeof(LuaCsHook).GetMethod("HookLuaCsPatchRetPostfix", BindingFlags.NonPublic | BindingFlags.Static); - private static MethodInfo ResolveMethod(string where, string className, string methodName, string[] parameterNames) - { - var classType = LuaUserData.GetType(className); - - if (classType == null) - { - GameMain.LuaCs.HandleException(new Exception($"Tried to use {where} with an invalid class name '{className}'.")); - return null; - } - - MethodInfo methodInfo = null; - - if (parameterNames != null) - { - Type[] parameterTypes = parameterNames.Select(x => LuaUserData.GetType(x)).ToArray(); - methodInfo = classType.GetMethod(methodName, DefaultBindingFlags, null, parameterTypes, null); - } - else - { - methodInfo = classType.GetMethod(methodName, DefaultBindingFlags); - } - - if (methodInfo == null) - { - string parameterNamesStr = parameterNames == null ? "" : string.Join(", ", parameterNames); - GameMain.LuaCs.HandleException(new Exception($"Method '{methodName}' with parameters '{parameterNamesStr}' not found in class '{className}'")); - } - - return methodInfo; - } - - public void HookMethod(string identifier, MethodInfo method, LuaCsPatch patch, HookMethodType hookType = HookMethodType.Before, ACsMod owner = null) + // TODO: deprecate this + public void HookMethod(string identifier, MethodInfo method, LuaCsCompatPatchFunc patch, HookMethodType hookType = HookMethodType.Before, ACsMod owner = null) { if (identifier == null || method == null || patch == null) { - GameMain.LuaCs.HandleException(new ArgumentNullException("Identifier, Method and Patch arguments must not be null."), exceptionType: ExceptionType.Both); - return; - } - if (prohibitedHooks.Any(h => method.DeclaringType.FullName.StartsWith(h))) - { - GameMain.LuaCs.HandleException(new ArgumentException("Hooks into Modding Environment are prohibited."), exceptionType: ExceptionType.Both); + luaCs.HandleException(new ArgumentNullException("Identifier, Method and Patch arguments must not be null."), LuaCsMessageOrigin.Unknown); return; } + ValidatePatchTarget(method); var funcAddr = ((long)method.MethodHandle.GetFunctionPointer()); var patches = Harmony.GetPatchInfo(method); @@ -183,7 +151,7 @@ namespace Barotrauma } } - if (compatHookPrefixMethods.TryGetValue(funcAddr, out HashSet<(string, LuaCsPatch, ACsMod)> methodSet)) + if (compatHookPrefixMethods.TryGetValue(funcAddr, out HashSet<(string, LuaCsCompatPatchFunc, ACsMod)> methodSet)) { if (identifier != "") { @@ -194,7 +162,7 @@ namespace Barotrauma } else if (patch != null) { - compatHookPrefixMethods.Add(funcAddr, new HashSet<(string, LuaCsPatch, ACsMod)>() { (identifier, patch, owner) }); + compatHookPrefixMethods.Add(funcAddr, new HashSet<(string, LuaCsCompatPatchFunc, ACsMod)>() { (identifier, patch, owner) }); } } @@ -215,7 +183,7 @@ namespace Barotrauma } } - if (compatHookPostfixMethods.TryGetValue(funcAddr, out HashSet<(string, LuaCsPatch, ACsMod)> methodSet)) + if (compatHookPostfixMethods.TryGetValue(funcAddr, out HashSet<(string, LuaCsCompatPatchFunc, ACsMod)> methodSet)) { if (identifier != "") { @@ -226,25 +194,25 @@ namespace Barotrauma } else if (patch != null) { - compatHookPostfixMethods.Add(funcAddr, new HashSet<(string, LuaCsPatch, ACsMod)>() { (identifier, patch, owner) }); + compatHookPostfixMethods.Add(funcAddr, new HashSet<(string, LuaCsCompatPatchFunc, ACsMod)>() { (identifier, patch, owner) }); } - } - } - - protected void HookMethod(string identifier, string className, string methodName, string[] parameterNames, LuaCsPatch patch, HookMethodType hookMethodType = HookMethodType.Before) + protected void HookMethod(string identifier, string className, string methodName, string[] parameterNames, LuaCsCompatPatchFunc patch, HookMethodType hookMethodType = HookMethodType.Before) { - - MethodInfo methodInfo = ResolveMethod("HookMethod", className, methodName, parameterNames); + var methodInfo = ResolveMethod(className, methodName, parameterNames); if (methodInfo == null) return; + if (methodInfo.GetParameters().Any(x => x.ParameterType.IsByRef)) + { + throw new InvalidOperationException($"{nameof(HookMethod)} doesn't support ByRef parameters; use {nameof(Patch)} instead."); + } HookMethod(identifier, methodInfo, patch, hookMethodType); } - protected void HookMethod(string identifier, string className, string methodName, LuaCsPatch patch, HookMethodType hookMethodType = HookMethodType.Before) => + protected void HookMethod(string identifier, string className, string methodName, LuaCsCompatPatchFunc patch, HookMethodType hookMethodType = HookMethodType.Before) => HookMethod(identifier, className, methodName, null, patch, hookMethodType); - protected void HookMethod(string className, string methodName, LuaCsPatch patch, HookMethodType hookMethodType = HookMethodType.Before) => + protected void HookMethod(string className, string methodName, LuaCsCompatPatchFunc patch, HookMethodType hookMethodType = HookMethodType.Before) => HookMethod("", className, methodName, null, patch, hookMethodType); - protected void HookMethod(string className, string methodName, string[] parameterNames, LuaCsPatch patch, HookMethodType hookMethodType = HookMethodType.Before) => + protected void HookMethod(string className, string methodName, string[] parameterNames, LuaCsCompatPatchFunc patch, HookMethodType hookMethodType = HookMethodType.Before) => HookMethod("", className, methodName, parameterNames, patch, hookMethodType); @@ -252,7 +220,7 @@ namespace Barotrauma { var funcAddr = ((long)method.MethodHandle.GetFunctionPointer()); - Dictionary> methods; + Dictionary> methods; if (hookType == HookMethodType.Before) methods = compatHookPrefixMethods; else if (hookType == HookMethodType.After) methods = compatHookPostfixMethods; else throw null; @@ -261,7 +229,7 @@ namespace Barotrauma } protected void UnhookMethod(string identifier, string className, string methodName, string[] parameterNames, HookMethodType hookType = HookMethodType.Before) { - MethodInfo methodInfo = ResolveMethod("UnhookMathod", className, methodName, parameterNames); + var methodInfo = ResolveMethod(className, methodName, parameterNames); if (methodInfo == null) return; UnhookMethod(identifier, methodInfo, hookType); } diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsModStore.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsModStore.cs index d539cb5e1..759f8e69e 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsModStore.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsModStore.cs @@ -73,7 +73,7 @@ namespace Barotrauma { if (luaModInterface.Any(i => i.Equals(modName))) { - GameMain.LuaCs.HandleException(new ArgumentException($"'{modName}' entry already registered"), exceptionType: ExceptionType.Lua); + GameMain.LuaCs.HandleException(new ArgumentException($"'{modName}' entry already registered"), LuaCsMessageOrigin.LuaMod); return null; } @@ -86,7 +86,7 @@ namespace Barotrauma { if (csModInterface.Any(i => i.Equals(mod))) { - GameMain.LuaCs.HandleException(new ArgumentException($"'{mod.GetType().FullName}' entry already registered"), exceptionType: ExceptionType.CSharp); + GameMain.LuaCs.HandleException(new ArgumentException($"'{mod.GetType().FullName}' entry already registered"), LuaCsMessageOrigin.CSharpMod); return null; } diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsNetworking.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsNetworking.cs index b2978aa63..339873483 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsNetworking.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsNetworking.cs @@ -93,9 +93,11 @@ namespace Barotrauma { LuaCsNetReceives[netMessageName](netMessage, client); } - catch(Exception e) + catch (Exception e) { - GameMain.LuaCs.HandleException(e, $"Exception thrown inside NetMessageReceive({netMessageName})", LuaCsSetup.ExceptionType.CSharp); + // TODO: make LuaCsNetworking hold a reference to LuaCsSetup instead of using this global + GameMain.LuaCs.PrintError($"Exception thrown inside NetMessageReceive({netMessageName})", LuaCsMessageOrigin.Unknown); + GameMain.LuaCs.HandleException(e, LuaCsMessageOrigin.Unknown); } } } @@ -120,7 +122,8 @@ namespace Barotrauma } catch (Exception e) { - GameMain.LuaCs.HandleException(e, $"Exception thrown inside NetMessageReceive({netMessageName})", LuaCsSetup.ExceptionType.CSharp); + GameMain.LuaCs.PrintError($"Exception thrown inside NetMessageReceive({netMessageName})", LuaCsMessageOrigin.Unknown); + GameMain.LuaCs.HandleException(e, LuaCsMessageOrigin.Unknown); } } } diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsSetup.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsSetup.cs index 42b9865e3..3e2b5742e 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsSetup.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsSetup.cs @@ -12,6 +12,7 @@ using System.Runtime.CompilerServices; using System.Linq; using System.Reflection; using System.Threading; +using LuaCsCompatPatchFunc = Barotrauma.LuaCsPatch; [assembly: InternalsVisibleTo(Barotrauma.CsScriptBase.CsScriptAssembly, AllInternalsVisible = true)] [assembly: InternalsVisibleTo(Barotrauma.CsScriptBase.CsOneTimeScriptAssembly, AllInternalsVisible = true)] @@ -24,6 +25,18 @@ namespace Barotrauma public LuaCsSetupConfig() { } } + internal delegate void LuaCsMessageLogger(string prefix, object o); + + internal delegate void LuaCsExceptionHandler(Exception ex, LuaCsMessageOrigin origin); + + internal enum LuaCsMessageOrigin + { + LuaCs, + Unknown, + LuaMod, + CSharpMod, + } + partial class LuaCsSetup { public const string LuaSetupFile = "Lua/LuaSetup.lua"; @@ -55,7 +68,7 @@ namespace Barotrauma /// public void RecreateCsScript() { - GameMain.LuaCs.CsScript = new CsScriptRunner(GameMain.LuaCs.CsScript.setup); + CsScript = new CsScriptRunner(CsScript.setup); lua.Globals["CsScript"] = CsScript; } @@ -76,7 +89,10 @@ namespace Barotrauma public LuaCsSetup() { - Hook = new LuaCsHook(); + MessageLogger = DefaultMessageLogger; + ExceptionHandler = DefaultExceptionHandler; + + Hook = new LuaCsHook(this); ModStore = new LuaCsModStore(); Game = new LuaGame(); @@ -136,123 +152,141 @@ namespace Barotrauma return null; } - public enum ExceptionType + private void DefaultExceptionHandler(Exception ex, LuaCsMessageOrigin origin) { - Lua, - CSharp, - Both + switch (ex) + { + case NetRuntimeException netRuntimeException: + if (netRuntimeException.DecoratedMessage == null) + { + PrintError(netRuntimeException, origin); + } + else + { + // FIXME: netRuntimeException.ToString() doesn't print the InnerException's stack trace... + PrintError($"{netRuntimeException.DecoratedMessage}: {netRuntimeException}", origin); + } + break; + case InterpreterException interpreterException: + if (interpreterException.DecoratedMessage == null) + { + PrintError(interpreterException, origin); + } + else + { + PrintError(interpreterException.DecoratedMessage, origin); + } + break; + default: + var msg = ex.StackTrace != null + ? ex.ToString() + : $"{ex}\n{Environment.StackTrace}"; + PrintError(msg, origin); + break; + } } - public void HandleException(Exception ex, string extra = "", ExceptionType exceptionType = ExceptionType.Lua) - { - if (!string.IsNullOrWhiteSpace(extra)) - if (exceptionType == ExceptionType.Lua) PrintError(extra); - else if (exceptionType == ExceptionType.CSharp) PrintCsError(extra); - else PrintBothError(extra); - if (ex is NetRuntimeException netRuntimeException) - { - if (netRuntimeException.DecoratedMessage == null) - { - PrintError(netRuntimeException); - } - else - { - PrintError(netRuntimeException.DecoratedMessage + ": " + netRuntimeException.ToString()); - } - } - else if (ex is InterpreterException interpreterException) - { - if (interpreterException.DecoratedMessage == null) - { - PrintError(interpreterException); - } - else - { - PrintError(interpreterException.DecoratedMessage); - } - } - else - { - string msg = ex.StackTrace != null - ? ex.ToString() - : $"{ex}\n{Environment.StackTrace}"; + internal LuaCsExceptionHandler ExceptionHandler { get; set; } - if (exceptionType == ExceptionType.Lua) { PrintError(msg); } - else if (exceptionType == ExceptionType.CSharp) { PrintCsError(msg); } - else { PrintBothError(msg); } - } - } - private static void PrintErrorBase(string prefix, object message, string empty) + internal void HandleException(Exception ex, LuaCsMessageOrigin origin) { - if (message == null) { message = empty; } - string str = message.ToString(); + this.ExceptionHandler?.Invoke(ex, origin); + } - for (int i = 0; i < str.Length; i += 1024) - { - string subStr = str.Substring(i, Math.Min(1024, str.Length - i)); - - string errorMsg = subStr; - if (i == 0) errorMsg = prefix + errorMsg; - - DebugConsole.ThrowError(errorMsg); - -#if SERVER - if (GameMain.Server != null) - { - foreach (var c in GameMain.Server.ConnectedClients) - { - GameMain.Server.SendDirectChatMessage(ChatMessage.Create("", errorMsg, ChatMessageType.Console, null, textColor: Color.Red), c); - } - - GameServer.Log(errorMsg, ServerLog.MessageType.Error); - } -#endif - } - } - -#if SERVER - public void PrintError(object message) => PrintErrorBase("[SV LUA ERROR] ", message, "nil"); - public static void PrintCsError(object message) => PrintErrorBase("[SV CS ERROR] ", message, "Null"); - public static void PrintBothError(object message) => PrintErrorBase("[SV ERROR] ", message, "Null"); -#else - public void PrintError(object message) => PrintErrorBase("[CL LUA ERROR] ", message, "nil"); - public static void PrintCsError(object message) => PrintErrorBase("[CL CS ERROR] ", message, "Null"); - public static void PrintBothError(object message) => PrintErrorBase("[CL ERROR] ", message, "Null"); -#endif - - private static void PrintMessageBase(string prefix, object message, string empty) + private static void PrintErrorBase(string prefix, object message, string empty) { - if (message == null) { message = empty; } - string str = message.ToString(); + message ??= empty; + var str = message.ToString(); - for (int i = 0; i < str.Length; i += 1024) - { - string subStr = str.Substring(i, Math.Min(1024, str.Length - i)); + for (int i = 0; i < str.Length; i += 1024) + { + var subStr = str.Substring(i, Math.Min(1024, str.Length - i)); + var errorMsg = subStr; + if (i == 0) errorMsg = prefix + errorMsg; + + DebugConsole.ThrowError(errorMsg); #if SERVER - if (GameMain.Server != null) - { - foreach (var c in GameMain.Server.ConnectedClients) - { - GameMain.Server.SendDirectChatMessage(ChatMessage.Create("", subStr, ChatMessageType.Console, null, textColor: Color.MediumPurple), c); - } + if (GameMain.Server != null) + { + foreach (var c in GameMain.Server.ConnectedClients) + { + GameMain.Server.SendDirectChatMessage(ChatMessage.Create("", errorMsg, ChatMessageType.Console, null, textColor: Color.Red), c); + } - GameServer.Log(prefix + subStr, ServerLog.MessageType.ServerMessage); - } + GameServer.Log(errorMsg, ServerLog.MessageType.Error); + } #endif - } + } + } #if SERVER - DebugConsole.NewMessage(message.ToString(), Color.MediumPurple); + private const string LOG_PREFIX = "SV"; #else - DebugConsole.NewMessage(message.ToString(), Color.Purple); + private const string LOG_PREFIX = "CL"; #endif - } - private void PrintMessage(object message) => PrintMessageBase("[LUA] ", message, "nil"); - public static void PrintCsMessage(object message) => PrintMessageBase("[CS] ", message, "Null"); - public static void PrintLogMessage(object message) => PrintMessageBase("[LuaCs LOG] ", message, "Null"); + + // TODO: deprecate this (in an effort to get rid of as much global state as possible) + public void PrintError(object o, LuaCsMessageOrigin origin) + { + switch (origin) + { + case LuaCsMessageOrigin.LuaCs: + PrintGenericError(o); + break; + case LuaCsMessageOrigin.LuaMod: + PrintLuaError(o); + break; + case LuaCsMessageOrigin.CSharpMod: + PrintCsError(o); + break; + } + } + + private static void PrintLuaError(object o) => PrintErrorBase($"[{LOG_PREFIX} LUA ERROR] ", o, "nil"); + + // TODO: deprecate this + // XXX: this is only public so that we don't break backward compat with C# mods + public static void PrintCsError(object o) => PrintErrorBase($"[{LOG_PREFIX} CS ERROR] ", o, "Null"); + + private static void PrintGenericError(object o) => PrintErrorBase($"[{LOG_PREFIX} ERROR] ", o, "Null"); + + internal LuaCsMessageLogger MessageLogger { get; set; } + + private static void DefaultMessageLogger(string prefix, object o) + { + var message = o.ToString(); + for (int i = 0; i < message.Length; i += 1024) + { + var subStr = message.Substring(i, Math.Min(1024, message.Length - i)); + +#if SERVER + if (GameMain.Server != null) + { + foreach (var c in GameMain.Server.ConnectedClients) + { + GameMain.Server.SendDirectChatMessage(ChatMessage.Create("", subStr, ChatMessageType.Console, null, textColor: Color.MediumPurple), c); + } + + GameServer.Log(prefix + subStr, ServerLog.MessageType.ServerMessage); + } +#endif + } + +#if SERVER + DebugConsole.NewMessage(message.ToString(), Color.MediumPurple); +#else + DebugConsole.NewMessage(message.ToString(), Color.Purple); +#endif + } + + private void PrintMessageBase(string prefix, object message, string empty) => MessageLogger?.Invoke(prefix, message ?? empty); + internal void PrintMessage(object message) => PrintMessageBase("[LuaCs] ", message, "nil"); + + // TODO: deprecate this (in an effort to get rid of as much global state as possible) + public static void PrintCsMessage(object message) => GameMain.LuaCs.PrintMessage(message); private DynValue DoFile(string file, Table globalContext = null, string codeStringFriendly = null) { @@ -284,17 +318,17 @@ namespace Barotrauma return lua.LoadFile(file, globalContext, codeStringFriendly); } - public object CallLuaFunction(object function, params object[] arguments) + public DynValue CallLuaFunction(object function, params object[] args) { lock (lua) { try { - return lua.Call(function, arguments); + return lua.Call(function, args); } catch (Exception e) { - HandleException(e); + HandleException(e, LuaCsMessageOrigin.LuaMod); } return null; } @@ -375,7 +409,7 @@ namespace Barotrauma LuaScriptLoader = new LuaScriptLoader(); LuaScriptLoader.ModulePaths = new string[] { }; - LuaCustomConverters.RegisterAll(); + LuaCustomConverters.Initialize(CallLuaFunction); lua = new Script(CoreModules.Preset_SoftSandbox | CoreModules.Debug); lua.Options.DebugPrint = PrintMessage; @@ -396,7 +430,8 @@ namespace Barotrauma UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); - UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); UserData.RegisterType(); @@ -408,7 +443,7 @@ namespace Barotrauma UserData.RegisterType(); UserData.RegisterType(); - lua.Globals["printerror"] = (Action)PrintError; + lua.Globals["printerror"] = (Action)PrintLuaError; lua.Globals["setmodulepaths"] = (Action)SetModulePaths; @@ -463,13 +498,13 @@ namespace Barotrauma } catch (Exception ex) { - HandleException(ex, exceptionType: ExceptionType.CSharp); + HandleException(ex, LuaCsMessageOrigin.CSharpMod); } }); } catch (Exception ex) { - HandleException(ex, exceptionType: ExceptionType.CSharp); + HandleException(ex, LuaCsMessageOrigin.CSharpMod); } } @@ -489,7 +524,7 @@ namespace Barotrauma } catch (Exception e) { - HandleException(e); + HandleException(e, LuaCsMessageOrigin.LuaMod); } } else if (luaPackage != null) @@ -505,20 +540,15 @@ namespace Barotrauma } catch (Exception e) { - HandleException(e); + HandleException(e, LuaCsMessageOrigin.LuaMod); } } else { - PrintError("LuaSetup.lua not found! Lua/LuaSetup.lua, no Lua scripts will be executed or work."); + PrintLuaError("LuaSetup.lua not found! Lua/LuaSetup.lua, no Lua scripts will be executed or work."); } executionNumber++; } - - } - - - -} - + } +} \ No newline at end of file diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsTimer.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsTimer.cs index 4aeb8d772..437c69d0a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsTimer.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsTimer.cs @@ -68,7 +68,7 @@ namespace Barotrauma } catch (Exception e) { - GameMain.LuaCs.HandleException(e, "", LuaCsSetup.ExceptionType.CSharp); + GameMain.LuaCs.HandleException(e, LuaCsMessageOrigin.CSharpMod); } timedActionsToRemove.Add(timedAction); diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsUtility.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsUtility.cs index d31f2cf2c..345d9fd6c 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsUtility.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsUtility.cs @@ -79,7 +79,7 @@ namespace Barotrauma return false; } - public static bool IsPathAllowedException(string path, bool write = true, LuaCsSetup.ExceptionType exceptionType = LuaCsSetup.ExceptionType.Both) + public static bool IsPathAllowedException(string path, bool write = true, LuaCsMessageOrigin origin = LuaCsMessageOrigin.Unknown) { if (write) { @@ -106,9 +106,9 @@ namespace Barotrauma } public static bool IsPathAllowedLuaException(string path, bool write = true) => - IsPathAllowedException(path, write, LuaCsSetup.ExceptionType.Lua); + IsPathAllowedException(path, write, LuaCsMessageOrigin.LuaMod); public static bool IsPathAllowedCsException(string path, bool write = true) => - IsPathAllowedException(path, write, LuaCsSetup.ExceptionType.CSharp); + IsPathAllowedException(path, write, LuaCsMessageOrigin.CSharpMod); public static string Read(string path) { diff --git a/Barotrauma/BarotraumaTest/LuaCs/HookPatchTests.cs b/Barotrauma/BarotraumaTest/LuaCs/HookPatchTests.cs new file mode 100644 index 000000000..9a27df57c --- /dev/null +++ b/Barotrauma/BarotraumaTest/LuaCs/HookPatchTests.cs @@ -0,0 +1,532 @@ +using Barotrauma; +using Microsoft.Xna.Framework; +using MoonSharp.Interpreter; +using System.Runtime.ExceptionServices; +using Xunit; +using Xunit.Abstractions; + +namespace TestProject.LuaCs +{ + public class HookPatchTests + { + private readonly LuaCsSetup luaCs = new(); + + public HookPatchTests(ITestOutputHelper output) + { + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + UserData.RegisterType(); + + luaCs.MessageLogger = (prefix, o) => + { + o ??= "null"; + output.WriteLine(prefix + o); + }; + luaCs.ExceptionHandler = (ex, _) => + { + // Pretend we never caught the exception in the first place + // (this allows us to preserve the stack trace) + var di = ExceptionDispatchInfo.Capture(ex); + di.Throw(); + }; + luaCs.Initialize(); + luaCs.Lua.Globals["TestValueType"] = UserData.CreateStatic(); + luaCs.Lua.Globals["InterfaceImplementingType"] = UserData.CreateStatic(); + } + + private DynValue AddPrefix(string body, string testMethod = "Run", string? patchId = null) + { + var className = typeof(T).FullName; + if (patchId != null) + { + return luaCs.Lua.DoString(@$" + return Hook.Patch('{patchId}', '{className}', '{testMethod}', function(instance, ptable) + {body} + end, Hook.HookMethodType.Before) + "); + } + else + { + return luaCs.Lua.DoString(@$" + return Hook.Patch('{className}', '{testMethod}', function(instance, ptable) + {body} + end, Hook.HookMethodType.Before) + "); + } + } + + private DynValue AddPostfix(string body, string testMethod = "Run", string? patchId = null) + { + var className = typeof(T).FullName; + if (patchId != null) + { + return luaCs.Lua.DoString(@$" + return Hook.Patch('{patchId}', '{className}', '{testMethod}', function(instance, ptable) + {body} + end, Hook.HookMethodType.After) + "); + } + else + { + return luaCs.Lua.DoString(@$" + return Hook.Patch('{className}', '{testMethod}', function(instance, ptable) + {body} + end, Hook.HookMethodType.After) + "); + } + } + + private DynValue RemovePrefix(string patchName, string testMethod = "Run") + { + var className = typeof(T).FullName; + return luaCs.Lua.DoString($@" + return Hook.RemovePatch('{patchName}', '{className}', '{testMethod}', Hook.HookMethodType.Before) + "); + } + + private DynValue RemovePostfix(string patchName, string testMethod = "Run") + { + var className = typeof(T).FullName; + return luaCs.Lua.DoString($@" + return Hook.RemovePatch('{patchName}', '{className}', '{testMethod}', Hook.HookMethodType.After) + "); + } + + public class PatchTarget1 + { + public bool ran; + + public void Run() + { + ran = true; + } + } + + [Fact] + public void TestFullMethodReplacement() + { + var target = new PatchTarget1(); + AddPrefix("ptable.PreventExecution = true"); + target.Run(); + Assert.False(target.ran); + } + + [Fact] + public void TestOverrideExistingPatch() + { + var target = new PatchTarget1(); + AddPrefix(@" + ptable.PreventExecution = true + originalPatchRan = true + ", patchId: "test"); + target.Run(); + Assert.False(target.ran); + Assert.True(luaCs.Lua.Globals["originalPatchRan"] as bool?); + + // Reset this global so we can test if the original patch ran + // after replacing it. + luaCs.Lua.Globals["originalPatchRan"] = false; + + // Replace the existing prefix, but don't prevent execution this time + AddPrefix("replacementPatchRan = true", patchId: "test"); + target.Run(); + Assert.True(target.ran); + + // Make sure the original patch didn't run + Assert.False(luaCs.Lua.Globals["originalPatchRan"] as bool?); + + // Test if the replacement patch ran + Assert.True(luaCs.Lua.Globals["replacementPatchRan"] as bool?); + } + + [Fact] + public void TestRemovePrefix() + { + var target = new PatchTarget1(); + var patchId = AddPrefix(@" + ptable.PreventExecution = true + patchRan = true + "); + target.Run(); + Assert.False(target.ran); + Assert.True(luaCs.Lua.Globals["patchRan"] as bool?); + + luaCs.Lua.Globals["patchRan"] = false; + + Assert.Equal(DataType.String, patchId.Type); + RemovePrefix(patchId.String); + target.Run(); + Assert.True(target.ran); + Assert.False(luaCs.Lua.Globals["patchRan"] as bool?); + } + + [Fact] + public void TestRemovePostfix() + { + var target = new PatchTarget1(); + var patchId = AddPostfix(@" + patchRan = true + "); + target.Run(); + Assert.True(target.ran); + Assert.True(luaCs.Lua.Globals["patchRan"] as bool?); + + target.ran = false; + luaCs.Lua.Globals["patchRan"] = false; + + Assert.Equal(DataType.String, patchId.Type); + RemovePostfix(patchId.String); + target.Run(); + Assert.True(target.ran); + Assert.False(luaCs.Lua.Globals["patchRan"] as bool?); + } + + public struct TestValueType + { + public int foo; + + public TestValueType(int foo) + { + this.foo = foo; + } + } + + public class PatchTarget2 + { + public bool ran; + + public object Run() + { + ran = true; + return 5; + } + } + + public interface IBogusInterface + { + int GetFoo(); + } + + public class InterfaceImplementingType : IBogusInterface + { + private readonly int foo; + + public InterfaceImplementingType(int foo) + { + this.foo = foo; + } + + public int GetFoo() => foo; + } + + [Fact] + public void TestReturnBoxed() + { + var target = new PatchTarget2(); + AddPrefix(@" + ptable.PreventExecution = true + return 123 + "); + var returnValue = target.Run(); + Assert.False(target.ran); + Assert.Equal(123, (int)(double)returnValue); + } + + [Fact] + public void TestReturnVoid() + { + var target = new PatchTarget2(); + // This should have no effect + AddPrefix("return"); + var returnValue = target.Run(); + Assert.True(target.ran); + Assert.Equal(5, returnValue); + } + + [Fact] + public void TestReturnNil() + { + var target = new PatchTarget2(); + // This should modify the return value to "null" + AddPostfix("return nil"); + var returnValue = target.Run(); + Assert.True(target.ran); + Assert.Null(returnValue); + } + + [Fact] + public void TestReturnValueType() + { + var target = new PatchTarget2(); + AddPostfix(@" + return TestValueType.__new(100) + "); + var returnValue = target.Run(); + Assert.True(target.ran); + Assert.IsType(returnValue); + Assert.Equal(100, ((TestValueType)returnValue).foo); + } + + public class PatchTarget3 + { + public bool ran; + + public IBogusInterface Run() + { + ran = true; + return new InterfaceImplementingType(5); + } + } + + [Fact] + public void TestReturnInterfaceImplementingType() + { + var target = new PatchTarget3(); + AddPostfix(@" + return InterfaceImplementingType.__new(100); + "); + var returnValue = target.Run()!; + Assert.True(target.ran); + Assert.Equal(100, returnValue.GetFoo()); + } + + public class PatchTarget4 + { + public bool ran; + + public void Run(int a, out string outString, ref byte refByte, string b) + { + ran = true; + outString = a + b + refByte; + } + } + + [Fact] + public void TestModifyParameters() + { + var target = new PatchTarget4(); + AddPrefix(@" + ptable['a'] = Int32(100) + ptable['b'] = 'abc' + ptable['refByte'] = Byte(4) + "); + byte refByte = 123; + target.Run(5, out var outString, ref refByte, "foo"); + Assert.True(target.ran); + Assert.Equal("100abc4", outString); + } + + public class PatchTarget5 + { + public bool ran; + + public string Run(Vector2 vec) + { + ran = true; + return vec.ToString(); + } + } + + [Fact] + public void TestParameterValueType() + { + var target = new PatchTarget5(); + AddPrefix("patchRan = true"); + var returnValue = target.Run(new Vector2(1, 2)); + Assert.True(target.ran); + Assert.True(luaCs.Lua.Globals["patchRan"] as bool?); + Assert.Equal("{X:1 Y:2}", returnValue); + } + + public class PatchTarget6 + { + public bool ran; + + public sbyte RunSByte(sbyte v) + { + ran = true; + return v; + } + + public byte RunByte(byte v) + { + ran = true; + return v; + } + + public short RunInt16(short v) + { + ran = true; + return v; + } + + public ushort RunUInt16(ushort v) + { + ran = true; + return v; + } + + public int RunInt32(int v) + { + ran = true; + return v; + } + + public uint RunUInt32(uint v) + { + ran = true; + return v; + } + + public long RunInt64(long v) + { + ran = true; + return v; + } + + public ulong RunUInt64(ulong v) + { + ran = true; + return v; + } + + public float RunSingle(float v) + { + ran = true; + return v; + } + + public double RunDouble(double v) + { + ran = true; + return v; + } + } + + [Fact] + public void TestCastPrimitiveWrapperSByte() + { + var target = new PatchTarget6(); + AddPrefix(@" + ptable['v'] = SByte(-6) + ", testMethod: nameof(PatchTarget6.RunSByte)); + var returnValue = target.RunSByte(-5); + Assert.True(target.ran); + Assert.Equal(-6, returnValue); + } + + [Fact] + public void TestCastPrimitiveWrapperByte() + { + var target = new PatchTarget6(); + AddPrefix(@" + ptable['v'] = Byte(6) + ", testMethod: nameof(PatchTarget6.RunByte)); + var returnValue = target.RunByte(5); + Assert.True(target.ran); + Assert.Equal(6, returnValue); + } + + [Fact] + public void TestCastPrimitiveWrapperInt16() + { + var target = new PatchTarget6(); + AddPrefix(@" + ptable['v'] = Int16(-25000) + ", testMethod: nameof(PatchTarget6.RunInt16)); + var returnValue = target.RunInt16(30000); + Assert.True(target.ran); + Assert.Equal(-25000, returnValue); + } + + [Fact] + public void TestCastPrimitiveWrapperUInt16() + { + var target = new PatchTarget6(); + AddPrefix(@" + ptable['v'] = UInt16(60000) + ", testMethod: nameof(PatchTarget6.RunUInt16)); + var returnValue = target.RunUInt16(50000); + Assert.True(target.ran); + Assert.Equal(60000, returnValue); + } + + [Fact] + public void TestCastPrimitiveWrapperInt32() + { + var target = new PatchTarget6(); + AddPrefix(@" + ptable['v'] = Int32('7FFFFF00', 16) + ", testMethod: nameof(PatchTarget6.RunInt32)); + var returnValue = target.RunInt32(900000); + Assert.True(target.ran); + Assert.Equal(0x7FFFFF00, returnValue); + } + + [Fact] + public void TestCastPrimitiveWrapperUInt32() + { + var target = new PatchTarget6(); + AddPrefix(@" + ptable['v'] = UInt32('AFFFFFFF', 16) + ", testMethod: nameof(PatchTarget6.RunUInt32)); + var returnValue = target.RunUInt32(300500); + Assert.True(target.ran); + Assert.Equal(0xAFFFFFFF, returnValue); + } + + [Fact] + public void TestCastPrimitiveWrapperInt64() + { + var target = new PatchTarget6(); + AddPrefix(@" + ptable['v'] = Int64('7555555555555555', 16) + ", testMethod: nameof(PatchTarget6.RunInt64)); + var returnValue = target.RunInt64(0x7FFFFFFF00000000); + Assert.True(target.ran); + Assert.Equal(0x7555555555555555, returnValue); + } + + [Fact] + public void TestCastPrimitiveWrapperUInt64() + { + var target = new PatchTarget6(); + AddPrefix(@" + ptable['v'] = UInt64('F555555555555555', 16) + ", testMethod: nameof(PatchTarget6.RunUInt64)); + var returnValue = target.RunUInt64(0xFFFFFFFF00000000); + Assert.True(target.ran); + Assert.Equal(0xF555555555555555, returnValue); + } + + [Fact] + public void TestCastPrimitiveWrapperSingle() + { + var target = new PatchTarget6(); + AddPrefix(@" + ptable['v'] = Single(123.456) + ", testMethod: nameof(PatchTarget6.RunSingle)); + var returnValue = target.RunSingle(111.111f); + Assert.True(target.ran); + Assert.Equal(123.456f, returnValue); + } + + [Fact] + public void TestCastPrimitiveWrapperDouble() + { + var target = new PatchTarget6(); + AddPrefix(@" + ptable['v'] = Double(123.456) + ", testMethod: nameof(PatchTarget6.RunDouble)); + var returnValue = target.RunDouble(111.111d); + Assert.True(target.ran); + Assert.Equal(123.456d, returnValue); + } + } +} diff --git a/Libraries/0Harmony.dll b/Libraries/0Harmony.dll deleted file mode 100644 index d6f00001f..000000000 Binary files a/Libraries/0Harmony.dll and /dev/null differ diff --git a/Libraries/MoonSharp.Interpreter.dll b/Libraries/MoonSharp.Interpreter.dll deleted file mode 100644 index 468c11545..000000000 Binary files a/Libraries/MoonSharp.Interpreter.dll and /dev/null differ diff --git a/Libraries/moonsharp b/Libraries/moonsharp new file mode 160000 index 000000000..b9fc22da9 --- /dev/null +++ b/Libraries/moonsharp @@ -0,0 +1 @@ +Subproject commit b9fc22da9e79427206e4f9ca241382aaefa03532 diff --git a/LinuxSolution.sln b/LinuxSolution.sln index 6c841ff6d..16e6b7939 100644 --- a/LinuxSolution.sln +++ b/LinuxSolution.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29201.188 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32319.34 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D32A29D8-AC7B-4189-B734-8ED9EB4120D0}" ProjectSection(SolutionItems) = preProject @@ -40,7 +40,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LinuxServer", "Barotrauma\B EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGame.Framework.Linux.NetStandard", "Libraries\MonoGame.Framework\Src\MonoGame.Framework\MonoGame.Framework.Linux.NetStandard.csproj", "{33E95A21-E071-4432-819F-AA64CF3EF3F1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinuxTest", "Barotrauma\BarotraumaTest\LinuxTest.csproj", "{F1B80D94-8BD6-48CE-8D17-BB2A5C98BCA3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LinuxTest", "Barotrauma\BarotraumaTest\LinuxTest.csproj", "{F1B80D94-8BD6-48CE-8D17-BB2A5C98BCA3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoonSharp.Interpreter.netcore", "Libraries\moonsharp\src\MoonSharp.Interpreter\_Projects\MoonSharp.Interpreter.netcore\MoonSharp.Interpreter.netcore.csproj", "{382DFA63-78FC-41AC-BA85-630960A56E5C}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution @@ -199,6 +201,18 @@ Global {F1B80D94-8BD6-48CE-8D17-BB2A5C98BCA3}.Unstable|Any CPU.Build.0 = Debug|Any CPU {F1B80D94-8BD6-48CE-8D17-BB2A5C98BCA3}.Unstable|x64.ActiveCfg = Debug|Any CPU {F1B80D94-8BD6-48CE-8D17-BB2A5C98BCA3}.Unstable|x64.Build.0 = Debug|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Debug|x64.ActiveCfg = Debug|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Debug|x64.Build.0 = Debug|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Release|Any CPU.Build.0 = Release|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Release|x64.ActiveCfg = Release|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Release|x64.Build.0 = Release|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Unstable|Any CPU.Build.0 = Debug|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Unstable|x64.ActiveCfg = Debug|Any CPU + {382DFA63-78FC-41AC-BA85-630960A56E5C}.Unstable|x64.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -217,6 +231,7 @@ Global {2B0881F6-9C67-4446-A1F2-FC042763A462} = {68B18BE6-9EE0-49DA-AE3A-4C7326F768F9} {33E95A21-E071-4432-819F-AA64CF3EF3F1} = {DE36F45F-F09E-4719-B953-00D148F7722A} {F1B80D94-8BD6-48CE-8D17-BB2A5C98BCA3} = {68B18BE6-9EE0-49DA-AE3A-4C7326F768F9} + {382DFA63-78FC-41AC-BA85-630960A56E5C} = {DE36F45F-F09E-4719-B953-00D148F7722A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {17032EAB-554B-4B44-A4F6-EFB177ACAB7A} diff --git a/MacSolution.sln b/MacSolution.sln index beaa4a347..a801ae405 100644 --- a/MacSolution.sln +++ b/MacSolution.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29201.188 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32319.34 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D32A29D8-AC7B-4189-B734-8ED9EB4120D0}" ProjectSection(SolutionItems) = preProject @@ -37,7 +37,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGame.Framework.MacOS.Ne EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Facepunch.Steamworks.Posix", "Libraries\Facepunch.Steamworks\Facepunch.Steamworks.Posix.csproj", "{F10CE3BB-26B8-446E-84D2-86D25E850F61}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MacTest", "Barotrauma\BarotraumaTest\MacTest.csproj", "{20BC9336-B439-4BF1-8B65-D587DBF421D1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MacTest", "Barotrauma\BarotraumaTest\MacTest.csproj", "{20BC9336-B439-4BF1-8B65-D587DBF421D1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoonSharp.Interpreter.netcore", "Libraries\moonsharp\src\MoonSharp.Interpreter\_Projects\MoonSharp.Interpreter.netcore\MoonSharp.Interpreter.netcore.csproj", "{40BDE83D-61D5-481C-A53E-E0F5B23881E2}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution @@ -196,6 +198,18 @@ Global {20BC9336-B439-4BF1-8B65-D587DBF421D1}.Unstable|Any CPU.Build.0 = Debug|Any CPU {20BC9336-B439-4BF1-8B65-D587DBF421D1}.Unstable|x64.ActiveCfg = Debug|Any CPU {20BC9336-B439-4BF1-8B65-D587DBF421D1}.Unstable|x64.Build.0 = Debug|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Debug|x64.ActiveCfg = Debug|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Debug|x64.Build.0 = Debug|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Release|Any CPU.Build.0 = Release|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Release|x64.ActiveCfg = Release|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Release|x64.Build.0 = Release|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Unstable|Any CPU.Build.0 = Debug|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Unstable|x64.ActiveCfg = Debug|Any CPU + {40BDE83D-61D5-481C-A53E-E0F5B23881E2}.Unstable|x64.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -214,6 +228,7 @@ Global {35DDDA7D-328D-4A5D-BCBB-2E60C830A899} = {DE36F45F-F09E-4719-B953-00D148F7722A} {F10CE3BB-26B8-446E-84D2-86D25E850F61} = {DE36F45F-F09E-4719-B953-00D148F7722A} {20BC9336-B439-4BF1-8B65-D587DBF421D1} = {DFD82BBD-8D05-403D-BEBC-F4C1CF783E18} + {40BDE83D-61D5-481C-A53E-E0F5B23881E2} = {DE36F45F-F09E-4719-B953-00D148F7722A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {17032EAB-554B-4B44-A4F6-EFB177ACAB7A} diff --git a/WindowsSolution.sln b/WindowsSolution.sln index accf6ea19..b0d437056 100644 --- a/WindowsSolution.sln +++ b/WindowsSolution.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29201.188 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32319.34 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D32A29D8-AC7B-4189-B734-8ED9EB4120D0}" ProjectSection(SolutionItems) = preProject @@ -40,90 +40,179 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XNATypes", "Libraries\XNATy EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpFont.NetStandard", "Libraries\SharpFont\Source\SharpFont\SharpFont.NetStandard.csproj", "{6911872D-40EF-400C-B0A1-9985A19ED488}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsTest", "Barotrauma\BarotraumaTest\WindowsTest.csproj", "{C7212AE2-A925-4225-A639-AE0653EF65B0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowsTest", "Barotrauma\BarotraumaTest\WindowsTest.csproj", "{C7212AE2-A925-4225-A639-AE0653EF65B0}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoonSharp.Interpreter.netcore", "Libraries\moonsharp\src\MoonSharp.Interpreter\_Projects\MoonSharp.Interpreter.netcore\MoonSharp.Interpreter.netcore.csproj", "{2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution Libraries\GameAnalytics\GA-SDK-MONO-SHARED\GA-SDK-MONO-SHARED.projitems*{95c4d59d-9be4-4278-b4f8-46c0ba1a3916}*SharedItemsImports = 5 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 + Unstable|Any CPU = Unstable|Any CPU Unstable|x64 = Unstable|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Debug|Any CPU.Build.0 = Debug|Any CPU {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Debug|x64.ActiveCfg = Debug|x64 {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Debug|x64.Build.0 = Debug|x64 + {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Release|Any CPU.Build.0 = Release|Any CPU {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Release|x64.ActiveCfg = Release|x64 {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Release|x64.Build.0 = Release|x64 + {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Unstable|Any CPU.Build.0 = Debug|Any CPU {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Unstable|x64.ActiveCfg = Release|x64 {E1BBC67C-DC2A-40E8-89F3-B57299D7B16C}.Unstable|x64.Build.0 = Release|x64 + {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Debug|Any CPU.Build.0 = Debug|Any CPU {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Debug|x64.ActiveCfg = Debug|x64 {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Debug|x64.Build.0 = Debug|x64 + {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Release|Any CPU.Build.0 = Release|Any CPU {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Release|x64.ActiveCfg = Release|x64 {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Release|x64.Build.0 = Release|x64 + {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Unstable|Any CPU.Build.0 = Debug|Any CPU {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Unstable|x64.ActiveCfg = Release|x64 {95C4D59D-9BE4-4278-B4F8-46C0BA1A3916}.Unstable|x64.Build.0 = Release|x64 + {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Debug|Any CPU.Build.0 = Debug|Any CPU {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Debug|x64.ActiveCfg = Debug|x64 {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Debug|x64.Build.0 = Debug|x64 + {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Release|Any CPU.Build.0 = Release|Any CPU {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Release|x64.ActiveCfg = Release|x64 {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Release|x64.Build.0 = Release|x64 + {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Unstable|Any CPU.Build.0 = Debug|Any CPU {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Unstable|x64.ActiveCfg = Release|x64 {AD30AE95-7BF6-4CE5-AEED-B6C30A88F139}.Unstable|x64.Build.0 = Release|x64 + {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Debug|Any CPU.Build.0 = Debug|Any CPU {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Debug|x64.ActiveCfg = Debug|x64 {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Debug|x64.Build.0 = Debug|x64 + {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Release|Any CPU.ActiveCfg = Release|Any CPU + {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Release|Any CPU.Build.0 = Release|Any CPU {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Release|x64.ActiveCfg = Release|x64 {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Release|x64.Build.0 = Release|x64 + {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Unstable|Any CPU.Build.0 = Debug|Any CPU {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Unstable|x64.ActiveCfg = Release|x64 {894D3518-A0E3-4B88-B9BF-9E1AFC3F9523}.Unstable|x64.Build.0 = Release|x64 + {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Debug|Any CPU.Build.0 = Debug|Any CPU {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Debug|x64.ActiveCfg = Debug|x64 {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Debug|x64.Build.0 = Debug|x64 + {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Release|Any CPU.Build.0 = Release|Any CPU {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Release|x64.ActiveCfg = Release|x64 {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Release|x64.Build.0 = Release|x64 + {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Unstable|Any CPU.Build.0 = Debug|Any CPU {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Unstable|x64.ActiveCfg = Release|x64 {ED2873CA-C209-4CBC-ADD4-DAA753DFEEAF}.Unstable|x64.Build.0 = Release|x64 + {978633A8-094A-4623-9B82-8533FC8BA1CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {978633A8-094A-4623-9B82-8533FC8BA1CC}.Debug|Any CPU.Build.0 = Debug|Any CPU {978633A8-094A-4623-9B82-8533FC8BA1CC}.Debug|x64.ActiveCfg = Debug|x64 {978633A8-094A-4623-9B82-8533FC8BA1CC}.Debug|x64.Build.0 = Debug|x64 + {978633A8-094A-4623-9B82-8533FC8BA1CC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {978633A8-094A-4623-9B82-8533FC8BA1CC}.Release|Any CPU.Build.0 = Release|Any CPU {978633A8-094A-4623-9B82-8533FC8BA1CC}.Release|x64.ActiveCfg = Release|x64 {978633A8-094A-4623-9B82-8533FC8BA1CC}.Release|x64.Build.0 = Release|x64 + {978633A8-094A-4623-9B82-8533FC8BA1CC}.Unstable|Any CPU.ActiveCfg = Unstable|Any CPU + {978633A8-094A-4623-9B82-8533FC8BA1CC}.Unstable|Any CPU.Build.0 = Unstable|Any CPU {978633A8-094A-4623-9B82-8533FC8BA1CC}.Unstable|x64.ActiveCfg = Unstable|x64 {978633A8-094A-4623-9B82-8533FC8BA1CC}.Unstable|x64.Build.0 = Unstable|x64 + {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Debug|Any CPU.Build.0 = Debug|Any CPU {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Debug|x64.ActiveCfg = Debug|x64 {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Debug|x64.Build.0 = Debug|x64 + {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Release|Any CPU.Build.0 = Release|Any CPU {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Release|x64.ActiveCfg = Release|x64 {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Release|x64.Build.0 = Release|x64 + {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Unstable|Any CPU.Build.0 = Debug|Any CPU {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Unstable|x64.ActiveCfg = Release|x64 {39E52316-D6C1-4D1F-95FF-37F41C9AB5A7}.Unstable|x64.Build.0 = Release|x64 + {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Debug|Any CPU.Build.0 = Debug|Any CPU {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Debug|x64.ActiveCfg = Debug|x64 {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Debug|x64.Build.0 = Debug|x64 + {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Release|Any CPU.Build.0 = Release|Any CPU {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Release|x64.ActiveCfg = Release|x64 {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Release|x64.Build.0 = Release|x64 + {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Unstable|Any CPU.Build.0 = Debug|Any CPU {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Unstable|x64.ActiveCfg = Release|x64 {D379BF8E-D696-4AB9-A27F-4D0C493BF484}.Unstable|x64.Build.0 = Release|x64 + {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Debug|Any CPU.Build.0 = Debug|Any CPU {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Debug|x64.ActiveCfg = Debug|x64 {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Debug|x64.Build.0 = Debug|x64 + {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Release|Any CPU.Build.0 = Release|Any CPU {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Release|x64.ActiveCfg = Release|x64 {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Release|x64.Build.0 = Release|x64 + {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Unstable|Any CPU.ActiveCfg = Unstable|Any CPU + {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Unstable|Any CPU.Build.0 = Unstable|Any CPU {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Unstable|x64.ActiveCfg = Unstable|x64 {47848C6E-C7A8-4EC3-96C2-3BC8A4234AFA}.Unstable|x64.Build.0 = Unstable|x64 + {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Debug|Any CPU.Build.0 = Debug|Any CPU {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Debug|x64.ActiveCfg = Debug|x64 {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Debug|x64.Build.0 = Debug|x64 + {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Release|Any CPU.Build.0 = Release|Any CPU {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Release|x64.ActiveCfg = Release|x64 {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Release|x64.Build.0 = Release|x64 + {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Unstable|Any CPU.Build.0 = Debug|Any CPU {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Unstable|x64.ActiveCfg = Release|x64 {1F318AC4-F808-4130-867F-B98DF9AA8F95}.Unstable|x64.Build.0 = Release|x64 + {6911872D-40EF-400C-B0A1-9985A19ED488}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6911872D-40EF-400C-B0A1-9985A19ED488}.Debug|Any CPU.Build.0 = Debug|Any CPU {6911872D-40EF-400C-B0A1-9985A19ED488}.Debug|x64.ActiveCfg = Debug|x64 {6911872D-40EF-400C-B0A1-9985A19ED488}.Debug|x64.Build.0 = Debug|x64 + {6911872D-40EF-400C-B0A1-9985A19ED488}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6911872D-40EF-400C-B0A1-9985A19ED488}.Release|Any CPU.Build.0 = Release|Any CPU {6911872D-40EF-400C-B0A1-9985A19ED488}.Release|x64.ActiveCfg = Release|x64 {6911872D-40EF-400C-B0A1-9985A19ED488}.Release|x64.Build.0 = Release|x64 + {6911872D-40EF-400C-B0A1-9985A19ED488}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {6911872D-40EF-400C-B0A1-9985A19ED488}.Unstable|Any CPU.Build.0 = Debug|Any CPU {6911872D-40EF-400C-B0A1-9985A19ED488}.Unstable|x64.ActiveCfg = Release|x64 {6911872D-40EF-400C-B0A1-9985A19ED488}.Unstable|x64.Build.0 = Release|x64 + {C7212AE2-A925-4225-A639-AE0653EF65B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7212AE2-A925-4225-A639-AE0653EF65B0}.Debug|Any CPU.Build.0 = Debug|Any CPU {C7212AE2-A925-4225-A639-AE0653EF65B0}.Debug|x64.ActiveCfg = Debug|Any CPU {C7212AE2-A925-4225-A639-AE0653EF65B0}.Debug|x64.Build.0 = Debug|Any CPU + {C7212AE2-A925-4225-A639-AE0653EF65B0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7212AE2-A925-4225-A639-AE0653EF65B0}.Release|Any CPU.Build.0 = Release|Any CPU {C7212AE2-A925-4225-A639-AE0653EF65B0}.Release|x64.ActiveCfg = Release|Any CPU {C7212AE2-A925-4225-A639-AE0653EF65B0}.Release|x64.Build.0 = Release|Any CPU + {C7212AE2-A925-4225-A639-AE0653EF65B0}.Unstable|Any CPU.ActiveCfg = Release|Any CPU + {C7212AE2-A925-4225-A639-AE0653EF65B0}.Unstable|Any CPU.Build.0 = Release|Any CPU {C7212AE2-A925-4225-A639-AE0653EF65B0}.Unstable|x64.ActiveCfg = Debug|Any CPU {C7212AE2-A925-4225-A639-AE0653EF65B0}.Unstable|x64.Build.0 = Debug|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Debug|x64.ActiveCfg = Debug|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Debug|x64.Build.0 = Debug|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Release|Any CPU.Build.0 = Release|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Release|x64.ActiveCfg = Release|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Release|x64.Build.0 = Release|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Unstable|Any CPU.ActiveCfg = Debug|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Unstable|Any CPU.Build.0 = Debug|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Unstable|x64.ActiveCfg = Debug|Any CPU + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED}.Unstable|x64.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -142,6 +231,7 @@ Global {1F318AC4-F808-4130-867F-B98DF9AA8F95} = {DE36F45F-F09E-4719-B953-00D148F7722A} {6911872D-40EF-400C-B0A1-9985A19ED488} = {DE36F45F-F09E-4719-B953-00D148F7722A} {C7212AE2-A925-4225-A639-AE0653EF65B0} = {78A9F0AA-5519-407A-9B72-2A09F5DF7068} + {2EEF2610-64A3-4E5D-95ED-0E181C1A34ED} = {DE36F45F-F09E-4719-B953-00D148F7722A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {17032EAB-554B-4B44-A4F6-EFB177ACAB7A} diff --git a/docs-landing-page/index.html b/docs-landing-page/index.html deleted file mode 100644 index fcb6bb06b..000000000 --- a/docs-landing-page/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - LuaCs For Barotrauma - - - - -
-
-
- -
-
-
-
-
-
- -
-
-
- - \ No newline at end of file diff --git a/docs-landing-page/landing.css b/docs-landing-page/landing.css deleted file mode 100644 index 7efcd8809..000000000 --- a/docs-landing-page/landing.css +++ /dev/null @@ -1,132 +0,0 @@ -body{ - overflow: hidden; - font-size: 100%; - background-color: #777; -} - -.common-docs{ - z-index: 1; - text-justify: auto; - position: fixed; - top: 0; - bottom: 0; - transition-property: transform; - transition-duration: 0.5s; - transition-timing-function: ease-in-out; - overflow: hidden; -} -#lua-docs{ - left: -10%; - right: 50%; -} -#cs-docs{ - right: -10%; - left: 50%; -} - -#cs-docs::before,#lua-docs::before{ - content: ""; - background: url(bg.jpg) repeat; - background-size: 80%; - background-blend-mode: luminosity; - filter: blur(2px); - position: absolute; - height: 200%; - width: 200%; -} -#lua-docs::before{ - background-color: rgba(49, 49, 135, 1); -} -#cs-docs::before{ - background-color: rgba(105, 44, 120, 1); -} - -.common-docs:hover{ - z-index: 2; - font-size: 300%; - transform: scale(1.05); -} - -.inner-bg{ - position: relative; - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; - transition-duration: 0.5s; - transition-timing-function: ease-in-out; -} -.inner-bg:hover{ - background-color: rgba(255, 255, 255, 0.35); -} - -.inner-docs{ - height: 100%; - width: 100%; - display: flex; - align-items: center; - justify-content: center; - position: relative; - background: radial-gradient(circle, #222, rgba(0, 0, 0, 0)); -} - - -@media (min-width: 80em) { - .inner-docs img{ - height: 30%; - width: auto; - } - .common-docs{ - transform: skewX(-11deg); - } - #cs-docs::before,#lua-docs::before{ - transform: skewX(11deg); - } - .common-docs:hover{ - transform: skewX(-11deg) scale(1.05); - } - .inner-docs{ - transform: skewX(11deg); - } - .inner-docs img{ - height: 30%; - width: auto; - } -} -@media (max-width: 80em) { - .common-docs{ - transform: skewX(-9deg); - } - #cs-docs::before,#lua-docs::before{ - transform: skewX(9deg); - } - .common-docs:hover{ - transform: skewX(-9deg) scale(1.05); - } - .inner-docs{ - transform: skewX(9deg); - } - .inner-docs img{ - height: 30%; - width: auto; - } -} -@media (max-width: 70em) { - .common-docs{ - transform: skewX(0deg); - } - #cs-docs::before,#lua-docs::before{ - transform: skewX(0deg); - } - .common-docs:hover{ - transform: skewX(0deg) scale(1.05); - } - .inner-docs{ - transform: skewX(0deg); - } - .inner-docs img{ - height: auto; - width: 50%; - } -} \ No newline at end of file diff --git a/docs/build_docs.bat b/docs/build_docs.bat deleted file mode 100644 index 2cc1e0904..000000000 --- a/docs/build_docs.bat +++ /dev/null @@ -1,5 +0,0 @@ -xcopy css html /Y -xcopy js html /Y -cd .. -lua B:\programming\lua\LDoc\ldoc.lua . -cd docs \ No newline at end of file diff --git a/docs/css/ldoc.css b/docs/css/ldoc.css deleted file mode 100644 index 7f4c90734..000000000 --- a/docs/css/ldoc.css +++ /dev/null @@ -1,539 +0,0 @@ - -:root { - --content-width: 100%; - --sidebar-width: 25%; - - --padding-big: 48px; - --padding-normal: 24px; - --padding-small: 16px; - --padding-tiny: 10px; - - --font-massive: 32px; - --font-huge: 24px; - --font-big: 18px; - --font-normal: 16px; - --font-tiny: 12px; - - --font-style-normal: Segoe UI, Helvetica, Arial, sans-serif; - --font-style-code: Consolas, monospace; - - --color-accent: rgb(47, 100, 74); - --color-accent-dark: rgb(33, 33, 33); - --color-white: rgb(255, 255, 255); - --color-offwhite: rgb(200, 200, 200); - --color-white-accent: rgb(203, 190, 209); - --color-black: rgb(0, 0, 0); - --color-lightgrey: rgb(160, 160, 160); - --color-background-light: rgb(245, 245, 245); - --color-background-dark: rgb(33, 33, 33); - --color-background-dark-ish: rgb(44, 44, 44); - --color-outline: rgb(149, 34, 160); - --color-good: #5190ff; -} - -* { - padding: 0; - margin: 0; - box-sizing: border-box; -} - -body { - background-color: var(--color-background-dark); - font-family: var(--font-style-normal); - - display: flex; - flex-direction: column; -} - -a { - color: inherit; - text-decoration: inherit; -} - -h1, h2, h3, h4 { - font-weight: 400; -} - -ul li { - margin-left: var(--padding-small); -} - -/* landing */ -.landing { - background-color: var(--color-accent); - color: var(--color-white); - - padding: 128px 0 128px 0; -} - -.landing h1 { - margin: 0; - padding: 0; - border: none; - - font-weight: 100; - font-size: var(--font-massive); - text-align: center; -} - -.wrapper { - padding: var(--padding-small); -} - -details { - user-select: none; -} - -details summary { - outline: none; -} - -code { - font-family: "Source Code Pro", monospace; - font-size: 85%; - white-space: pre; - tab-size: 4; - -moz-tab-size: 4; - padding: 1px 4px; - background-color: #282a36; - outline-style: solid; - outline-color: black; - outline-width: 2px; -} - -pre { - background-color: rgb(0, 0, 0, 1); - margin-top: var(--padding-small); - padding: 2px; - overflow: auto; -} - -pre code { - background-color: transparent; -} - -span.realm { - width: 14px; - height: 14px; - border-radius: 3px; - display: inline-block; - margin-right: 5px; -} - -span.realm.shared { - background: linear-gradient(45deg, #f80 0%, #f80 50%, #08f 51%, #08f 100%); -} - -span.realm.client { - background-color: #f80; -} - -span.realm.server { - background-color: #08f; -} - - -.colorful-label { - color: rgb(31, 141, 155); -} - -/* wrapper element for sidebar/content */ -main { - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: flex-start; - - width: var(--content-width); - margin: auto; -} - -/* sidebar */ -nav { - color: var(--color-offwhite); - background-color: var(--color-background-dark); - - position: fixed; - display: flex; - flex-direction: column; - - width: var(--sidebar-width); - height: 100%; -} - -/* sidebar header */ -nav header { - color: var(--color-white); - background-color: var(--color-accent); - - padding: var(--padding-small); -} - -nav header h1 { - font-size: var(--font-huge); - font-weight: 100; - text-align: center; - - margin-bottom: var(--padding-small); -} - -#search { - background-color: var(--color-accent-dark); - color: var(--color-white); - - border: none; - font-size: var(--font-normal); - outline: none; - - width: 100%; - padding: 6px; -} - -#search::placeholder { - color: var(--color-white-accent); -} - -#search::-webkit-search-cancel-button { - display: none; -} - -/* sidebar contents */ -nav section { - padding: var(--padding-small); - overflow: auto; -} - -nav section ul { - list-style-type: none; -} - -nav section::-webkit-scrollbar, -pre::-webkit-scrollbar { - width: 8px; - height: 8px; -} - -nav section::-webkit-scrollbar-track, -pre::-webkit-scrollbar-track { - background: transparent; -} - -nav section::-webkit-scrollbar-thumb { - background-color: var(--color-lightgrey); -} - -pre::-webkit-scrollbar-thumb { - background-color: var(--color-lightgrey); -} - -/* sidebar contents category */ -nav section details.category { - padding-top: var(--padding-tiny); -} - -nav section details.category > ul > li { - margin: 0; - line-height: 1.5; -} - -nav section details.category > ul > li a { - display: inline-block; - width: 90%; -} - -nav section details.category:first-of-type { - padding-top: calc(var(--padding-tiny) * -1); -} - -nav section details.category summary::-webkit-details-marker { - opacity: 0.5; - cursor: pointer; -} - -nav section details.category summary h2 { - color: var(--color-accent); - - font-size: var(--font-big); - letter-spacing: 2px; - text-transform: uppercase; - cursor: pointer; - - padding-bottom: var(--padding-tiny); -} - -/* content */ -article { - background-color: var(--color-background-dark-ish); - color: white; - width: calc(100% - var(--sidebar-width)); - min-height: 100vh; - margin-left: var(--sidebar-width); -} - -article .wrapper > *:first-child { - margin-top: 0; -} - -/* header */ -article header { - color: rgb(255, 255, 255); - background-color: var(--color-accent); - padding: var(--padding-tiny); -} - -article header h1 { - border-bottom: 1px solid rgba(255, 255, 255, 0.25); - padding-bottom: 8px; - font-family: var(--font-style-code); - margin: 0; -} - -article header h2 { - padding-top: var(--padding-tiny); - margin: 0; - font-size: var(--font-normal); - font-weight: normal; -} - -article header.module a { - color: white !important; - text-decoration: underline; -} - -details.category > summary { - list-style: none; -} - -details.category > summary::-webkit-details-marker { - display: none; -} - -article h1 { - font-size: 28px; - font-weight: 600; - border-bottom: 1px solid rgba(0, 0, 0, 0.25); - margin-top: 24px; - margin-bottom: 16px; - padding-bottom: 8px; -} - -article h2 { - font-size: 20px; - font-weight: 600; - margin-top: 12px; -} - -article h3 { - color: var(--color-good); - margin-top: var(--padding-tiny); - text-transform: uppercase; -} - -article p { - margin-top: var(--padding-small); -} - -article p a, -article ul li a, -article h1 a, -article h2 a { - color: var(--color-good); - font-weight: 600; -} - -article h1.title { - color: rgb(255, 255, 255); - background-color: var(--color-accent); - margin-top: var(--padding-small); - margin-bottom: 0; - padding: var(--padding-tiny); - - font-size: var(--font-big); - font-weight: 100; - letter-spacing: 2px; - text-transform: uppercase; -} - -a.reference { - color: var(--color-good); - float: right; - margin-top: 8px; - padding-left: 8px; - font-size: 14px; - font-weight: 600; -} - -.notice { - --color-notice-background: var(--color-accent); - --color-notice-text: var(--color-notice-background); - - margin-top: var(--padding-tiny); - border: 2px solid var(--color-notice-background); -} - -.notice.error { - --color-notice-background: rgb(194, 52, 130); -} - -.notice.warning { - --color-notice-background: rgb(224, 169, 112); - --color-notice-text: rgb(167, 104, 37); -} - -.notice .title { - color: var(--color-white); - background-color: var(--color-notice-background); - - padding: var(--padding-tiny); - font-size: var(--font-normal); - - text-transform: uppercase; - letter-spacing: 2px; -} - -.notice p { - color: var(--color-notice-text); - - margin: 0 !important; - padding: var(--padding-tiny); -} - -/* function/table */ -.method { - display: flex; - flex-flow: column; - padding: var(--padding-tiny); - margin-top: var(--padding-small); -} - -.method header { - color: white; - background-color: inherit; - padding: 0; - order: -1; -} - -.method header .anchor { - color: inherit; - text-decoration: inherit; -} - -.method:target { - background-color: var(--color-background-dark); - - outline: solid; - outline-width: 1px; - outline-color: var(--color-accent); -} - -.method header:target { - background-color: var(--color-accent); -} - -.method header h1 { - font-family: "Source Code Pro", monospace; - padding-bottom: var(--padding-tiny); - border-bottom: 1px solid var(--color-accent); - font-size: 20px; -} - -.method header p:first-of-type { - margin-top: var(--padding-tiny); -} - -.method h3 { - color: var(--color-good); - font-size: var(--font-normal); - letter-spacing: 2px; - text-transform: uppercase; -} - -.method pre { - margin-top: var(--padding-tiny); -} - -@media only screen and (max-width: 1100px) { - main nav { - position: inherit; - } - - main article { - margin-left: 0; - } -} - -.method ul { - margin-top: var(--padding-tiny); - background-color: inherit; -} - -.method ul li { - list-style: none; - margin: 4px 0 0 var(--padding-normal); -} - -.method ul li:first-of-type { - margin-top: 0; -} - -.method ul li p { - margin: 4px 0 0 var(--padding-normal); -} - -.method ul li pre { - margin: 4px 0 0 var(--padding-normal); -} - -.method ul li a { - color: rgb(115, 53, 142); - font-weight: 600; -} - -/* we have to manually specify these instead of making a shared class since you cannot customize the parameter class in ldoc */ -.parameter, .type, .default { - display: inline-block; - color: rgb(255, 255, 255) !important; - - padding: 4px; - font-size: 14px; - font-family: "Source Code Pro", monospace; -} - -.parameter { - background-color: rgb(115, 53, 142); -} - -.type { - background-color: rgb(31, 141, 155); -} - -a.type { - font-weight: 300 !important; - text-decoration: underline; -} - -.default { - background-color: rgb(193, 114, 11); -} - -.type a { - padding: 0; -} - -.or { - color: rgba(115, 53, 142, 0.5); - background-color: inherit; - - width: calc(100% - 32px); - height: 8px; - margin: 0 0 8px 32px; - - text-align: center; - font-weight: 600; - border-bottom: 1px solid rgba(115, 53, 142, 0.5); -} - -.or span { - background-color: inherit; - padding: 0 8px 0 8px; -} diff --git a/docs/http_server.bat b/docs/http_server.bat deleted file mode 100644 index e57abb414..000000000 --- a/docs/http_server.bat +++ /dev/null @@ -1 +0,0 @@ -py -m http.server -d html \ No newline at end of file diff --git a/docs/js/app.js b/docs/js/app.js deleted file mode 100644 index ce0cee1ba..000000000 --- a/docs/js/app.js +++ /dev/null @@ -1,168 +0,0 @@ - -const skippedCategories = ["manual"]; - -class Node -{ - constructor(name, element, expandable, noAutoCollapse, children = []) - { - this.name = name; - this.element = element; - this.expandable = expandable; - this.noAutoCollapse = noAutoCollapse; - this.children = children; - } - - AddChild(name, element, expandable, noAutoCollapse, children) - { - let newNode = new Node(name, element, expandable, noAutoCollapse, children); - this.children.push(newNode); - - return newNode; - } -} - -class SearchManager -{ - constructor(input, contents) - { - this.input = input; - this.input.addEventListener("input", event => - { - this.OnInputUpdated(this.input.value.toLowerCase().replace(/:/g, ".")); - }); - - // setup search tree - this.tree = new Node("", document.createElement("null"), true, true); - this.entries = {}; - - const categoryElements = contents.querySelectorAll(".category"); - - // iterate each kind (hooks/libraries/classes/etc) - for (const category of categoryElements) - { - const nameElement = category.querySelector(":scope > summary > h2"); - - if (!nameElement) - { - continue; - } - - const categoryName = nameElement.textContent.trim().toLowerCase(); - - if (skippedCategories.includes(categoryName)) - { - continue; - } - - let categoryNode = this.tree.AddChild(categoryName, category, true, true); - const sectionElements = category.querySelectorAll(":scope > ul > li"); - - for (const section of sectionElements) - { - const entryElements = section.querySelectorAll(":scope > details > ul > li > a"); - const sectionName = section.querySelector(":scope > details > summary > a") - .textContent - .trim() - .toLowerCase(); - - let sectionNode = categoryNode.AddChild(sectionName, section.querySelector(":scope > details"), true); - - for (let i = 0; i < entryElements.length; i++) - { - const entryElement = entryElements[i]; - const entryName = entryElement.textContent.trim().toLowerCase(); - - sectionNode.AddChild(sectionName + "." + entryName, entryElement.parentElement); - } - } - } - } - - ResetVisibility(current) - { - current.element.style.display = ""; - - if (current.noAutoCollapse) - { - current.element.open = true; - } - else if (current.expandable) - { - current.element.open = false; - } - - for (let node of current.children) - { - this.ResetVisibility(node); - } - } - - Search(input, current) - { - let matched = false; - - if (current.name.indexOf(input) != -1) - { - matched = true; - } - - for (let node of current.children) - { - let childMatched = this.Search(input, node); - matched = matched || childMatched; - } - - if (matched) - { - current.element.style.display = ""; - - if (current.expandable) - { - current.element.open = true; - } - } - else - { - current.element.style.display = "none"; - - if (current.expandable) - { - current.element.open = false; - } - } - - return matched; - } - - OnInputUpdated(input) - { - if (input.length <= 1) - { - this.ResetVisibility(this.tree); - return; - } - - this.Search(input, this.tree); - } -} - -window.onload = function() -{ - const openDetails = document.querySelector(".category > ul > li > details[open]"); - - if (openDetails) - { - openDetails.scrollIntoView(); - } -} - -document.addEventListener("DOMContentLoaded", function() -{ - const searchInput = document.getElementById("search"); - const contents = document.querySelector("body > main > nav > section"); - - if (searchInput && contents) - { - new SearchManager(searchInput, contents); - } -}); diff --git a/docs/lua/generated/Affliction.lua b/docs/lua/generated/Affliction.lua deleted file mode 100644 index 111690a3b..000000000 --- a/docs/lua/generated/Affliction.lua +++ /dev/null @@ -1,262 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.Affliction -]] --- @code Affliction --- @pragma nostrip -local Affliction = {} - ---- Serialize --- @realm shared --- @tparam XElement element -function Serialize(element) end - ---- Deserialize --- @realm shared --- @tparam XElement element -function Deserialize(element) end - ---- CreateMultiplied --- @realm shared --- @tparam number multiplier --- @treturn Affliction -function CreateMultiplied(multiplier) end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- GetActiveEffect --- @realm shared --- @treturn Effect -function GetActiveEffect() end - ---- GetVitalityDecrease --- @realm shared --- @tparam CharacterHealth characterHealth --- @treturn number -function GetVitalityDecrease(characterHealth) end - ---- GetVitalityDecrease --- @realm shared --- @tparam CharacterHealth characterHealth --- @tparam number strength --- @treturn number -function GetVitalityDecrease(characterHealth, strength) end - ---- GetScreenGrainStrength --- @realm shared --- @treturn number -function GetScreenGrainStrength() end - ---- GetScreenDistortStrength --- @realm shared --- @treturn number -function GetScreenDistortStrength() end - ---- GetRadialDistortStrength --- @realm shared --- @treturn number -function GetRadialDistortStrength() end - ---- GetChromaticAberrationStrength --- @realm shared --- @treturn number -function GetChromaticAberrationStrength() end - ---- GetAfflictionOverlayMultiplier --- @realm shared --- @treturn number -function GetAfflictionOverlayMultiplier() end - ---- GetFaceTint --- @realm shared --- @treturn Color -function GetFaceTint() end - ---- GetBodyTint --- @realm shared --- @treturn Color -function GetBodyTint() end - ---- GetScreenBlurStrength --- @realm shared --- @treturn number -function GetScreenBlurStrength() end - ---- GetSkillMultiplier --- @realm shared --- @treturn number -function GetSkillMultiplier() end - ---- CalculateDamagePerSecond --- @realm shared --- @tparam number currentVitalityDecrease -function CalculateDamagePerSecond(currentVitalityDecrease) end - ---- GetResistance --- @realm shared --- @tparam Identifier afflictionId --- @treturn number -function GetResistance(afflictionId) end - ---- GetSpeedMultiplier --- @realm shared --- @treturn number -function GetSpeedMultiplier() end - ---- GetStatValue --- @realm shared --- @tparam StatTypes statType --- @treturn number -function GetStatValue(statType) end - ---- HasFlag --- @realm shared --- @tparam AbilityFlags flagType --- @treturn bool -function HasFlag(flagType) end - ---- Update --- @realm shared --- @tparam CharacterHealth characterHealth --- @tparam Limb targetLimb --- @tparam number deltaTime -function Update(characterHealth, targetLimb, deltaTime) end - ---- ApplyStatusEffects --- @realm shared --- @tparam function type --- @tparam number deltaTime --- @tparam CharacterHealth characterHealth --- @tparam Limb targetLimb -function ApplyStatusEffects(type, deltaTime, characterHealth, targetLimb) end - ---- ApplyStatusEffect --- @realm shared --- @tparam function type --- @tparam StatusEffect statusEffect --- @tparam number deltaTime --- @tparam CharacterHealth characterHealth --- @tparam Limb targetLimb -function ApplyStatusEffect(type, statusEffect, deltaTime, characterHealth, targetLimb) end - ---- SetStrength --- @realm shared --- @tparam number strength -function SetStrength(strength) end - ---- ShouldShowIcon --- @realm shared --- @tparam Character afflictedCharacter --- @treturn bool -function ShouldShowIcon(afflictedCharacter) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Name, Field of type string --- @realm shared --- @string Name - ---- --- SerializableProperties, Field of type table --- @realm shared --- @table SerializableProperties - ---- --- PendingAdditionStrength, Field of type number --- @realm shared --- @number PendingAdditionStrength - ---- --- AdditionStrength, Field of type number --- @realm shared --- @number AdditionStrength - ---- --- Strength, Field of type number --- @realm shared --- @number Strength - ---- --- NonClampedStrength, Field of type number --- @realm shared --- @number NonClampedStrength - ---- --- Identifier, Field of type Identifier --- @realm shared --- @Identifier Identifier - ---- --- Probability, Field of type number --- @realm shared --- @number Probability - ---- --- Prefab, Field of type AfflictionPrefab --- @realm shared --- @AfflictionPrefab Prefab - ---- --- DamagePerSecond, Field of type number --- @realm shared --- @number DamagePerSecond - ---- --- DamagePerSecondTimer, Field of type number --- @realm shared --- @number DamagePerSecondTimer - ---- --- PreviousVitalityDecrease, Field of type number --- @realm shared --- @number PreviousVitalityDecrease - ---- --- StrengthDiminishMultiplier, Field of type number --- @realm shared --- @number StrengthDiminishMultiplier - ---- --- MultiplierSource, Field of type Affliction --- @realm shared --- @Affliction MultiplierSource - ---- --- PeriodicEffectTimers, Field of type table --- @realm shared --- @table PeriodicEffectTimers - ---- --- AppliedAsSuccessfulTreatmentTime, Field of type number --- @realm shared --- @number AppliedAsSuccessfulTreatmentTime - ---- --- AppliedAsFailedTreatmentTime, Field of type number --- @realm shared --- @number AppliedAsFailedTreatmentTime - ---- --- Source, Field of type Character --- @realm shared --- @Character Source - diff --git a/docs/lua/generated/AfflictionPrefab.lua b/docs/lua/generated/AfflictionPrefab.lua deleted file mode 100644 index cae17b477..000000000 --- a/docs/lua/generated/AfflictionPrefab.lua +++ /dev/null @@ -1,299 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.AfflictionPrefab -]] --- @code AfflictionPrefab --- @pragma nostrip -local AfflictionPrefab = {} - ---- Dispose --- @realm shared -function Dispose() end - ---- LoadAllEffects --- @realm shared -function AfflictionPrefab.LoadAllEffects() end - ---- ClearAllEffects --- @realm shared -function AfflictionPrefab.ClearAllEffects() end - ---- LoadEffects --- @realm shared -function LoadEffects() end - ---- ClearEffects --- @realm shared -function ClearEffects() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Instantiate --- @realm shared --- @tparam number strength --- @tparam Character source --- @treturn Affliction -function Instantiate(strength, source) end - ---- GetActiveEffect --- @realm shared --- @tparam number currentStrength --- @treturn Effect -function GetActiveEffect(currentStrength) end - ---- GetTreatmentSuitability --- @realm shared --- @tparam Item item --- @treturn number -function GetTreatmentSuitability(item) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- AfflictionPrefab.InternalDamage, Field of type AfflictionPrefab --- @realm shared --- @AfflictionPrefab AfflictionPrefab.InternalDamage - ---- --- AfflictionPrefab.ImpactDamage, Field of type AfflictionPrefab --- @realm shared --- @AfflictionPrefab AfflictionPrefab.ImpactDamage - ---- --- AfflictionPrefab.Bleeding, Field of type AfflictionPrefab --- @realm shared --- @AfflictionPrefab AfflictionPrefab.Bleeding - ---- --- AfflictionPrefab.Burn, Field of type AfflictionPrefab --- @realm shared --- @AfflictionPrefab AfflictionPrefab.Burn - ---- --- AfflictionPrefab.OxygenLow, Field of type AfflictionPrefab --- @realm shared --- @AfflictionPrefab AfflictionPrefab.OxygenLow - ---- --- AfflictionPrefab.Bloodloss, Field of type AfflictionPrefab --- @realm shared --- @AfflictionPrefab AfflictionPrefab.Bloodloss - ---- --- AfflictionPrefab.Pressure, Field of type AfflictionPrefab --- @realm shared --- @AfflictionPrefab AfflictionPrefab.Pressure - ---- --- AfflictionPrefab.Stun, Field of type AfflictionPrefab --- @realm shared --- @AfflictionPrefab AfflictionPrefab.Stun - ---- --- AfflictionPrefab.RadiationSickness, Field of type AfflictionPrefab --- @realm shared --- @AfflictionPrefab AfflictionPrefab.RadiationSickness - ---- --- AfflictionPrefab.List, Field of type Enumerable --- @realm shared --- @Enumerable AfflictionPrefab.List - ---- --- Effects, Field of type Enumerable --- @realm shared --- @Enumerable Effects - ---- --- PeriodicEffects, Field of type IList`1 --- @realm shared --- @IList`1 PeriodicEffects - ---- --- TreatmentSuitability, Field of type Enumerable --- @realm shared --- @Enumerable TreatmentSuitability - ---- --- UintIdentifier, Field of type number --- @realm shared --- @number UintIdentifier - ---- --- ContentPackage, Field of type ContentPackage --- @realm shared --- @ContentPackage ContentPackage - ---- --- FilePath, Field of type ContentPath --- @realm shared --- @ContentPath FilePath - ---- --- AfflictionType, Field of type Identifier --- @realm shared --- @Identifier AfflictionType - ---- --- LimbSpecific, Field of type bool --- @realm shared --- @bool LimbSpecific - ---- --- IndicatorLimb, Field of type LimbType --- @realm shared --- @LimbType IndicatorLimb - ---- --- Name, Field of type LocalizedString --- @realm shared --- @LocalizedString Name - ---- --- Description, Field of type LocalizedString --- @realm shared --- @LocalizedString Description - ---- --- TranslationIdentifier, Field of type Identifier --- @realm shared --- @Identifier TranslationIdentifier - ---- --- IsBuff, Field of type bool --- @realm shared --- @bool IsBuff - ---- --- HealableInMedicalClinic, Field of type bool --- @realm shared --- @bool HealableInMedicalClinic - ---- --- HealCostMultiplier, Field of type number --- @realm shared --- @number HealCostMultiplier - ---- --- BaseHealCost, Field of type number --- @realm shared --- @number BaseHealCost - ---- --- CauseOfDeathDescription, Field of type LocalizedString --- @realm shared --- @LocalizedString CauseOfDeathDescription - ---- --- SelfCauseOfDeathDescription, Field of type LocalizedString --- @realm shared --- @LocalizedString SelfCauseOfDeathDescription - ---- --- ActivationThreshold, Field of type number --- @realm shared --- @number ActivationThreshold - ---- --- ShowIconThreshold, Field of type number --- @realm shared --- @number ShowIconThreshold - ---- --- ShowIconToOthersThreshold, Field of type number --- @realm shared --- @number ShowIconToOthersThreshold - ---- --- MaxStrength, Field of type number --- @realm shared --- @number MaxStrength - ---- --- GrainBurst, Field of type number --- @realm shared --- @number GrainBurst - ---- --- ShowInHealthScannerThreshold, Field of type number --- @realm shared --- @number ShowInHealthScannerThreshold - ---- --- TreatmentThreshold, Field of type number --- @realm shared --- @number TreatmentThreshold - ---- --- KarmaChangeOnApplied, Field of type number --- @realm shared --- @number KarmaChangeOnApplied - ---- --- BurnOverlayAlpha, Field of type number --- @realm shared --- @number BurnOverlayAlpha - ---- --- DamageOverlayAlpha, Field of type number --- @realm shared --- @number DamageOverlayAlpha - ---- --- AchievementOnRemoved, Field of type Identifier --- @realm shared --- @Identifier AchievementOnRemoved - ---- --- Icon, Field of type Sprite --- @realm shared --- @Sprite Icon - ---- --- IconColors, Field of type Color[] --- @realm shared --- @Color[] IconColors - ---- --- AfflictionOverlay, Field of type Sprite --- @realm shared --- @Sprite AfflictionOverlay - ---- --- AfflictionOverlayAlphaIsLinear, Field of type bool --- @realm shared --- @bool AfflictionOverlayAlphaIsLinear - ---- --- AfflictionPrefab.Prefabs, Field of type PrefabCollection`1 --- @realm shared --- @PrefabCollection`1 AfflictionPrefab.Prefabs - ---- --- Identifier, Field of type Identifier --- @realm shared --- @Identifier Identifier - ---- --- ContentFile, Field of type ContentFile --- @realm shared --- @ContentFile ContentFile - diff --git a/docs/lua/generated/AnimController.lua b/docs/lua/generated/AnimController.lua deleted file mode 100644 index 7348c574a..000000000 --- a/docs/lua/generated/AnimController.lua +++ /dev/null @@ -1,591 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.AnimController -]] --- @code AnimController --- @pragma nostrip -local AnimController = {} - ---- UpdateAnim --- @realm shared --- @tparam number deltaTime -function UpdateAnim(deltaTime) end - ---- DragCharacter --- @realm shared --- @tparam Character target --- @tparam number deltaTime -function DragCharacter(target, deltaTime) end - ---- GetSpeed --- @realm shared --- @tparam AnimationType type --- @treturn number -function GetSpeed(type) end - ---- GetCurrentSpeed --- @realm shared --- @tparam bool useMaxSpeed --- @treturn number -function GetCurrentSpeed(useMaxSpeed) end - ---- GetAnimationParamsFromType --- @realm shared --- @tparam AnimationType type --- @treturn AnimationParams -function GetAnimationParamsFromType(type) end - ---- GetHeightFromFloor --- @realm shared --- @treturn number -function GetHeightFromFloor() end - ---- UpdateUseItem --- @realm shared --- @tparam bool allowMovement --- @tparam Vector2 handWorldPos -function UpdateUseItem(allowMovement, handWorldPos) end - ---- Grab --- @realm shared --- @tparam Vector2 rightHandPos --- @tparam Vector2 leftHandPos -function Grab(rightHandPos, leftHandPos) end - ---- HoldItem --- @realm shared --- @tparam number deltaTime --- @tparam Item item --- @tparam Vector2[] handlePos --- @tparam Vector2 holdPos --- @tparam Vector2 aimPos --- @tparam bool aim --- @tparam number holdAngle --- @tparam number itemAngleRelativeToHoldAngle --- @tparam bool aimMelee -function HoldItem(deltaTime, item, handlePos, holdPos, aimPos, aim, holdAngle, itemAngleRelativeToHoldAngle, aimMelee) end - ---- HandIK --- @realm shared --- @tparam Limb hand --- @tparam Vector2 pos --- @tparam number armTorque --- @tparam number handTorque --- @tparam number maxAngularVelocity -function HandIK(hand, pos, armTorque, handTorque, maxAngularVelocity) end - ---- ApplyPose --- @realm shared --- @tparam Vector2 leftHandPos --- @tparam Vector2 rightHandPos --- @tparam Vector2 leftFootPos --- @tparam Vector2 rightFootPos --- @tparam number footMoveForce -function ApplyPose(leftHandPos, rightHandPos, leftFootPos, rightFootPos, footMoveForce) end - ---- ApplyTestPose --- @realm shared -function ApplyTestPose() end - ---- Recreate --- @realm shared --- @tparam RagdollParams ragdollParams -function Recreate(ragdollParams) end - ---- GetLimb --- @realm shared --- @tparam LimbType limbType --- @tparam bool excludeSevered --- @treturn Limb -function GetLimb(limbType, excludeSevered) end - ---- GetMouthPosition --- @realm shared --- @treturn Nullable`1 -function GetMouthPosition() end - ---- GetColliderBottom --- @realm shared --- @treturn Vector2 -function GetColliderBottom() end - ---- FindLowestLimb --- @realm shared --- @treturn Limb -function FindLowestLimb() end - ---- ReleaseStuckLimbs --- @realm shared -function ReleaseStuckLimbs() end - ---- HideAndDisable --- @realm shared --- @tparam LimbType limbType --- @tparam number duration --- @tparam bool ignoreCollisions -function HideAndDisable(limbType, duration, ignoreCollisions) end - ---- RestoreTemporarilyDisabled --- @realm shared -function RestoreTemporarilyDisabled() end - ---- Remove --- @realm shared -function Remove() end - ---- SubtractMass --- @realm shared --- @tparam Limb limb -function SubtractMass(limb) end - ---- SaveRagdoll --- @realm shared --- @tparam string fileNameWithoutExtension -function SaveRagdoll(fileNameWithoutExtension) end - ---- ResetRagdoll --- @realm shared --- @tparam bool forceReload -function ResetRagdoll(forceReload) end - ---- ResetJoints --- @realm shared -function ResetJoints() end - ---- ResetLimbs --- @realm shared -function ResetLimbs() end - ---- AddJoint --- @realm shared --- @tparam JointParams jointParams -function AddJoint(jointParams) end - ---- AddLimb --- @realm shared --- @tparam Limb limb -function AddLimb(limb) end - ---- RemoveLimb --- @realm shared --- @tparam Limb limb -function RemoveLimb(limb) end - ---- OnLimbCollision --- @realm shared --- @tparam Fixture f1 --- @tparam Fixture f2 --- @tparam Contact contact --- @treturn bool -function OnLimbCollision(f1, f2, contact) end - ---- SeverLimbJoint --- @realm shared --- @tparam LimbJoint limbJoint --- @treturn bool -function SeverLimbJoint(limbJoint) end - ---- Flip --- @realm shared -function Flip() end - ---- GetCenterOfMass --- @realm shared --- @treturn Vector2 -function GetCenterOfMass() end - ---- MoveLimb --- @realm shared --- @tparam Limb limb --- @tparam Vector2 pos --- @tparam number amount --- @tparam bool pullFromCenter -function MoveLimb(limb, pos, amount, pullFromCenter) end - ---- ResetPullJoints --- @realm shared -function ResetPullJoints() end - ---- FindHull --- @realm shared --- @tparam Nullable`1 worldPosition --- @tparam bool setSubmarine -function FindHull(worldPosition, setSubmarine) end - ---- Teleport --- @realm shared --- @tparam Vector2 moveAmount --- @tparam Vector2 velocityChange --- @tparam bool detachProjectiles -function Teleport(moveAmount, velocityChange, detachProjectiles) end - ---- Update --- @realm shared --- @tparam number deltaTime --- @tparam Camera cam -function Update(deltaTime, cam) end - ---- ForceRefreshFloorY --- @realm shared -function ForceRefreshFloorY() end - ---- GetSurfaceY --- @realm shared --- @treturn number -function GetSurfaceY() end - ---- SetPosition --- @realm shared --- @tparam Vector2 simPosition --- @tparam bool lerp --- @tparam bool ignorePlatforms --- @tparam bool forceMainLimbToCollider --- @tparam bool detachProjectiles -function SetPosition(simPosition, lerp, ignorePlatforms, forceMainLimbToCollider, detachProjectiles) end - ---- Hang --- @realm shared -function Hang() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- RightHandIKPos, Field of type Vector2 --- @realm shared --- @Vector2 RightHandIKPos - ---- --- LeftHandIKPos, Field of type Vector2 --- @realm shared --- @Vector2 LeftHandIKPos - ---- --- IsAiming, Field of type bool --- @realm shared --- @bool IsAiming - ---- --- IsAimingMelee, Field of type bool --- @realm shared --- @bool IsAimingMelee - ---- --- ArmLength, Field of type number --- @realm shared --- @number ArmLength - ---- --- WalkParams, Field of type GroundedMovementParams --- @realm shared --- @GroundedMovementParams WalkParams - ---- --- RunParams, Field of type GroundedMovementParams --- @realm shared --- @GroundedMovementParams RunParams - ---- --- SwimSlowParams, Field of type SwimParams --- @realm shared --- @SwimParams SwimSlowParams - ---- --- SwimFastParams, Field of type SwimParams --- @realm shared --- @SwimParams SwimFastParams - ---- --- CurrentAnimationParams, Field of type AnimationParams --- @realm shared --- @AnimationParams CurrentAnimationParams - ---- --- ForceSelectAnimationType, Field of type AnimationType --- @realm shared --- @AnimationType ForceSelectAnimationType - ---- --- CurrentGroundedParams, Field of type GroundedMovementParams --- @realm shared --- @GroundedMovementParams CurrentGroundedParams - ---- --- CurrentSwimParams, Field of type SwimParams --- @realm shared --- @SwimParams CurrentSwimParams - ---- --- CanWalk, Field of type bool --- @realm shared --- @bool CanWalk - ---- --- IsMovingBackwards, Field of type bool --- @realm shared --- @bool IsMovingBackwards - ---- --- IsMovingFast, Field of type bool --- @realm shared --- @bool IsMovingFast - ---- --- AllAnimParams, Field of type table --- @realm shared --- @table AllAnimParams - ---- --- AimSourceWorldPos, Field of type Vector2 --- @realm shared --- @Vector2 AimSourceWorldPos - ---- --- AimSourcePos, Field of type Vector2 --- @realm shared --- @Vector2 AimSourcePos - ---- --- AimSourceSimPos, Field of type Vector2 --- @realm shared --- @Vector2 AimSourceSimPos - ---- --- HeadPosition, Field of type Nullable`1 --- @realm shared --- @Nullable`1 HeadPosition - ---- --- TorsoPosition, Field of type Nullable`1 --- @realm shared --- @Nullable`1 TorsoPosition - ---- --- HeadAngle, Field of type Nullable`1 --- @realm shared --- @Nullable`1 HeadAngle - ---- --- TorsoAngle, Field of type Nullable`1 --- @realm shared --- @Nullable`1 TorsoAngle - ---- --- StepSize, Field of type Nullable`1 --- @realm shared --- @Nullable`1 StepSize - ---- --- AnimationTestPose, Field of type bool --- @realm shared --- @bool AnimationTestPose - ---- --- WalkPos, Field of type number --- @realm shared --- @number WalkPos - ---- --- IsAboveFloor, Field of type bool --- @realm shared --- @bool IsAboveFloor - ---- --- RagdollParams, Field of type RagdollParams --- @realm shared --- @RagdollParams RagdollParams - ---- --- Limbs, Field of type Limb[] --- @realm shared --- @Limb[] Limbs - ---- --- HasMultipleLimbsOfSameType, Field of type bool --- @realm shared --- @bool HasMultipleLimbsOfSameType - ---- --- Frozen, Field of type bool --- @realm shared --- @bool Frozen - ---- --- Character, Field of type Character --- @realm shared --- @Character Character - ---- --- OnGround, Field of type bool --- @realm shared --- @bool OnGround - ---- --- ColliderHeightFromFloor, Field of type number --- @realm shared --- @number ColliderHeightFromFloor - ---- --- IsStuck, Field of type bool --- @realm shared --- @bool IsStuck - ---- --- Collider, Field of type PhysicsBody --- @realm shared --- @PhysicsBody Collider - ---- --- ColliderIndex, Field of type number --- @realm shared --- @number ColliderIndex - ---- --- FloorY, Field of type number --- @realm shared --- @number FloorY - ---- --- Mass, Field of type number --- @realm shared --- @number Mass - ---- --- MainLimb, Field of type Limb --- @realm shared --- @Limb MainLimb - ---- --- WorldPosition, Field of type Vector2 --- @realm shared --- @Vector2 WorldPosition - ---- --- SimplePhysicsEnabled, Field of type bool --- @realm shared --- @bool SimplePhysicsEnabled - ---- --- TargetMovement, Field of type Vector2 --- @realm shared --- @Vector2 TargetMovement - ---- --- ImpactTolerance, Field of type number --- @realm shared --- @number ImpactTolerance - ---- --- Draggable, Field of type bool --- @realm shared --- @bool Draggable - ---- --- CanEnterSubmarine, Field of type bool --- @realm shared --- @bool CanEnterSubmarine - ---- --- Dir, Field of type number --- @realm shared --- @number Dir - ---- --- Direction, Field of type Direction --- @realm shared --- @Direction Direction - ---- --- InWater, Field of type bool --- @realm shared --- @bool InWater - ---- --- HeadInWater, Field of type bool --- @realm shared --- @bool HeadInWater - ---- --- CurrentHull, Field of type Hull --- @realm shared --- @Hull CurrentHull - ---- --- IgnorePlatforms, Field of type bool --- @realm shared --- @bool IgnorePlatforms - ---- --- IsFlipped, Field of type bool --- @realm shared --- @bool IsFlipped - ---- --- BodyInRest, Field of type bool --- @realm shared --- @bool BodyInRest - ---- --- Invalid, Field of type bool --- @realm shared --- @bool Invalid - ---- --- IsHanging, Field of type bool --- @realm shared --- @bool IsHanging - ---- --- Anim, Field of type Animation --- @realm shared --- @Animation Anim - ---- --- LimbJoints, Field of type LimbJoint[] --- @realm shared --- @LimbJoint[] LimbJoints - ---- --- movement, Field of type Vector2 --- @realm shared --- @Vector2 movement - ---- --- Stairs, Field of type Structure --- @realm shared --- @Structure Stairs - ---- --- TargetDir, Field of type Direction --- @realm shared --- @Direction TargetDir - ---- --- forceStanding, Field of type bool --- @realm shared --- @bool forceStanding - ---- --- forceNotStanding, Field of type bool --- @realm shared --- @bool forceNotStanding - diff --git a/docs/lua/generated/Character.lua b/docs/lua/generated/Character.lua deleted file mode 100644 index 5dfe4cfaa..000000000 --- a/docs/lua/generated/Character.lua +++ /dev/null @@ -1,1730 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma Character class with some additional functions and fields - -Barotrauma source code: [Character.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs) -]] --- @code Character --- @pragma nostrip - -local Character = {} - --- @remove function Character.Create(characterInfo, position, seed, id, isRemotePlayer, hasAi, ragdoll) end --- @remove function TeleportTo(worldPos) end --- @remove Character.CharacterList - ---- Creates a Character using CharacterInfo. --- @realm server --- @tparam CharacterInfo characterInfo --- @tparam Vector2 position --- @tparam string seed --- @tparam number id --- @tparam bool isRemotePlayer --- @tparam bool hasAi --- @tparam RagdollParams ragdoll --- @treturn Character --- @usage --- local vsauce = CharacterInfo("human", "custom name") --- local character = Character.Create(vsauce, Vector2(0, 0), "some random characters") --- print(character) -function Character.Create(characterInfo, position, seed, id, isRemotePlayer, hasAi, ragdoll) end - - ---- Teleports a character to a position. --- @realm server --- @tparam Vector2 position --- @usage --- Character.CharacterList[1].TeleportTo(Vector2(0, 0)) -- teleports first created characters to 0, 0 -function TeleportTo(worldPos) end - ---- --- Character.CharacterList, Table containing all characters. --- @realm shared --- @table Character.CharacterList - - ---- TrySeverLimbJoints --- @realm shared --- @tparam Limb targetLimb --- @tparam number severLimbsProbability --- @tparam number damage --- @tparam bool allowBeheading --- @tparam Character attacker -function TrySeverLimbJoints(targetLimb, severLimbsProbability, damage, allowBeheading, attacker) end - ---- AddDamage --- @realm shared --- @tparam Vector2 worldPosition --- @tparam Enumerable afflictions --- @tparam number stun --- @tparam bool playSound --- @tparam number attackImpulse --- @tparam Character attacker --- @tparam number damageMultiplier --- @treturn AttackResult -function AddDamage(worldPosition, afflictions, stun, playSound, attackImpulse, attacker, damageMultiplier) end - ---- AddDamage --- @realm shared --- @tparam Vector2 worldPosition --- @tparam Enumerable afflictions --- @tparam number stun --- @tparam bool playSound --- @tparam number attackImpulse --- @tparam Limb& hitLimb --- @tparam Character attacker --- @tparam number damageMultiplier --- @treturn AttackResult -function AddDamage(worldPosition, afflictions, stun, playSound, attackImpulse, hitLimb, attacker, damageMultiplier) end - ---- RecordKill --- @realm shared --- @tparam Character target -function RecordKill(target) end - ---- AddEncounter --- @realm shared --- @tparam Character other -function AddEncounter(other) end - ---- DamageLimb --- @realm shared --- @tparam Vector2 worldPosition --- @tparam Limb hitLimb --- @tparam Enumerable afflictions --- @tparam number stun --- @tparam bool playSound --- @tparam number attackImpulse --- @tparam Character attacker --- @tparam number damageMultiplier --- @tparam bool allowStacking --- @tparam number penetration --- @tparam bool shouldImplode --- @treturn AttackResult -function DamageLimb(worldPosition, hitLimb, afflictions, stun, playSound, attackImpulse, attacker, damageMultiplier, allowStacking, penetration, shouldImplode) end - ---- TryAdjustAttackerSkill --- @realm shared --- @tparam Character attacker --- @tparam number healthChange -function TryAdjustAttackerSkill(attacker, healthChange) end - ---- SetStun --- @realm shared --- @tparam number newStun --- @tparam bool allowStunDecrease --- @tparam bool isNetworkMessage -function SetStun(newStun, allowStunDecrease, isNetworkMessage) end - ---- ApplyStatusEffects --- @realm shared --- @tparam function actionType --- @tparam number deltaTime -function ApplyStatusEffects(actionType, deltaTime) end - ---- BreakJoints --- @realm shared -function BreakJoints() end - ---- Kill --- @realm shared --- @tparam CauseOfDeathType causeOfDeath --- @tparam Affliction causeOfDeathAffliction --- @tparam bool isNetworkMessage --- @tparam bool log -function Kill(causeOfDeath, causeOfDeathAffliction, isNetworkMessage, log) end - ---- Revive --- @realm shared --- @tparam bool removeAllAfflictions -function Revive(removeAllAfflictions) end - ---- Remove --- @realm shared -function Remove() end - ---- SaveInventory --- @realm shared --- @tparam Inventory inventory --- @tparam XElement parentElement -function Character.SaveInventory(inventory, parentElement) end - ---- SaveInventory --- @realm shared -function SaveInventory() end - ---- SpawnInventoryItems --- @realm shared --- @tparam Inventory inventory --- @tparam ContentXElement itemData -function SpawnInventoryItems(inventory, itemData) end - ---- GetAttackContexts --- @realm shared --- @treturn Enumerable -function GetAttackContexts() end - ---- GetVisibleHulls --- @realm shared --- @treturn table -function GetVisibleHulls() end - ---- GetRelativeSimPosition --- @realm shared --- @tparam ISpatialEntity target --- @tparam Nullable`1 worldPos --- @treturn Vector2 -function GetRelativeSimPosition(target, worldPos) end - ---- HasJob --- @realm shared --- @tparam string identifier --- @treturn bool -function HasJob(identifier) end - ---- IsProtectedFromPressure --- @realm shared --- @treturn bool -function IsProtectedFromPressure() end - ---- LoadTalents --- @realm shared -function LoadTalents() end - ---- GiveTalent --- @realm shared --- @tparam Identifier talentIdentifier --- @tparam bool addingFirstTime --- @treturn bool -function GiveTalent(talentIdentifier, addingFirstTime) end - ---- GiveTalent --- @realm shared --- @tparam number talentIdentifier --- @tparam bool addingFirstTime --- @treturn bool -function GiveTalent(talentIdentifier, addingFirstTime) end - ---- GiveTalent --- @realm shared --- @tparam TalentPrefab talentPrefab --- @tparam bool addingFirstTime --- @treturn bool -function GiveTalent(talentPrefab, addingFirstTime) end - ---- HasTalent --- @realm shared --- @tparam Identifier identifier --- @treturn bool -function HasTalent(identifier) end - ---- HasUnlockedAllTalents --- @realm shared --- @treturn bool -function HasUnlockedAllTalents() end - ---- GetFriendlyCrew --- @realm shared --- @tparam Character character --- @treturn Enumerable -function Character.GetFriendlyCrew(character) end - ---- HasTalents --- @realm shared --- @treturn bool -function HasTalents() end - ---- CheckTalents --- @realm shared --- @tparam AbilityEffectType abilityEffectType --- @tparam AbilityObject abilityObject -function CheckTalents(abilityEffectType, abilityObject) end - ---- CheckTalents --- @realm shared --- @tparam AbilityEffectType abilityEffectType -function CheckTalents(abilityEffectType) end - ---- HasRecipeForItem --- @realm shared --- @tparam Identifier recipeIdentifier --- @treturn bool -function HasRecipeForItem(recipeIdentifier) end - ---- GiveMoney --- @realm shared --- @tparam number amount -function GiveMoney(amount) end - ---- GetStatValue --- @realm shared --- @tparam StatTypes statType --- @treturn number -function GetStatValue(statType) end - ---- OnWearablesChanged --- @realm shared -function OnWearablesChanged() end - ---- ChangeStat --- @realm shared --- @tparam StatTypes statType --- @tparam number value -function ChangeStat(statType, value) end - ---- AddAbilityFlag --- @realm shared --- @tparam AbilityFlags abilityFlag -function AddAbilityFlag(abilityFlag) end - ---- RemoveAbilityFlag --- @realm shared --- @tparam AbilityFlags abilityFlag -function RemoveAbilityFlag(abilityFlag) end - ---- HasAbilityFlag --- @realm shared --- @tparam AbilityFlags abilityFlag --- @treturn bool -function HasAbilityFlag(abilityFlag) end - ---- GetAbilityResistance --- @realm shared --- @tparam AfflictionPrefab affliction --- @treturn number -function GetAbilityResistance(affliction) end - ---- ChangeAbilityResistance --- @realm shared --- @tparam Identifier resistanceId --- @tparam number value -function ChangeAbilityResistance(resistanceId, value) end - ---- IsFriendly --- @realm shared --- @tparam Character other --- @treturn bool -function IsFriendly(other) end - ---- IsFriendly --- @realm shared --- @tparam Character me --- @tparam Character other --- @treturn bool -function Character.IsFriendly(me, other) end - ---- ResetNetState --- @realm shared -function ResetNetState() end - ---- ClearInput --- @realm shared --- @tparam InputType inputType -function ClearInput(inputType) end - ---- ClearInputs --- @realm shared -function ClearInputs() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- GiveJobItems --- @realm shared --- @tparam WayPoint spawnPoint -function GiveJobItems(spawnPoint) end - ---- GiveIdCardTags --- @realm shared --- @tparam WayPoint spawnPoint --- @tparam bool createNetworkEvent -function GiveIdCardTags(spawnPoint, createNetworkEvent) end - ---- GetSkillLevel --- @realm shared --- @tparam string skillIdentifier --- @treturn number -function GetSkillLevel(skillIdentifier) end - ---- GetSkillLevel --- @realm shared --- @tparam Identifier skillIdentifier --- @treturn number -function GetSkillLevel(skillIdentifier) end - ---- GetTargetMovement --- @realm shared --- @treturn Vector2 -function GetTargetMovement() end - ---- ApplyMovementLimits --- @realm shared --- @tparam Vector2 targetMovement --- @tparam number currentSpeed --- @treturn Vector2 -function ApplyMovementLimits(targetMovement, currentSpeed) end - ---- StackSpeedMultiplier --- @realm shared --- @tparam number val -function StackSpeedMultiplier(val) end - ---- ResetSpeedMultiplier --- @realm shared -function ResetSpeedMultiplier() end - ---- StackHealthMultiplier --- @realm shared --- @tparam number val -function StackHealthMultiplier(val) end - ---- AddStaticHealthMultiplier --- @realm shared --- @tparam number newMultiplier -function AddStaticHealthMultiplier(newMultiplier) end - ---- GetTemporarySpeedReduction --- @realm shared --- @treturn number -function GetTemporarySpeedReduction() end - ---- GetRightHandPenalty --- @realm shared --- @treturn number -function GetRightHandPenalty() end - ---- GetLeftHandPenalty --- @realm shared --- @treturn number -function GetLeftHandPenalty() end - ---- GetLegPenalty --- @realm shared --- @tparam number startSum --- @treturn number -function GetLegPenalty(startSum) end - ---- ApplyTemporarySpeedLimits --- @realm shared --- @tparam number speed --- @treturn number -function ApplyTemporarySpeedLimits(speed) end - ---- Control --- @realm shared --- @tparam number deltaTime --- @tparam Camera cam -function Control(deltaTime, cam) end - ---- SetAttackTarget --- @realm shared --- @tparam Limb attackLimb --- @tparam IDamageable damageTarget --- @tparam Vector2 attackPos -function SetAttackTarget(attackLimb, damageTarget, attackPos) end - ---- CanSeeCharacter --- @realm shared --- @tparam Character target --- @treturn bool -function CanSeeCharacter(target) end - ---- CanSeeTarget --- @realm shared --- @tparam ISpatialEntity target --- @tparam ISpatialEntity seeingEntity --- @treturn bool -function CanSeeTarget(target, seeingEntity) end - ---- IsFacing --- @realm shared --- @tparam Vector2 targetWorldPos --- @treturn bool -function IsFacing(targetWorldPos) end - ---- HasItem --- @realm shared --- @tparam Item item --- @tparam bool requireEquipped --- @tparam Nullable`1 slotType --- @treturn bool -function HasItem(item, requireEquipped, slotType) end - ---- HasEquippedItem --- @realm shared --- @tparam Item item --- @tparam Nullable`1 slotType --- @tparam function predicate --- @treturn bool -function HasEquippedItem(item, slotType, predicate) end - ---- HasEquippedItem --- @realm shared --- @tparam string tagOrIdentifier --- @tparam bool allowBroken --- @tparam Nullable`1 slotType --- @treturn bool -function HasEquippedItem(tagOrIdentifier, allowBroken, slotType) end - ---- HasEquippedItem --- @realm shared --- @tparam Identifier tagOrIdentifier --- @tparam bool allowBroken --- @tparam Nullable`1 slotType --- @treturn bool -function HasEquippedItem(tagOrIdentifier, allowBroken, slotType) end - ---- GetEquippedItem --- @realm shared --- @tparam string tagOrIdentifier --- @tparam Nullable`1 slotType --- @treturn Item -function GetEquippedItem(tagOrIdentifier, slotType) end - ---- CanAccessInventory --- @realm shared --- @tparam Inventory inventory --- @treturn bool -function CanAccessInventory(inventory) end - ---- FindItem --- @realm shared --- @tparam Int32& itemIndex --- @tparam Item& targetItem --- @tparam Enumerable identifiers --- @tparam bool ignoreBroken --- @tparam Enumerable ignoredItems --- @tparam Enumerable ignoredContainerIdentifiers --- @tparam function customPredicate --- @tparam function customPriorityFunction --- @tparam number maxItemDistance --- @tparam ISpatialEntity positionalReference --- @treturn bool -function FindItem(itemIndex, targetItem, identifiers, ignoreBroken, ignoredItems, ignoredContainerIdentifiers, customPredicate, customPriorityFunction, maxItemDistance, positionalReference) end - ---- IsItemTakenBySomeoneElse --- @realm shared --- @tparam Item item --- @treturn bool -function IsItemTakenBySomeoneElse(item) end - ---- CanInteractWith --- @realm shared --- @tparam Character c --- @tparam number maxDist --- @tparam bool checkVisibility --- @tparam bool skipDistanceCheck --- @treturn bool -function CanInteractWith(c, maxDist, checkVisibility, skipDistanceCheck) end - ---- CanInteractWith --- @realm shared --- @tparam Item item --- @tparam bool checkLinked --- @treturn bool -function CanInteractWith(item, checkLinked) end - ---- CanInteractWith --- @realm shared --- @tparam Item item --- @tparam Single& distanceToItem --- @tparam bool checkLinked --- @treturn bool -function CanInteractWith(item, distanceToItem, checkLinked) end - ---- SetCustomInteract --- @realm shared --- @tparam function onCustomInteract --- @tparam LocalizedString hudText -function SetCustomInteract(onCustomInteract, hudText) end - ---- SelectCharacter --- @realm shared --- @tparam Character character -function SelectCharacter(character) end - ---- DeselectCharacter --- @realm shared -function DeselectCharacter() end - ---- DoInteractionUpdate --- @realm shared --- @tparam number deltaTime --- @tparam Vector2 mouseSimPos -function DoInteractionUpdate(deltaTime, mouseSimPos) end - ---- UpdateAnimAll --- @realm shared --- @tparam number deltaTime -function Character.UpdateAnimAll(deltaTime) end - ---- UpdateAll --- @realm shared --- @tparam number deltaTime --- @tparam Camera cam -function Character.UpdateAll(deltaTime, cam) end - ---- Update --- @realm shared --- @tparam number deltaTime --- @tparam Camera cam -function Update(deltaTime, cam) end - ---- AddAttacker --- @realm shared --- @tparam Character character --- @tparam number damage -function AddAttacker(character, damage) end - ---- ForgiveAttacker --- @realm shared --- @tparam Character character -function ForgiveAttacker(character) end - ---- GetDamageDoneByAttacker --- @realm shared --- @tparam Character otherCharacter --- @treturn number -function GetDamageDoneByAttacker(otherCharacter) end - ---- DespawnNow --- @realm shared --- @tparam bool createNetworkEvents -function DespawnNow(createNetworkEvents) end - ---- RemoveByPrefab --- @realm shared --- @tparam CharacterPrefab prefab -function Character.RemoveByPrefab(prefab) end - ---- CanHearCharacter --- @realm shared --- @tparam Character speaker --- @treturn bool -function CanHearCharacter(speaker) end - ---- SetOrder --- @realm shared --- @tparam Order order --- @tparam bool isNewOrder --- @tparam bool speak --- @tparam bool force -function SetOrder(order, isNewOrder, speak, force) end - ---- GetCurrentOrderWithTopPriority --- @realm shared --- @treturn Order -function GetCurrentOrderWithTopPriority() end - ---- GetCurrentOrder --- @realm shared --- @tparam Order order --- @treturn Order -function GetCurrentOrder(order) end - ---- DisableLine --- @realm shared --- @tparam Identifier identifier -function DisableLine(identifier) end - ---- DisableLine --- @realm shared --- @tparam string identifier -function DisableLine(identifier) end - ---- Speak --- @realm shared --- @tparam string message --- @tparam Nullable`1 messageType --- @tparam number delay --- @tparam Identifier identifier --- @tparam number minDurationBetweenSimilar -function Speak(message, messageType, delay, identifier, minDurationBetweenSimilar) end - ---- ShowSpeechBubble --- @realm shared --- @tparam number duration --- @tparam Color color -function ShowSpeechBubble(duration, color) end - ---- SetAllDamage --- @realm shared --- @tparam number damageAmount --- @tparam number bleedingDamageAmount --- @tparam number burnDamageAmount -function SetAllDamage(damageAmount, bleedingDamageAmount, burnDamageAmount) end - ---- AddDamage --- @realm shared --- @tparam Character attacker --- @tparam Vector2 worldPosition --- @tparam Attack attack --- @tparam number deltaTime --- @tparam bool playSound --- @treturn AttackResult -function AddDamage(attacker, worldPosition, attack, deltaTime, playSound) end - ---- ApplyAttack --- @realm shared --- @tparam Character attacker --- @tparam Vector2 worldPosition --- @tparam Attack attack --- @tparam number deltaTime --- @tparam bool playSound --- @tparam Limb targetLimb --- @tparam number penetration --- @treturn AttackResult -function ApplyAttack(attacker, worldPosition, attack, deltaTime, playSound, targetLimb, penetration) end - ---- Create --- @realm shared --- @tparam string speciesName --- @tparam Vector2 position --- @tparam string seed --- @tparam CharacterInfo characterInfo --- @tparam number id --- @tparam bool isRemotePlayer --- @tparam bool hasAi --- @tparam bool createNetworkEvent --- @tparam RagdollParams ragdoll --- @treturn Character -function Character.Create(speciesName, position, seed, characterInfo, id, isRemotePlayer, hasAi, createNetworkEvent, ragdoll) end - ---- Create --- @realm shared --- @tparam Identifier speciesName --- @tparam Vector2 position --- @tparam string seed --- @tparam CharacterInfo characterInfo --- @tparam number id --- @tparam bool isRemotePlayer --- @tparam bool hasAi --- @tparam bool createNetworkEvent --- @tparam RagdollParams ragdoll --- @treturn Character -function Character.Create(speciesName, position, seed, characterInfo, id, isRemotePlayer, hasAi, createNetworkEvent, ragdoll) end - ---- Create --- @realm shared --- @tparam CharacterPrefab prefab --- @tparam Vector2 position --- @tparam string seed --- @tparam CharacterInfo characterInfo --- @tparam number id --- @tparam bool isRemotePlayer --- @tparam bool hasAi --- @tparam bool createNetworkEvent --- @tparam RagdollParams ragdoll --- @treturn Character -function Character.Create(prefab, position, seed, characterInfo, id, isRemotePlayer, hasAi, createNetworkEvent, ragdoll) end - ---- ReloadHead --- @realm shared --- @tparam Nullable`1 headId --- @tparam number hairIndex --- @tparam number beardIndex --- @tparam number moustacheIndex --- @tparam number faceAttachmentIndex -function ReloadHead(headId, hairIndex, beardIndex, moustacheIndex, faceAttachmentIndex) end - ---- LoadHeadAttachments --- @realm shared -function LoadHeadAttachments() end - ---- IsKeyHit --- @realm shared --- @tparam InputType inputType --- @treturn bool -function IsKeyHit(inputType) end - ---- IsKeyDown --- @realm shared --- @tparam InputType inputType --- @treturn bool -function IsKeyDown(inputType) end - ---- SetInput --- @realm shared --- @tparam InputType inputType --- @tparam bool hit --- @tparam bool held -function SetInput(inputType, hit, held) end - ---- GetPositionUpdateInterval --- @realm shared --- @tparam Client recipient --- @treturn number -function GetPositionUpdateInterval(recipient) end - ---- ServerReadInput --- @realm shared --- @tparam IReadMessage msg --- @tparam Client c -function ServerReadInput(msg, c) end - ---- ServerEventRead --- @realm shared --- @tparam IReadMessage msg --- @tparam Client c -function ServerEventRead(msg, c) end - ---- ServerWritePosition --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c -function ServerWritePosition(msg, c) end - ---- ServerEventWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c --- @tparam IData extraData -function ServerEventWrite(msg, c, extraData) end - ---- WriteSpawnData --- @realm shared --- @tparam IWriteMessage msg --- @tparam number entityId --- @tparam bool restrictMessageSize -function WriteSpawnData(msg, entityId, restrictMessageSize) end - ---- ThrowIfAccessingWalletsInSingleplayer --- @realm shared -function Character.ThrowIfAccessingWalletsInSingleplayer() end - ---- SetOriginalTeam --- @realm shared --- @tparam CharacterTeamType newTeam -function SetOriginalTeam(newTeam) end - ---- HasTeamChange --- @realm shared --- @tparam string identifier --- @treturn bool -function HasTeamChange(identifier) end - ---- TryAddNewTeamChange --- @realm shared --- @tparam string identifier --- @tparam ActiveTeamChange newTeamChange --- @treturn bool -function TryAddNewTeamChange(identifier, newTeamChange) end - ---- TryRemoveTeamChange --- @realm shared --- @tparam string identifier --- @treturn bool -function TryRemoveTeamChange(identifier) end - ---- UpdateTeam --- @realm shared -function UpdateTeam() end - ---- FreeID --- @realm shared -function FreeID() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Character.Controlled, Field of type Character --- @realm shared --- @Character Character.Controlled - ---- --- Enabled, Field of type bool --- @realm shared --- @bool Enabled - ---- --- IsRemotelyControlled, Field of type bool --- @realm shared --- @bool IsRemotelyControlled - ---- --- IsRemotePlayer, Field of type bool --- @realm shared --- @bool IsRemotePlayer - ---- --- IsLocalPlayer, Field of type bool --- @realm shared --- @bool IsLocalPlayer - ---- --- IsPlayer, Field of type bool --- @realm shared --- @bool IsPlayer - ---- --- IsCommanding, Field of type bool --- @realm shared --- @bool IsCommanding - ---- --- IsBot, Field of type bool --- @realm shared --- @bool IsBot - ---- --- IsEscorted, Field of type bool --- @realm shared --- @bool IsEscorted - ---- --- SerializableProperties, Field of type table --- @realm shared --- @table SerializableProperties - ---- --- Keys, Field of type Key[] --- @realm shared --- @Key[] Keys - ---- --- TeamID, Field of type CharacterTeamType --- @realm shared --- @CharacterTeamType TeamID - ---- --- Wallet, Field of type Wallet --- @realm shared --- @Wallet Wallet - ---- --- IsOnPlayerTeam, Field of type bool --- @realm shared --- @bool IsOnPlayerTeam - ---- --- IsInstigator, Field of type bool --- @realm shared --- @bool IsInstigator - ---- --- LastAttackers, Field of type Enumerable --- @realm shared --- @Enumerable LastAttackers - ---- --- LastAttacker, Field of type Character --- @realm shared --- @Character LastAttacker - ---- --- LastOrderedCharacter, Field of type Character --- @realm shared --- @Character LastOrderedCharacter - ---- --- SecondLastOrderedCharacter, Field of type Character --- @realm shared --- @Character SecondLastOrderedCharacter - ---- --- ItemSelectedDurations, Field of type table --- @realm shared --- @table ItemSelectedDurations - ---- --- SpeciesName, Field of type Identifier --- @realm shared --- @Identifier SpeciesName - ---- --- Group, Field of type Identifier --- @realm shared --- @Identifier Group - ---- --- IsHumanoid, Field of type bool --- @realm shared --- @bool IsHumanoid - ---- --- IsHusk, Field of type bool --- @realm shared --- @bool IsHusk - ---- --- IsMale, Field of type bool --- @realm shared --- @bool IsMale - ---- --- IsFemale, Field of type bool --- @realm shared --- @bool IsFemale - ---- --- BloodDecalName, Field of type string --- @realm shared --- @string BloodDecalName - ---- --- CanSpeak, Field of type bool --- @realm shared --- @bool CanSpeak - ---- --- NeedsAir, Field of type bool --- @realm shared --- @bool NeedsAir - ---- --- NeedsWater, Field of type bool --- @realm shared --- @bool NeedsWater - ---- --- NeedsOxygen, Field of type bool --- @realm shared --- @bool NeedsOxygen - ---- --- Noise, Field of type number --- @realm shared --- @number Noise - ---- --- Visibility, Field of type number --- @realm shared --- @number Visibility - ---- --- IsTraitor, Field of type bool --- @realm shared --- @bool IsTraitor - ---- --- IsHuman, Field of type bool --- @realm shared --- @bool IsHuman - ---- --- CurrentOrders, Field of type table --- @realm shared --- @table CurrentOrders - ---- --- IsDismissed, Field of type bool --- @realm shared --- @bool IsDismissed - ---- --- ViewTarget, Field of type Entity --- @realm shared --- @Entity ViewTarget - ---- --- AimRefPosition, Field of type Vector2 --- @realm shared --- @Vector2 AimRefPosition - ---- --- Info, Field of type CharacterInfo --- @realm shared --- @CharacterInfo Info - ---- --- VariantOf, Field of type Identifier --- @realm shared --- @Identifier VariantOf - ---- --- Name, Field of type string --- @realm shared --- @string Name - ---- --- DisplayName, Field of type string --- @realm shared --- @string DisplayName - ---- --- LogName, Field of type string --- @realm shared --- @string LogName - ---- --- HideFace, Field of type bool --- @realm shared --- @bool HideFace - ---- --- ConfigPath, Field of type string --- @realm shared --- @string ConfigPath - ---- --- Mass, Field of type number --- @realm shared --- @number Mass - ---- --- Inventory, Field of type CharacterInventory --- @realm shared --- @CharacterInventory Inventory - ---- --- CustomInteractHUDText, Field of type LocalizedString --- @realm shared --- @LocalizedString CustomInteractHUDText - ---- --- AllowCustomInteract, Field of type bool --- @realm shared --- @bool AllowCustomInteract - ---- --- LockHands, Field of type bool --- @realm shared --- @bool LockHands - ---- --- AllowInput, Field of type bool --- @realm shared --- @bool AllowInput - ---- --- CanMove, Field of type bool --- @realm shared --- @bool CanMove - ---- --- CanInteract, Field of type bool --- @realm shared --- @bool CanInteract - ---- --- CanEat, Field of type bool --- @realm shared --- @bool CanEat - ---- --- CursorPosition, Field of type Vector2 --- @realm shared --- @Vector2 CursorPosition - ---- --- SmoothedCursorPosition, Field of type Vector2 --- @realm shared --- @Vector2 SmoothedCursorPosition - ---- --- CursorWorldPosition, Field of type Vector2 --- @realm shared --- @Vector2 CursorWorldPosition - ---- --- FocusedCharacter, Field of type Character --- @realm shared --- @Character FocusedCharacter - ---- --- SelectedCharacter, Field of type Character --- @realm shared --- @Character SelectedCharacter - ---- --- SelectedBy, Field of type Character --- @realm shared --- @Character SelectedBy - ---- --- HeldItems, Field of type Enumerable --- @realm shared --- @Enumerable HeldItems - ---- --- LowPassMultiplier, Field of type number --- @realm shared --- @number LowPassMultiplier - ---- --- ObstructVision, Field of type bool --- @realm shared --- @bool ObstructVision - ---- --- PressureProtection, Field of type number --- @realm shared --- @number PressureProtection - ---- --- InPressure, Field of type bool --- @realm shared --- @bool InPressure - ---- --- IsIncapacitated, Field of type bool --- @realm shared --- @bool IsIncapacitated - ---- --- IsUnconscious, Field of type bool --- @realm shared --- @bool IsUnconscious - ---- --- IsArrested, Field of type bool --- @realm shared --- @bool IsArrested - ---- --- IsPet, Field of type bool --- @realm shared --- @bool IsPet - ---- --- Oxygen, Field of type number --- @realm shared --- @number Oxygen - ---- --- OxygenAvailable, Field of type number --- @realm shared --- @number OxygenAvailable - ---- --- HullOxygenPercentage, Field of type number --- @realm shared --- @number HullOxygenPercentage - ---- --- UseHullOxygen, Field of type bool --- @realm shared --- @bool UseHullOxygen - ---- --- Stun, Field of type number --- @realm shared --- @number Stun - ---- --- CharacterHealth, Field of type CharacterHealth --- @realm shared --- @CharacterHealth CharacterHealth - ---- --- Vitality, Field of type number --- @realm shared --- @number Vitality - ---- --- Health, Field of type number --- @realm shared --- @number Health - ---- --- HealthPercentage, Field of type number --- @realm shared --- @number HealthPercentage - ---- --- MaxVitality, Field of type number --- @realm shared --- @number MaxVitality - ---- --- MaxHealth, Field of type number --- @realm shared --- @number MaxHealth - ---- --- AIState, Field of type AIState --- @realm shared --- @AIState AIState - ---- --- IsLatched, Field of type bool --- @realm shared --- @bool IsLatched - ---- --- Bloodloss, Field of type number --- @realm shared --- @number Bloodloss - ---- --- Bleeding, Field of type number --- @realm shared --- @number Bleeding - ---- --- SpeechImpediment, Field of type number --- @realm shared --- @number SpeechImpediment - ---- --- PressureTimer, Field of type number --- @realm shared --- @number PressureTimer - ---- --- DisableImpactDamageTimer, Field of type number --- @realm shared --- @number DisableImpactDamageTimer - ---- --- CurrentSpeed, Field of type number --- @realm shared --- @number CurrentSpeed - ---- --- SelectedConstruction, Field of type Item --- @realm shared --- @Item SelectedConstruction - ---- --- FocusedItem, Field of type Item --- @realm shared --- @Item FocusedItem - ---- --- PickingItem, Field of type Item --- @realm shared --- @Item PickingItem - ---- --- AIController, Field of type AIController --- @realm shared --- @AIController AIController - ---- --- IsDead, Field of type bool --- @realm shared --- @bool IsDead - ---- --- EnableDespawn, Field of type bool --- @realm shared --- @bool EnableDespawn - ---- --- CauseOfDeath, Field of type CauseOfDeath --- @realm shared --- @CauseOfDeath CauseOfDeath - ---- --- CanBeSelected, Field of type bool --- @realm shared --- @bool CanBeSelected - ---- --- CanBeDragged, Field of type bool --- @realm shared --- @bool CanBeDragged - ---- --- CanInventoryBeAccessed, Field of type bool --- @realm shared --- @bool CanInventoryBeAccessed - ---- --- CanAim, Field of type bool --- @realm shared --- @bool CanAim - ---- --- InWater, Field of type bool --- @realm shared --- @bool InWater - ---- --- SimPosition, Field of type Vector2 --- @realm shared --- @Vector2 SimPosition - ---- --- Position, Field of type Vector2 --- @realm shared --- @Vector2 Position - ---- --- DrawPosition, Field of type Vector2 --- @realm shared --- @Vector2 DrawPosition - ---- --- IsInFriendlySub, Field of type bool --- @realm shared --- @bool IsInFriendlySub - ---- --- OverrideMovement, Field of type Nullable`1 --- @realm shared --- @Nullable`1 OverrideMovement - ---- --- ForceRun, Field of type bool --- @realm shared --- @bool ForceRun - ---- --- IsClimbing, Field of type bool --- @realm shared --- @bool IsClimbing - ---- --- CanRun, Field of type bool --- @realm shared --- @bool CanRun - ---- --- SpeedMultiplier, Field of type number --- @realm shared --- @number SpeedMultiplier - ---- --- PropulsionSpeedMultiplier, Field of type number --- @realm shared --- @number PropulsionSpeedMultiplier - ---- --- HealthMultiplier, Field of type number --- @realm shared --- @number HealthMultiplier - ---- --- StaticHealthMultiplier, Field of type number --- @realm shared --- @number StaticHealthMultiplier - ---- --- IsKnockedDown, Field of type bool --- @realm shared --- @bool IsKnockedDown - ---- --- IsCaptain, Field of type bool --- @realm shared --- @bool IsCaptain - ---- --- IsEngineer, Field of type bool --- @realm shared --- @bool IsEngineer - ---- --- IsMechanic, Field of type bool --- @realm shared --- @bool IsMechanic - ---- --- IsMedic, Field of type bool --- @realm shared --- @bool IsMedic - ---- --- IsSecurity, Field of type bool --- @realm shared --- @bool IsSecurity - ---- --- IsAssistant, Field of type bool --- @realm shared --- @bool IsAssistant - ---- --- IsWatchman, Field of type bool --- @realm shared --- @bool IsWatchman - ---- --- IsVip, Field of type bool --- @realm shared --- @bool IsVip - ---- --- IsPrisoner, Field of type bool --- @realm shared --- @bool IsPrisoner - ---- --- UniqueNameColor, Field of type Nullable`1 --- @realm shared --- @Nullable`1 UniqueNameColor - ---- --- HealthUpdateInterval, Field of type number --- @realm shared --- @number HealthUpdateInterval - ---- --- MemState, Field of type table --- @realm shared --- @table MemState - ---- --- MemLocalState, Field of type table --- @realm shared --- @table MemLocalState - ---- --- Removed, Field of type bool --- @realm shared --- @bool Removed - ---- --- IdFreed, Field of type bool --- @realm shared --- @bool IdFreed - ---- --- WorldPosition, Field of type Vector2 --- @realm shared --- @Vector2 WorldPosition - ---- --- Submarine, Field of type Submarine --- @realm shared --- @Submarine Submarine - ---- --- AiTarget, Field of type AITarget --- @realm shared --- @AITarget AiTarget - ---- --- InDetectable, Field of type bool --- @realm shared --- @bool InDetectable - ---- --- SpawnTime, Field of type number --- @realm shared --- @number SpawnTime - ---- --- ErrorLine, Field of type string --- @realm shared --- @string ErrorLine - ---- --- OwnerClientEndPoint, Field of type string --- @realm shared --- @string OwnerClientEndPoint - ---- --- OwnerClientName, Field of type string --- @realm shared --- @string OwnerClientName - ---- --- ClientDisconnected, Field of type bool --- @realm shared --- @bool ClientDisconnected - ---- --- KillDisconnectedTimer, Field of type number --- @realm shared --- @number KillDisconnectedTimer - ---- --- HealthUpdatePending, Field of type bool --- @realm shared --- @bool HealthUpdatePending - ---- --- PreviousHull, Field of type Hull --- @realm shared --- @Hull PreviousHull - ---- --- CurrentHull, Field of type Hull --- @realm shared --- @Hull CurrentHull - ---- --- Properties, Field of type table --- @realm shared --- @table Properties - ---- --- HumanPrefab, Field of type HumanPrefab --- @realm shared --- @HumanPrefab HumanPrefab - ---- --- Latchers, Field of type HashSet`1 --- @realm shared --- @HashSet`1 Latchers - ---- --- AttachedProjectiles, Field of type HashSet`1 --- @realm shared --- @HashSet`1 AttachedProjectiles - ---- --- CombatAction, Field of type CombatAction --- @realm shared --- @CombatAction CombatAction - ---- --- AnimController, Field of type AnimController --- @realm shared --- @AnimController AnimController - ---- --- Seed, Field of type string --- @realm shared --- @string Seed - ---- --- LastDamageSource, Field of type Entity --- @realm shared --- @Entity LastDamageSource - ---- --- LastDamage, Field of type AttackResult --- @realm shared --- @AttackResult LastDamage - ---- --- InvisibleTimer, Field of type number --- @realm shared --- @number InvisibleTimer - ---- --- Prefab, Field of type CharacterPrefab --- @realm shared --- @CharacterPrefab Prefab - ---- --- Params, Field of type CharacterParams --- @realm shared --- @CharacterParams Params - ---- --- TraitorCurrentObjective, Field of type LocalizedString --- @realm shared --- @LocalizedString TraitorCurrentObjective - ---- --- ResetInteract, Field of type bool --- @realm shared --- @bool ResetInteract - ---- --- ActiveConversation, Field of type ConversationAction --- @realm shared --- @ConversationAction ActiveConversation - ---- --- RequireConsciousnessForCustomInteract, Field of type bool --- @realm shared --- @bool RequireConsciousnessForCustomInteract - ---- --- KnockbackCooldownTimer, Field of type number --- @realm shared --- @number KnockbackCooldownTimer - ---- --- IsRagdolled, Field of type bool --- @realm shared --- @bool IsRagdolled - ---- --- IsForceRagdolled, Field of type bool --- @realm shared --- @bool IsForceRagdolled - ---- --- dontFollowCursor, Field of type bool --- @realm shared --- @bool dontFollowCursor - ---- --- DisableHealthWindow, Field of type bool --- @realm shared --- @bool DisableHealthWindow - ---- --- GodMode, Field of type bool --- @realm shared --- @bool GodMode - ---- --- CampaignInteractionType, Field of type InteractionType --- @realm shared --- @InteractionType CampaignInteractionType - ---- --- MerchantIdentifier, Field of type Identifier --- @realm shared --- @Identifier MerchantIdentifier - ---- --- OnDeath, Field of type OnDeathHandler --- @realm shared --- @OnDeathHandler OnDeath - ---- --- OnAttacked, Field of type OnAttackedHandler --- @realm shared --- @OnAttackedHandler OnAttacked - ---- --- LastNetworkUpdateID, Field of type number --- @realm shared --- @number LastNetworkUpdateID - ---- --- LastProcessedID, Field of type number --- @realm shared --- @number LastProcessedID - ---- --- healthUpdateTimer, Field of type number --- @realm shared --- @number healthUpdateTimer - ---- --- isSynced, Field of type bool --- @realm shared --- @bool isSynced - ---- --- Character.CharacterUpdateInterval, Field of type number --- @realm shared --- @number Character.CharacterUpdateInterval - ---- --- Character.KnockbackCooldown, Field of type number --- @realm shared --- @number Character.KnockbackCooldown - ---- --- ID, Field of type number --- @realm shared --- @number ID - ---- --- CreationStackTrace, Field of type string --- @realm shared --- @string CreationStackTrace - ---- --- CreationIndex, Field of type number --- @realm shared --- @number CreationIndex - diff --git a/docs/lua/generated/CharacterHealth.lua b/docs/lua/generated/CharacterHealth.lua deleted file mode 100644 index 149801a17..000000000 --- a/docs/lua/generated/CharacterHealth.lua +++ /dev/null @@ -1,367 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.CharacterHealth -]] --- @code CharacterHealth --- @pragma nostrip -local CharacterHealth = {} - ---- GetAllAfflictions --- @realm shared --- @treturn IReadOnlyCollection`1 -function GetAllAfflictions() end - ---- GetAllAfflictions --- @realm shared --- @tparam function limbHealthFilter --- @treturn Enumerable -function GetAllAfflictions(limbHealthFilter) end - ---- GetAffliction --- @realm shared --- @tparam string identifier --- @tparam bool allowLimbAfflictions --- @treturn Affliction -function GetAffliction(identifier, allowLimbAfflictions) end - ---- GetAffliction --- @realm shared --- @tparam Identifier identifier --- @tparam bool allowLimbAfflictions --- @treturn Affliction -function GetAffliction(identifier, allowLimbAfflictions) end - ---- GetAfflictionOfType --- @realm shared --- @tparam Identifier afflictionType --- @tparam bool allowLimbAfflictions --- @treturn Affliction -function GetAfflictionOfType(afflictionType, allowLimbAfflictions) end - ---- GetAffliction --- @realm shared --- @tparam string identifier --- @tparam bool allowLimbAfflictions --- @treturn T -function GetAffliction(identifier, allowLimbAfflictions) end - ---- GetAffliction --- @realm shared --- @tparam string identifier --- @tparam Limb limb --- @treturn Affliction -function GetAffliction(identifier, limb) end - ---- GetAfflictionLimb --- @realm shared --- @tparam Affliction affliction --- @treturn Limb -function GetAfflictionLimb(affliction) end - ---- GetAfflictionStrength --- @realm shared --- @tparam string afflictionType --- @tparam Limb limb --- @tparam bool requireLimbSpecific --- @treturn number -function GetAfflictionStrength(afflictionType, limb, requireLimbSpecific) end - ---- GetAfflictionStrength --- @realm shared --- @tparam string afflictionType --- @tparam bool allowLimbAfflictions --- @treturn number -function GetAfflictionStrength(afflictionType, allowLimbAfflictions) end - ---- ApplyAffliction --- @realm shared --- @tparam Limb targetLimb --- @tparam Affliction affliction --- @tparam bool allowStacking -function ApplyAffliction(targetLimb, affliction, allowStacking) end - ---- GetResistance --- @realm shared --- @tparam AfflictionPrefab afflictionPrefab --- @treturn number -function GetResistance(afflictionPrefab) end - ---- GetStatValue --- @realm shared --- @tparam StatTypes statType --- @treturn number -function GetStatValue(statType) end - ---- HasFlag --- @realm shared --- @tparam AbilityFlags flagType --- @treturn bool -function HasFlag(flagType) end - ---- ReduceAllAfflictionsOnAllLimbs --- @realm shared --- @tparam number amount --- @tparam Nullable`1 treatmentAction -function ReduceAllAfflictionsOnAllLimbs(amount, treatmentAction) end - ---- ReduceAfflictionOnAllLimbs --- @realm shared --- @tparam Identifier affliction --- @tparam number amount --- @tparam Nullable`1 treatmentAction -function ReduceAfflictionOnAllLimbs(affliction, amount, treatmentAction) end - ---- ReduceAllAfflictionsOnLimb --- @realm shared --- @tparam Limb targetLimb --- @tparam number amount --- @tparam Nullable`1 treatmentAction -function ReduceAllAfflictionsOnLimb(targetLimb, amount, treatmentAction) end - ---- ReduceAfflictionOnLimb --- @realm shared --- @tparam Limb targetLimb --- @tparam Identifier affliction --- @tparam number amount --- @tparam Nullable`1 treatmentAction -function ReduceAfflictionOnLimb(targetLimb, affliction, amount, treatmentAction) end - ---- ApplyDamage --- @realm shared --- @tparam Limb hitLimb --- @tparam AttackResult attackResult --- @tparam bool allowStacking -function ApplyDamage(hitLimb, attackResult, allowStacking) end - ---- SetAllDamage --- @realm shared --- @tparam number damageAmount --- @tparam number bleedingDamageAmount --- @tparam number burnDamageAmount -function SetAllDamage(damageAmount, bleedingDamageAmount, burnDamageAmount) end - ---- GetLimbDamage --- @realm shared --- @tparam Limb limb --- @tparam string afflictionType --- @treturn number -function GetLimbDamage(limb, afflictionType) end - ---- RemoveAllAfflictions --- @realm shared -function RemoveAllAfflictions() end - ---- RemoveNegativeAfflictions --- @realm shared -function RemoveNegativeAfflictions() end - ---- Update --- @realm shared --- @tparam number deltaTime -function Update(deltaTime) end - ---- SetVitality --- @realm shared --- @tparam number newVitality -function SetVitality(newVitality) end - ---- CalculateVitality --- @realm shared -function CalculateVitality() end - ---- ApplyAfflictionStatusEffects --- @realm shared --- @tparam function type -function ApplyAfflictionStatusEffects(type) end - ---- GetCauseOfDeath --- @realm shared --- @treturn ValueTuple`2 -function GetCauseOfDeath() end - ---- GetSuitableTreatments --- @realm shared --- @tparam table treatmentSuitability --- @tparam bool normalize --- @tparam Limb limb --- @tparam bool ignoreHiddenAfflictions --- @tparam number predictFutureDuration -function GetSuitableTreatments(treatmentSuitability, normalize, limb, ignoreHiddenAfflictions, predictFutureDuration) end - ---- GetActiveAfflictionTags --- @realm shared --- @treturn Enumerable -function GetActiveAfflictionTags() end - ---- GetActiveAfflictionTags --- @realm shared --- @tparam Enumerable afflictions --- @treturn Enumerable -function GetActiveAfflictionTags(afflictions) end - ---- GetPredictedStrength --- @realm shared --- @tparam Affliction affliction --- @tparam number predictFutureDuration --- @tparam Limb limb --- @treturn number -function GetPredictedStrength(affliction, predictFutureDuration, limb) end - ---- ServerWrite --- @realm shared --- @tparam IWriteMessage msg -function ServerWrite(msg) end - ---- Remove --- @realm shared -function Remove() end - ---- SortAfflictionsBySeverity --- @realm shared --- @tparam Enumerable afflictions --- @tparam bool excludeBuffs --- @treturn Enumerable -function CharacterHealth.SortAfflictionsBySeverity(afflictions, excludeBuffs) end - ---- Save --- @realm shared --- @tparam XElement healthElement -function Save(healthElement) end - ---- Load --- @realm shared --- @tparam XElement element -function Load(element) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- DoesBleed, Field of type bool --- @realm shared --- @bool DoesBleed - ---- --- UseHealthWindow, Field of type bool --- @realm shared --- @bool UseHealthWindow - ---- --- CrushDepth, Field of type number --- @realm shared --- @number CrushDepth - ---- --- BloodlossAffliction, Field of type Affliction --- @realm shared --- @Affliction BloodlossAffliction - ---- --- IsUnconscious, Field of type bool --- @realm shared --- @bool IsUnconscious - ---- --- PressureKillDelay, Field of type number --- @realm shared --- @number PressureKillDelay - ---- --- Vitality, Field of type number --- @realm shared --- @number Vitality - ---- --- HealthPercentage, Field of type number --- @realm shared --- @number HealthPercentage - ---- --- MaxVitality, Field of type number --- @realm shared --- @number MaxVitality - ---- --- MinVitality, Field of type number --- @realm shared --- @number MinVitality - ---- --- FaceTint, Field of type Color --- @realm shared --- @Color FaceTint - ---- --- BodyTint, Field of type Color --- @realm shared --- @Color BodyTint - ---- --- OxygenAmount, Field of type number --- @realm shared --- @number OxygenAmount - ---- --- BloodlossAmount, Field of type number --- @realm shared --- @number BloodlossAmount - ---- --- Stun, Field of type number --- @realm shared --- @number Stun - ---- --- StunTimer, Field of type number --- @realm shared --- @number StunTimer - ---- --- PressureAffliction, Field of type Affliction --- @realm shared --- @Affliction PressureAffliction - ---- --- Unkillable, Field of type bool --- @realm shared --- @bool Unkillable - ---- --- DefaultFaceTint, Field of type Color --- @realm shared --- @Color DefaultFaceTint - ---- --- Character, Field of type Character --- @realm shared --- @Character Character - ---- --- CharacterHealth.InsufficientOxygenThreshold, Field of type number --- @realm shared --- @number CharacterHealth.InsufficientOxygenThreshold - ---- --- CharacterHealth.LowOxygenThreshold, Field of type number --- @realm shared --- @number CharacterHealth.LowOxygenThreshold - diff --git a/docs/lua/generated/CharacterInfo.lua b/docs/lua/generated/CharacterInfo.lua deleted file mode 100644 index 31fbcb632..000000000 --- a/docs/lua/generated/CharacterInfo.lua +++ /dev/null @@ -1,564 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma CharacterInfo class with some additional functions and fields - -Barotrauma source code: [CharacterInfo.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/CharacterInfo.cs) -]] --- @code CharacterInfo --- @pragma nostrip - -local CharacterInfo = {} - ---- Rename --- @realm shared --- @tparam string newName -function Rename(newName) end - ---- ResetName --- @realm shared -function ResetName() end - ---- Save --- @realm shared --- @tparam XElement parentElement --- @treturn XElement -function Save(parentElement) end - ---- SaveOrders --- @realm shared --- @tparam XElement parentElement --- @tparam Order[] orders -function CharacterInfo.SaveOrders(parentElement, orders) end - ---- SaveOrderData --- @realm shared --- @tparam CharacterInfo characterInfo --- @tparam XElement parentElement -function CharacterInfo.SaveOrderData(characterInfo, parentElement) end - ---- SaveOrderData --- @realm shared -function SaveOrderData() end - ---- ApplyOrderData --- @realm shared --- @tparam Character character --- @tparam XElement orderData -function CharacterInfo.ApplyOrderData(character, orderData) end - ---- ApplyOrderData --- @realm shared -function ApplyOrderData() end - ---- LoadOrders --- @realm shared --- @tparam XElement ordersElement --- @treturn table -function CharacterInfo.LoadOrders(ordersElement) end - ---- ApplyHealthData --- @realm shared --- @tparam Character character --- @tparam XElement healthData -function CharacterInfo.ApplyHealthData(character, healthData) end - ---- ReloadHeadAttachments --- @realm shared -function ReloadHeadAttachments() end - ---- ClearCurrentOrders --- @realm shared -function ClearCurrentOrders() end - ---- Remove --- @realm shared -function Remove() end - ---- ClearSavedStatValues --- @realm shared -function ClearSavedStatValues() end - ---- ClearSavedStatValues --- @realm shared --- @tparam StatTypes statType -function ClearSavedStatValues(statType) end - ---- RemoveSavedStatValuesOnDeath --- @realm shared -function RemoveSavedStatValuesOnDeath() end - ---- ResetSavedStatValue --- @realm shared --- @tparam string statIdentifier -function ResetSavedStatValue(statIdentifier) end - ---- GetSavedStatValue --- @realm shared --- @tparam StatTypes statType --- @treturn number -function GetSavedStatValue(statType) end - ---- GetSavedStatValue --- @realm shared --- @tparam StatTypes statType --- @tparam Identifier statIdentifier --- @treturn number -function GetSavedStatValue(statType, statIdentifier) end - ---- ChangeSavedStatValue --- @realm shared --- @tparam StatTypes statType --- @tparam number value --- @tparam string statIdentifier --- @tparam bool removeOnDeath --- @tparam number maxValue --- @tparam bool setValue -function ChangeSavedStatValue(statType, value, statIdentifier, removeOnDeath, maxValue, setValue) end - ---- ServerWrite --- @realm shared --- @tparam IWriteMessage msg -function ServerWrite(msg) end - ---- GetUnlockedTalentsInTree --- @realm shared --- @treturn Enumerable -function GetUnlockedTalentsInTree() end - ---- GetEndocrineTalents --- @realm shared --- @treturn Enumerable -function GetEndocrineTalents() end - ---- CheckDisguiseStatus --- @realm shared --- @tparam bool handleBuff --- @tparam IdCard idCard -function CheckDisguiseStatus(handleBuff, idCard) end - ---- GetManualOrderPriority --- @realm shared --- @tparam Order order --- @treturn number -function GetManualOrderPriority(order) end - ---- GetValidAttachmentElements --- @realm shared --- @tparam Enumerable elements --- @tparam HeadPreset headPreset --- @tparam Nullable`1 wearableType --- @treturn Enumerable -function GetValidAttachmentElements(elements, headPreset, wearableType) end - ---- CountValidAttachmentsOfType --- @realm shared --- @tparam WearableType wearableType --- @treturn number -function CountValidAttachmentsOfType(wearableType) end - ---- GetRandomName --- @realm shared --- @tparam RandSync randSync --- @treturn string -function GetRandomName(randSync) end - ---- SelectRandomColor --- @realm shared --- @tparam ImmutableArray`1& array --- @tparam RandSync randSync --- @treturn Color -function CharacterInfo.SelectRandomColor(array, randSync) end - ---- GetIdentifier --- @realm shared --- @treturn number -function GetIdentifier() end - ---- GetIdentifierUsingOriginalName --- @realm shared --- @treturn number -function GetIdentifierUsingOriginalName() end - ---- FilterElements --- @realm shared --- @tparam Enumerable elements --- @tparam ImmutableHashSet`1 tags --- @tparam Nullable`1 targetType --- @treturn Enumerable -function FilterElements(elements, tags, targetType) end - ---- RecreateHead --- @realm shared --- @tparam ImmutableHashSet`1 tags --- @tparam number hairIndex --- @tparam number beardIndex --- @tparam number moustacheIndex --- @tparam number faceAttachmentIndex -function RecreateHead(tags, hairIndex, beardIndex, moustacheIndex, faceAttachmentIndex) end - ---- ReplaceVars --- @realm shared --- @tparam string str --- @treturn string -function ReplaceVars(str) end - ---- RecreateHead --- @realm shared --- @tparam HeadInfo headInfo -function RecreateHead(headInfo) end - ---- RefreshHead --- @realm shared -function RefreshHead() end - ---- LoadHeadAttachments --- @realm shared -function LoadHeadAttachments() end - ---- AddEmpty --- @realm shared --- @tparam Enumerable elements --- @tparam WearableType type --- @tparam number commonness --- @treturn table -function CharacterInfo.AddEmpty(elements, type, commonness) end - ---- GetRandomElement --- @realm shared --- @tparam Enumerable elements --- @treturn ContentXElement -function GetRandomElement(elements) end - ---- IsValidIndex --- @realm shared --- @tparam number index --- @tparam table list --- @treturn bool -function CharacterInfo.IsValidIndex(index, list) end - ---- IncreaseSkillLevel --- @realm shared --- @tparam Identifier skillIdentifier --- @tparam number increase --- @tparam bool gainedFromAbility -function IncreaseSkillLevel(skillIdentifier, increase, gainedFromAbility) end - ---- SetSkillLevel --- @realm shared --- @tparam Identifier skillIdentifier --- @tparam number level -function SetSkillLevel(skillIdentifier, level) end - ---- GiveExperience --- @realm shared --- @tparam number amount --- @tparam bool isMissionExperience -function GiveExperience(amount, isMissionExperience) end - ---- SetExperience --- @realm shared --- @tparam number newExperience -function SetExperience(newExperience) end - ---- GetTotalTalentPoints --- @realm shared --- @treturn number -function GetTotalTalentPoints() end - ---- GetAvailableTalentPoints --- @realm shared --- @treturn number -function GetAvailableTalentPoints() end - ---- GetProgressTowardsNextLevel --- @realm shared --- @treturn number -function GetProgressTowardsNextLevel() end - ---- GetExperienceRequiredForCurrentLevel --- @realm shared --- @treturn number -function GetExperienceRequiredForCurrentLevel() end - ---- GetExperienceRequiredToLevelUp --- @realm shared --- @treturn number -function GetExperienceRequiredToLevelUp() end - ---- GetCurrentLevel --- @realm shared --- @treturn number -function GetCurrentLevel() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Head, Field of type HeadInfo --- @realm shared --- @HeadInfo Head - ---- --- IsMale, Field of type bool --- @realm shared --- @bool IsMale - ---- --- IsFemale, Field of type bool --- @realm shared --- @bool IsFemale - ---- --- Prefab, Field of type CharacterInfoPrefab --- @realm shared --- @CharacterInfoPrefab Prefab - ---- --- HasNickname, Field of type bool --- @realm shared --- @bool HasNickname - ---- --- OriginalName, Field of type string --- @realm shared --- @string OriginalName - ---- --- DisplayName, Field of type string --- @realm shared --- @string DisplayName - ---- --- SpeciesName, Field of type Identifier --- @realm shared --- @Identifier SpeciesName - ---- --- ExperiencePoints, Field of type number --- @realm shared --- @number ExperiencePoints - ---- --- UnlockedTalents, Field of type HashSet`1 --- @realm shared --- @HashSet`1 UnlockedTalents - ---- --- AdditionalTalentPoints, Field of type number --- @realm shared --- @number AdditionalTalentPoints - ---- --- HeadSprite, Field of type Sprite --- @realm shared --- @Sprite HeadSprite - ---- --- Portrait, Field of type Sprite --- @realm shared --- @Sprite Portrait - ---- --- AttachmentSprites, Field of type table --- @realm shared --- @table AttachmentSprites - ---- --- CharacterConfigElement, Field of type ContentXElement --- @realm shared --- @ContentXElement CharacterConfigElement - ---- --- PersonalityTrait, Field of type NPCPersonalityTrait --- @realm shared --- @NPCPersonalityTrait PersonalityTrait - ---- --- CharacterInfo.HighestManualOrderPriority, Field of type number --- @realm shared --- @number CharacterInfo.HighestManualOrderPriority - ---- --- CurrentOrders, Field of type table --- @realm shared --- @table CurrentOrders - ---- --- SpriteTags, Field of type table --- @realm shared --- @table SpriteTags - ---- --- Ragdoll, Field of type RagdollParams --- @realm shared --- @RagdollParams Ragdoll - ---- --- IsAttachmentsLoaded, Field of type bool --- @realm shared --- @bool IsAttachmentsLoaded - ---- --- Hairs, Field of type IReadOnlyList`1 --- @realm shared --- @IReadOnlyList`1 Hairs - ---- --- Beards, Field of type IReadOnlyList`1 --- @realm shared --- @IReadOnlyList`1 Beards - ---- --- Moustaches, Field of type IReadOnlyList`1 --- @realm shared --- @IReadOnlyList`1 Moustaches - ---- --- FaceAttachments, Field of type IReadOnlyList`1 --- @realm shared --- @IReadOnlyList`1 FaceAttachments - ---- --- Wearables, Field of type Enumerable --- @realm shared --- @Enumerable Wearables - ---- --- InventoryData, Field of type XElement --- @realm shared --- @XElement InventoryData - ---- --- HealthData, Field of type XElement --- @realm shared --- @XElement HealthData - ---- --- OrderData, Field of type XElement --- @realm shared --- @XElement OrderData - ---- --- Name, Field of type string --- @realm shared --- @string Name - ---- --- Character, Field of type Character --- @realm shared --- @Character Character - ---- --- Job, Field of type Job --- @realm shared --- @Job Job - ---- --- Salary, Field of type number --- @realm shared --- @number Salary - ---- --- OmitJobInPortraitClothing, Field of type bool --- @realm shared --- @bool OmitJobInPortraitClothing - ---- --- IsDisguised, Field of type bool --- @realm shared --- @bool IsDisguised - ---- --- IsDisguisedAsAnother, Field of type bool --- @realm shared --- @bool IsDisguisedAsAnother - ---- --- ragdollFileName, Field of type string --- @realm shared --- @string ragdollFileName - ---- --- StartItemsGiven, Field of type bool --- @realm shared --- @bool StartItemsGiven - ---- --- IsNewHire, Field of type bool --- @realm shared --- @bool IsNewHire - ---- --- CauseOfDeath, Field of type CauseOfDeath --- @realm shared --- @CauseOfDeath CauseOfDeath - ---- --- TeamID, Field of type CharacterTeamType --- @realm shared --- @CharacterTeamType TeamID - ---- --- ID, Field of type number --- @realm shared --- @number ID - ---- --- HasSpecifierTags, Field of type bool --- @realm shared --- @bool HasSpecifierTags - ---- --- HairColors, Field of type ImmutableArray`1 --- @realm shared --- @ImmutableArray`1 HairColors - ---- --- FacialHairColors, Field of type ImmutableArray`1 --- @realm shared --- @ImmutableArray`1 FacialHairColors - ---- --- SkinColors, Field of type ImmutableArray`1 --- @realm shared --- @ImmutableArray`1 SkinColors - ---- --- MissionsCompletedSinceDeath, Field of type number --- @realm shared --- @number MissionsCompletedSinceDeath - ---- --- SavedStatValues, Field of type table --- @realm shared --- @table SavedStatValues - ---- --- CharacterInfo.MaxAdditionalTalentPoints, Field of type number --- @realm shared --- @number CharacterInfo.MaxAdditionalTalentPoints - ---- --- CharacterInfo.MaxCurrentOrders, Field of type number --- @realm shared --- @number CharacterInfo.MaxCurrentOrders - diff --git a/docs/lua/generated/CharacterInventory.lua b/docs/lua/generated/CharacterInventory.lua deleted file mode 100644 index e5c14951b..000000000 --- a/docs/lua/generated/CharacterInventory.lua +++ /dev/null @@ -1,338 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.CharacterInventory -]] --- @code CharacterInventory --- @pragma nostrip -local CharacterInventory = {} - ---- FindLimbSlot --- @realm shared --- @tparam InvSlotType limbSlot --- @treturn number -function FindLimbSlot(limbSlot) end - ---- GetItemInLimbSlot --- @realm shared --- @tparam InvSlotType limbSlot --- @treturn Item -function GetItemInLimbSlot(limbSlot) end - ---- IsInLimbSlot --- @realm shared --- @tparam Item item --- @tparam InvSlotType limbSlot --- @treturn bool -function IsInLimbSlot(item, limbSlot) end - ---- CanBePutInSlot --- @realm shared --- @tparam Item item --- @tparam number i --- @tparam bool ignoreCondition --- @treturn bool -function CanBePutInSlot(item, i, ignoreCondition) end - ---- CanBePutInSlot --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam number i --- @tparam Nullable`1 condition --- @tparam Nullable`1 quality --- @treturn bool -function CanBePutInSlot(itemPrefab, i, condition, quality) end - ---- CanBeAutoMovedToCorrectSlots --- @realm shared --- @tparam Item item --- @treturn bool -function CanBeAutoMovedToCorrectSlots(item) end - ---- RemoveItem --- @realm shared --- @tparam Item item -function RemoveItem(item) end - ---- RemoveItem --- @realm shared --- @tparam Item item --- @tparam bool tryEquipFromSameStack -function RemoveItem(item, tryEquipFromSameStack) end - ---- TryPutItemWithAutoEquipCheck --- @realm shared --- @tparam Item item --- @tparam Character user --- @tparam Enumerable allowedSlots --- @tparam bool createNetworkEvent --- @treturn bool -function TryPutItemWithAutoEquipCheck(item, user, allowedSlots, createNetworkEvent) end - ---- TryPutItem --- @realm shared --- @tparam Item item --- @tparam Character user --- @tparam Enumerable allowedSlots --- @tparam bool createNetworkEvent --- @tparam bool ignoreCondition --- @treturn bool -function TryPutItem(item, user, allowedSlots, createNetworkEvent, ignoreCondition) end - ---- CheckIfAnySlotAvailable --- @realm shared --- @tparam Item item --- @tparam bool inWrongSlot --- @treturn number -function CheckIfAnySlotAvailable(item, inWrongSlot) end - ---- TryPutItem --- @realm shared --- @tparam Item item --- @tparam number index --- @tparam bool allowSwapping --- @tparam bool allowCombine --- @tparam Character user --- @tparam bool createNetworkEvent --- @tparam bool ignoreCondition --- @treturn bool -function TryPutItem(item, index, allowSwapping, allowCombine, user, createNetworkEvent, ignoreCondition) end - ---- ServerEventRead --- @realm shared --- @tparam IReadMessage msg --- @tparam Client c -function ServerEventRead(msg, c) end - ---- ServerEventWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c --- @tparam IData extraData -function ServerEventWrite(msg, c, extraData) end - ---- Contains --- @realm shared --- @tparam Item item --- @treturn bool -function Contains(item) end - ---- FirstOrDefault --- @realm shared --- @treturn Item -function FirstOrDefault() end - ---- LastOrDefault --- @realm shared --- @treturn Item -function LastOrDefault() end - ---- GetItemAt --- @realm shared --- @tparam number index --- @treturn Item -function GetItemAt(index) end - ---- GetItemsAt --- @realm shared --- @tparam number index --- @treturn Enumerable -function GetItemsAt(index) end - ---- FindIndex --- @realm shared --- @tparam Item item --- @treturn number -function FindIndex(item) end - ---- FindIndices --- @realm shared --- @tparam Item item --- @treturn table -function FindIndices(item) end - ---- ItemOwnsSelf --- @realm shared --- @tparam Item item --- @treturn bool -function ItemOwnsSelf(item) end - ---- FindAllowedSlot --- @realm shared --- @tparam Item item --- @tparam bool ignoreCondition --- @treturn number -function FindAllowedSlot(item, ignoreCondition) end - ---- CanBePut --- @realm shared --- @tparam Item item --- @treturn bool -function CanBePut(item) end - ---- CanBePut --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam Nullable`1 condition --- @tparam Nullable`1 quality --- @treturn bool -function CanBePut(itemPrefab, condition, quality) end - ---- HowManyCanBePut --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam Nullable`1 condition --- @treturn number -function HowManyCanBePut(itemPrefab, condition) end - ---- HowManyCanBePut --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam number i --- @tparam Nullable`1 condition --- @treturn number -function HowManyCanBePut(itemPrefab, i, condition) end - ---- IsEmpty --- @realm shared --- @treturn bool -function IsEmpty() end - ---- IsFull --- @realm shared --- @tparam bool takeStacksIntoAccount --- @treturn bool -function IsFull(takeStacksIntoAccount) end - ---- CreateNetworkEvent --- @realm shared -function CreateNetworkEvent() end - ---- FindItem --- @realm shared --- @tparam function predicate --- @tparam bool recursive --- @treturn Item -function FindItem(predicate, recursive) end - ---- FindAllItems --- @realm shared --- @tparam function predicate --- @tparam bool recursive --- @tparam table list --- @treturn table -function FindAllItems(predicate, recursive, list) end - ---- FindItemByTag --- @realm shared --- @tparam Identifier tag --- @tparam bool recursive --- @treturn Item -function FindItemByTag(tag, recursive) end - ---- FindItemByIdentifier --- @realm shared --- @tparam Identifier identifier --- @tparam bool recursive --- @treturn Item -function FindItemByIdentifier(identifier, recursive) end - ---- ForceToSlot --- @realm shared --- @tparam Item item --- @tparam number index -function ForceToSlot(item, index) end - ---- ForceRemoveFromSlot --- @realm shared --- @tparam Item item --- @tparam number index -function ForceRemoveFromSlot(item, index) end - ---- SharedRead --- @realm shared --- @tparam IReadMessage msg --- @tparam List`1[]& newItemIds -function SharedRead(msg, newItemIds) end - ---- SharedWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam IData extraData -function SharedWrite(msg, extraData) end - ---- DeleteAllItems --- @realm shared -function DeleteAllItems() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- SlotTypes, Field of type InvSlotType[] --- @realm shared --- @InvSlotType[] SlotTypes - ---- --- AccessibleWhenAlive, Field of type bool --- @realm shared --- @bool AccessibleWhenAlive - ---- --- AccessibleByOwner, Field of type bool --- @realm shared --- @bool AccessibleByOwner - ---- --- AllItems, Field of type Enumerable --- @realm shared --- @Enumerable AllItems - ---- --- AllItemsMod, Field of type Enumerable --- @realm shared --- @Enumerable AllItemsMod - ---- --- Capacity, Field of type number --- @realm shared --- @number Capacity - ---- --- CharacterInventory.anySlot, Field of type table --- @realm shared --- @table CharacterInventory.anySlot - ---- --- Owner, Field of type Entity --- @realm shared --- @Entity Owner - ---- --- Locked, Field of type bool --- @realm shared --- @bool Locked - ---- --- AllowSwappingContainedItems, Field of type bool --- @realm shared --- @bool AllowSwappingContainedItems - diff --git a/docs/lua/generated/Client.lua b/docs/lua/generated/Client.lua deleted file mode 100644 index a898761ab..000000000 --- a/docs/lua/generated/Client.lua +++ /dev/null @@ -1,487 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma Client class with some additional functions and fields - -Barotrauma source code: [Client.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Networking/Client.cs) -]] --- @code Client --- @pragma nostrip - -local Client = {} - --- @remove function SetClientCharacter(character) end --- @remove function Kick(reason) end --- @remove function Ban(reason, range, seconds) end --- @remove function Client.Unban(player, endpoint) end --- @remove function CheckPermission(permissions) end - ---- Sets the client character. --- @realm server -function SetClientCharacter(character) end - ---- Kick a client. --- @realm server -function Kick(reason) end - ---- Ban a client. --- @realm server -function Ban(reason, range, seconds) end - ---- Checks permissions, Client.Permissions. --- @realm server -function CheckPermission(permissions) end - ---- Unban a client. --- @realm server -function Client.Unban(player, endpoint) end - - ---- Ban --- @realm shared --- @tparam string player --- @tparam string reason --- @tparam bool range --- @tparam number seconds -function Client.Ban(player, reason, range, seconds) end - ---- InitClientSync --- @realm shared -function InitClientSync() end - ---- IsValidName --- @realm shared --- @tparam string name --- @tparam ServerSettings serverSettings --- @treturn bool -function Client.IsValidName(name, serverSettings) end - ---- EndpointMatches --- @realm shared --- @tparam string endPoint --- @treturn bool -function EndpointMatches(endPoint) end - ---- SetPermissions --- @realm shared --- @tparam ClientPermissions permissions --- @tparam Enumerable permittedConsoleCommands -function SetPermissions(permissions, permittedConsoleCommands) end - ---- GivePermission --- @realm shared --- @tparam ClientPermissions permission -function GivePermission(permission) end - ---- RemovePermission --- @realm shared --- @tparam ClientPermissions permission -function RemovePermission(permission) end - ---- HasPermission --- @realm shared --- @tparam ClientPermissions permission --- @treturn bool -function HasPermission(permission) end - ---- GetVote --- @realm shared --- @tparam VoteType voteType --- @treturn T -function GetVote(voteType) end - ---- SetVote --- @realm shared --- @tparam VoteType voteType --- @tparam Object value -function SetVote(voteType, value) end - ---- ResetVotes --- @realm shared -function ResetVotes() end - ---- AddKickVote --- @realm shared --- @tparam Client voter -function AddKickVote(voter) end - ---- RemoveKickVote --- @realm shared --- @tparam Client voter -function RemoveKickVote(voter) end - ---- HasKickVoteFrom --- @realm shared --- @tparam Client voter --- @treturn bool -function HasKickVoteFrom(voter) end - ---- HasKickVoteFromID --- @realm shared --- @tparam number id --- @treturn bool -function HasKickVoteFromID(id) end - ---- UpdateKickVotes --- @realm shared --- @tparam table connectedClients -function Client.UpdateKickVotes(connectedClients) end - ---- WritePermissions --- @realm shared --- @tparam IWriteMessage msg -function WritePermissions(msg) end - ---- ReadPermissions --- @realm shared --- @tparam IReadMessage inc --- @tparam ClientPermissions& permissions --- @tparam List`1& permittedCommands -function Client.ReadPermissions(inc, permissions, permittedCommands) end - ---- ReadPermissions --- @realm shared --- @tparam IReadMessage inc -function ReadPermissions(inc) end - ---- SanitizeName --- @realm shared --- @tparam string name --- @treturn string -function Client.SanitizeName(name) end - ---- Dispose --- @realm shared -function Dispose() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- CharacterInfo, Field of type CharacterInfo --- @realm shared --- @CharacterInfo CharacterInfo - ---- --- Connection, Field of type NetworkConnection --- @realm shared --- @NetworkConnection Connection - ---- --- Karma, Field of type number --- @realm shared --- @number Karma - ---- --- Client.ClientList, Field of type table --- @realm shared --- @table Client.ClientList - ---- --- Character, Field of type Character --- @realm shared --- @Character Character - ---- --- SpectatePos, Field of type Nullable`1 --- @realm shared --- @Nullable`1 SpectatePos - ---- --- Spectating, Field of type bool --- @realm shared --- @bool Spectating - ---- --- Muted, Field of type bool --- @realm shared --- @bool Muted - ---- --- HasPermissions, Field of type bool --- @realm shared --- @bool HasPermissions - ---- --- VoipQueue, Field of type VoipQueue --- @realm shared --- @VoipQueue VoipQueue - ---- --- InGame, Field of type bool --- @realm shared --- @bool InGame - ---- --- KickVoteCount, Field of type number --- @realm shared --- @number KickVoteCount - ---- --- VoiceEnabled, Field of type bool --- @realm shared --- @bool VoiceEnabled - ---- --- LastRecvClientListUpdate, Field of type number --- @realm shared --- @number LastRecvClientListUpdate - ---- --- LastSentServerSettingsUpdate, Field of type number --- @realm shared --- @number LastSentServerSettingsUpdate - ---- --- LastRecvServerSettingsUpdate, Field of type number --- @realm shared --- @number LastRecvServerSettingsUpdate - ---- --- LastRecvLobbyUpdate, Field of type number --- @realm shared --- @number LastRecvLobbyUpdate - ---- --- LastSentChatMsgID, Field of type number --- @realm shared --- @number LastSentChatMsgID - ---- --- LastRecvChatMsgID, Field of type number --- @realm shared --- @number LastRecvChatMsgID - ---- --- LastSentEntityEventID, Field of type number --- @realm shared --- @number LastSentEntityEventID - ---- --- LastRecvEntityEventID, Field of type number --- @realm shared --- @number LastRecvEntityEventID - ---- --- LastRecvCampaignUpdate, Field of type number --- @realm shared --- @number LastRecvCampaignUpdate - ---- --- LastRecvCampaignSave, Field of type number --- @realm shared --- @number LastRecvCampaignSave - ---- --- LastCampaignSaveSendTime, Field of type Pair`2 --- @realm shared --- @Pair`2 LastCampaignSaveSendTime - ---- --- ChatMsgQueue, Field of type table --- @realm shared --- @table ChatMsgQueue - ---- --- LastChatMsgQueueID, Field of type number --- @realm shared --- @number LastChatMsgQueueID - ---- --- LastSentChatMessages, Field of type table --- @realm shared --- @table LastSentChatMessages - ---- --- ChatSpamSpeed, Field of type number --- @realm shared --- @number ChatSpamSpeed - ---- --- ChatSpamTimer, Field of type number --- @realm shared --- @number ChatSpamTimer - ---- --- ChatSpamCount, Field of type number --- @realm shared --- @number ChatSpamCount - ---- --- RoundsSincePlayedAsTraitor, Field of type number --- @realm shared --- @number RoundsSincePlayedAsTraitor - ---- --- KickAFKTimer, Field of type number --- @realm shared --- @number KickAFKTimer - ---- --- MidRoundSyncTimeOut, Field of type number --- @realm shared --- @number MidRoundSyncTimeOut - ---- --- NeedsMidRoundSync, Field of type bool --- @realm shared --- @bool NeedsMidRoundSync - ---- --- UnreceivedEntityEventCount, Field of type number --- @realm shared --- @number UnreceivedEntityEventCount - ---- --- FirstNewEventID, Field of type number --- @realm shared --- @number FirstNewEventID - ---- --- EntityEventLastSent, Field of type table --- @realm shared --- @table EntityEventLastSent - ---- --- PositionUpdateLastSent, Field of type table --- @realm shared --- @table PositionUpdateLastSent - ---- --- PendingPositionUpdates, Field of type Queue`1 --- @realm shared --- @Queue`1 PendingPositionUpdates - ---- --- ReadyToStart, Field of type bool --- @realm shared --- @bool ReadyToStart - ---- --- JobPreferences, Field of type table --- @realm shared --- @table JobPreferences - ---- --- AssignedJob, Field of type JobVariant --- @realm shared --- @JobVariant AssignedJob - ---- --- DeleteDisconnectedTimer, Field of type number --- @realm shared --- @number DeleteDisconnectedTimer - ---- --- SpectateOnly, Field of type bool --- @realm shared --- @bool SpectateOnly - ---- --- WaitForNextRoundRespawn, Field of type Nullable`1 --- @realm shared --- @Nullable`1 WaitForNextRoundRespawn - ---- --- KarmaKickCount, Field of type number --- @realm shared --- @number KarmaKickCount - ---- --- Name, Field of type string --- @realm shared --- @string Name - ---- --- NameID, Field of type number --- @realm shared --- @number NameID - ---- --- ID, Field of type Byte --- @realm shared --- @Byte ID - ---- --- SteamID, Field of type number --- @realm shared --- @number SteamID - ---- --- OwnerSteamID, Field of type number --- @realm shared --- @number OwnerSteamID - ---- --- Language, Field of type LanguageIdentifier --- @realm shared --- @LanguageIdentifier Language - ---- --- Ping, Field of type number --- @realm shared --- @number Ping - ---- --- PreferredJob, Field of type Identifier --- @realm shared --- @Identifier PreferredJob - ---- --- TeamID, Field of type CharacterTeamType --- @realm shared --- @CharacterTeamType TeamID - ---- --- PreferredTeam, Field of type CharacterTeamType --- @realm shared --- @CharacterTeamType PreferredTeam - ---- --- CharacterID, Field of type number --- @realm shared --- @number CharacterID - ---- --- HasSpawned, Field of type bool --- @realm shared --- @bool HasSpawned - ---- --- GivenAchievements, Field of type HashSet`1 --- @realm shared --- @HashSet`1 GivenAchievements - ---- --- Permissions, Field of type ClientPermissions --- @realm shared --- @ClientPermissions Permissions - ---- --- PermittedConsoleCommands, Field of type HashSet`1 --- @realm shared --- @HashSet`1 PermittedConsoleCommands - ---- --- Client.MaxNameLength, Field of type number --- @realm shared --- @number Client.MaxNameLength - diff --git a/docs/lua/generated/Entity.Spawner.lua b/docs/lua/generated/Entity.Spawner.lua deleted file mode 100644 index 4ab359510..000000000 --- a/docs/lua/generated/Entity.Spawner.lua +++ /dev/null @@ -1,213 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma EntitySpawner class with some additional functions and fields - -Barotrauma source code: [EntitySpawner.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Networking/EntitySpawner.cs) -]] --- @code Entity.Spawner --- @pragma nostrip - - ---- CreateNetworkEvent --- @realm shared --- @tparam SpawnOrRemove spawnOrRemove -function CreateNetworkEvent(spawnOrRemove) end - ---- ServerEventWrite --- @realm shared --- @tparam IWriteMessage message --- @tparam Client client --- @tparam IData extraData -function ServerEventWrite(message, client, extraData) end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- AddItemToSpawnQueue --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam Vector2 worldPosition --- @tparam Nullable`1 condition --- @tparam Nullable`1 quality --- @tparam function onSpawned -function AddItemToSpawnQueue(itemPrefab, worldPosition, condition, quality, onSpawned) end - ---- AddItemToSpawnQueue --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam Vector2 position --- @tparam Submarine sub --- @tparam Nullable`1 condition --- @tparam Nullable`1 quality --- @tparam function onSpawned -function AddItemToSpawnQueue(itemPrefab, position, sub, condition, quality, onSpawned) end - ---- AddItemToSpawnQueue --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam Inventory inventory --- @tparam Nullable`1 condition --- @tparam Nullable`1 quality --- @tparam function onSpawned --- @tparam bool spawnIfInventoryFull --- @tparam bool ignoreLimbSlots --- @tparam InvSlotType slot -function AddItemToSpawnQueue(itemPrefab, inventory, condition, quality, onSpawned, spawnIfInventoryFull, ignoreLimbSlots, slot) end - ---- AddCharacterToSpawnQueue --- @realm shared --- @tparam Identifier speciesName --- @tparam Vector2 worldPosition --- @tparam function onSpawn -function AddCharacterToSpawnQueue(speciesName, worldPosition, onSpawn) end - ---- AddCharacterToSpawnQueue --- @realm shared --- @tparam Identifier speciesName --- @tparam Vector2 position --- @tparam Submarine sub --- @tparam function onSpawn -function AddCharacterToSpawnQueue(speciesName, position, sub, onSpawn) end - ---- AddCharacterToSpawnQueue --- @realm shared --- @tparam Identifier speciesName --- @tparam Vector2 worldPosition --- @tparam CharacterInfo characterInfo --- @tparam function onSpawn -function AddCharacterToSpawnQueue(speciesName, worldPosition, characterInfo, onSpawn) end - ---- AddEntityToRemoveQueue --- @realm shared --- @tparam Entity entity -function AddEntityToRemoveQueue(entity) end - ---- AddItemToRemoveQueue --- @realm shared --- @tparam Item item -function AddItemToRemoveQueue(item) end - ---- IsInSpawnQueue --- @realm shared --- @tparam Predicate`1 predicate --- @treturn bool -function IsInSpawnQueue(predicate) end - ---- CountSpawnQueue --- @realm shared --- @tparam Predicate`1 predicate --- @treturn number -function CountSpawnQueue(predicate) end - ---- IsInRemoveQueue --- @realm shared --- @tparam Entity entity --- @treturn bool -function IsInRemoveQueue(entity) end - ---- Update --- @realm shared --- @tparam bool createNetworkEvents -function Update(createNetworkEvents) end - ---- Reset --- @realm shared -function Reset() end - ---- FreeID --- @realm shared -function FreeID() end - ---- Remove --- @realm shared -function Remove() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Removed, Field of type bool --- @realm shared --- @bool Removed - ---- --- IdFreed, Field of type bool --- @realm shared --- @bool IdFreed - ---- --- SimPosition, Field of type Vector2 --- @realm shared --- @Vector2 SimPosition - ---- --- Position, Field of type Vector2 --- @realm shared --- @Vector2 Position - ---- --- WorldPosition, Field of type Vector2 --- @realm shared --- @Vector2 WorldPosition - ---- --- DrawPosition, Field of type Vector2 --- @realm shared --- @Vector2 DrawPosition - ---- --- Submarine, Field of type Submarine --- @realm shared --- @Submarine Submarine - ---- --- AiTarget, Field of type AITarget --- @realm shared --- @AITarget AiTarget - ---- --- InDetectable, Field of type bool --- @realm shared --- @bool InDetectable - ---- --- SpawnTime, Field of type number --- @realm shared --- @number SpawnTime - ---- --- ErrorLine, Field of type string --- @realm shared --- @string ErrorLine - ---- --- ID, Field of type number --- @realm shared --- @number ID - ---- --- CreationStackTrace, Field of type string --- @realm shared --- @string CreationStackTrace - ---- --- CreationIndex, Field of type number --- @realm shared --- @number CreationIndex - diff --git a/docs/lua/generated/Entity.lua b/docs/lua/generated/Entity.lua deleted file mode 100644 index 36c9642d6..000000000 --- a/docs/lua/generated/Entity.lua +++ /dev/null @@ -1,176 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma Entity class with some additional functions and fields - -Barotrauma source code: [Entity.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Map/Entity.cs) -]] --- @code Entity --- @pragma nostrip - ---- Remove --- @realm shared -function Remove() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- GetEntities --- @realm shared --- @treturn IReadOnlyCollection`1 -function Entity.GetEntities() end - ---- FindFreeIdBlock --- @realm shared --- @tparam number minBlockSize --- @treturn number -function Entity.FindFreeIdBlock(minBlockSize) end - ---- FindEntityByID --- @realm shared --- @tparam number ID --- @treturn Entity -function Entity.FindEntityByID(ID) end - ---- RemoveAll --- @realm shared -function Entity.RemoveAll() end - ---- FreeID --- @realm shared -function FreeID() end - ---- DumpIds --- @realm shared --- @tparam number count --- @tparam string filename -function Entity.DumpIds(count, filename) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Entity.EntityCount, Field of type number --- @realm shared --- @number Entity.EntityCount - ---- --- Removed, Field of type bool --- @realm shared --- @bool Removed - ---- --- IdFreed, Field of type bool --- @realm shared --- @bool IdFreed - ---- --- SimPosition, Field of type Vector2 --- @realm shared --- @Vector2 SimPosition - ---- --- Position, Field of type Vector2 --- @realm shared --- @Vector2 Position - ---- --- WorldPosition, Field of type Vector2 --- @realm shared --- @Vector2 WorldPosition - ---- --- DrawPosition, Field of type Vector2 --- @realm shared --- @Vector2 DrawPosition - ---- --- Submarine, Field of type Submarine --- @realm shared --- @Submarine Submarine - ---- --- AiTarget, Field of type AITarget --- @realm shared --- @AITarget AiTarget - ---- --- InDetectable, Field of type bool --- @realm shared --- @bool InDetectable - ---- --- SpawnTime, Field of type number --- @realm shared --- @number SpawnTime - ---- --- ErrorLine, Field of type string --- @realm shared --- @string ErrorLine - ---- --- ID, Field of type number --- @realm shared --- @number ID - ---- --- CreationStackTrace, Field of type string --- @realm shared --- @string CreationStackTrace - ---- --- CreationIndex, Field of type number --- @realm shared --- @number CreationIndex - ---- --- Entity.Spawner, Field of type EntitySpawner --- @realm shared --- @EntitySpawner Entity.Spawner - ---- --- Entity.NullEntityID, Field of type number --- @realm shared --- @number Entity.NullEntityID - ---- --- Entity.EntitySpawnerID, Field of type number --- @realm shared --- @number Entity.EntitySpawnerID - ---- --- Entity.RespawnManagerID, Field of type number --- @realm shared --- @number Entity.RespawnManagerID - ---- --- Entity.DummyID, Field of type number --- @realm shared --- @number Entity.DummyID - ---- --- Entity.ReservedIDStart, Field of type number --- @realm shared --- @number Entity.ReservedIDStart - ---- --- Entity.MaxEntityCount, Field of type number --- @realm shared --- @number Entity.MaxEntityCount - diff --git a/docs/lua/generated/GameScreen.lua b/docs/lua/generated/GameScreen.lua deleted file mode 100644 index b517db72e..000000000 --- a/docs/lua/generated/GameScreen.lua +++ /dev/null @@ -1,58 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.GameScreen -]] --- @code Game.GameScreen --- @pragma nostrip -local GameScreen = {} - ---- Select --- @realm shared -function Select() end - ---- Deselect --- @realm shared -function Deselect() end - ---- Update --- @realm shared --- @tparam number deltaTime -function Update(deltaTime) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Cam, Field of type Camera --- @realm shared --- @Camera Cam - ---- --- GameTime, Field of type number --- @realm shared --- @number GameTime - ---- --- IsEditor, Field of type bool --- @realm shared --- @bool IsEditor - diff --git a/docs/lua/generated/GameSession.lua b/docs/lua/generated/GameSession.lua deleted file mode 100644 index f4318d0f2..000000000 --- a/docs/lua/generated/GameSession.lua +++ /dev/null @@ -1,256 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.GameSession -]] --- @code Game.GameSession --- @pragma nostrip -local GameSession = {} - ---- LoadPreviousSave --- @realm shared -function LoadPreviousSave() end - ---- SwitchSubmarine --- @realm shared --- @tparam SubmarineInfo newSubmarine --- @tparam number cost --- @tparam Client client --- @treturn SubmarineInfo -function SwitchSubmarine(newSubmarine, cost, client) end - ---- PurchaseSubmarine --- @realm shared --- @tparam SubmarineInfo newSubmarine --- @tparam Client client -function PurchaseSubmarine(newSubmarine, client) end - ---- IsSubmarineOwned --- @realm shared --- @tparam SubmarineInfo query --- @treturn bool -function IsSubmarineOwned(query) end - ---- IsCurrentLocationRadiated --- @realm shared --- @treturn bool -function IsCurrentLocationRadiated() end - ---- StartRound --- @realm shared --- @tparam string levelSeed --- @tparam Nullable`1 difficulty --- @tparam LevelGenerationParams levelGenerationParams -function StartRound(levelSeed, difficulty, levelGenerationParams) end - ---- StartRound --- @realm shared --- @tparam LevelData levelData --- @tparam bool mirrorLevel --- @tparam SubmarineInfo startOutpost --- @tparam SubmarineInfo endOutpost -function StartRound(levelData, mirrorLevel, startOutpost, endOutpost) end - ---- PlaceSubAtStart --- @realm shared --- @tparam Level level -function PlaceSubAtStart(level) end - ---- Update --- @realm shared --- @tparam number deltaTime -function Update(deltaTime) end - ---- GetMission --- @realm shared --- @tparam number index --- @treturn Mission -function GetMission(index) end - ---- GetMissionIndex --- @realm shared --- @tparam Mission mission --- @treturn number -function GetMissionIndex(mission) end - ---- EnforceMissionOrder --- @realm shared --- @tparam table missionIdentifiers -function EnforceMissionOrder(missionIdentifiers) end - ---- GetSessionCrewCharacters --- @realm shared --- @tparam CharacterType type --- @treturn ImmutableHashSet`1 -function GameSession.GetSessionCrewCharacters(type) end - ---- EndRound --- @realm shared --- @tparam string endMessage --- @tparam table traitorResults --- @tparam TransitionType transitionType -function EndRound(endMessage, traitorResults, transitionType) end - ---- LogEndRoundStats --- @realm shared --- @tparam string eventId -function LogEndRoundStats(eventId) end - ---- KillCharacter --- @realm shared --- @tparam Character character -function KillCharacter(character) end - ---- ReviveCharacter --- @realm shared --- @tparam Character character -function ReviveCharacter(character) end - ---- IsCompatibleWithEnabledContentPackages --- @realm shared --- @tparam IList`1 contentPackageNames --- @tparam LocalizedString& errorMsg --- @treturn bool -function GameSession.IsCompatibleWithEnabledContentPackages(contentPackageNames, errorMsg) end - ---- Save --- @realm shared --- @tparam string filePath -function Save(filePath) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Missions, Field of type Enumerable --- @realm shared --- @Enumerable Missions - ---- --- Casualties, Field of type Enumerable --- @realm shared --- @Enumerable Casualties - ---- --- IsRunning, Field of type bool --- @realm shared --- @bool IsRunning - ---- --- RoundEnding, Field of type bool --- @realm shared --- @bool RoundEnding - ---- --- Level, Field of type Level --- @realm shared --- @Level Level - ---- --- LevelData, Field of type LevelData --- @realm shared --- @LevelData LevelData - ---- --- MirrorLevel, Field of type bool --- @realm shared --- @bool MirrorLevel - ---- --- Map, Field of type Map --- @realm shared --- @Map Map - ---- --- Campaign, Field of type CampaignMode --- @realm shared --- @CampaignMode Campaign - ---- --- StartLocation, Field of type Location --- @realm shared --- @Location StartLocation - ---- --- EndLocation, Field of type Location --- @realm shared --- @Location EndLocation - ---- --- SubmarineInfo, Field of type SubmarineInfo --- @realm shared --- @SubmarineInfo SubmarineInfo - ---- --- Submarine, Field of type Submarine --- @realm shared --- @Submarine Submarine - ---- --- SavePath, Field of type string --- @realm shared --- @string SavePath - ---- --- EventManager, Field of type EventManager --- @realm shared --- @EventManager EventManager - ---- --- GameMode, Field of type GameMode --- @realm shared --- @GameMode GameMode - ---- --- CrewManager, Field of type CrewManager --- @realm shared --- @CrewManager CrewManager - ---- --- RoundStartTime, Field of type number --- @realm shared --- @number RoundStartTime - ---- --- TimeSpentCleaning, Field of type number --- @realm shared --- @number TimeSpentCleaning - ---- --- TimeSpentPainting, Field of type number --- @realm shared --- @number TimeSpentPainting - ---- --- WinningTeam, Field of type Nullable`1 --- @realm shared --- @Nullable`1 WinningTeam - ---- --- OwnedSubmarines, Field of type table --- @realm shared --- @table OwnedSubmarines - ---- --- GameSession.MinimumLoadingTime, Field of type number --- @realm shared --- @number GameSession.MinimumLoadingTime - diff --git a/docs/lua/generated/GameSettings.lua b/docs/lua/generated/GameSettings.lua deleted file mode 100644 index 1df17c805..000000000 --- a/docs/lua/generated/GameSettings.lua +++ /dev/null @@ -1,53 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.GameSettings -]] --- @code Game.Settings --- @pragma nostrip -local GameSettings = {} - ---- Init --- @realm shared -function GameSettings.Init() end - ---- SetCurrentConfig --- @realm shared --- @tparam Config& newConfig -function GameSettings.SetCurrentConfig(newConfig) end - ---- SaveCurrentConfig --- @realm shared -function GameSettings.SaveCurrentConfig() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- GameSettings.CurrentConfig, Field of type Config& --- @realm shared --- @Config& GameSettings.CurrentConfig - ---- --- GameSettings.PlayerConfigPath, Field of type string --- @realm shared --- @string GameSettings.PlayerConfigPath - diff --git a/docs/lua/generated/Hull.lua b/docs/lua/generated/Hull.lua deleted file mode 100644 index accedfd36..000000000 --- a/docs/lua/generated/Hull.lua +++ /dev/null @@ -1,817 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.Hull -]] --- @code Hull --- @pragma nostrip -local Hull = {} - ---- IncreaseSectionColorOrStrength --- @realm shared --- @tparam BackgroundSection section --- @tparam Nullable`1 color --- @tparam Nullable`1 strength --- @tparam bool requiresUpdate --- @tparam bool isCleaning -function IncreaseSectionColorOrStrength(section, color, strength, requiresUpdate, isCleaning) end - ---- SetSectionColorOrStrength --- @realm shared --- @tparam BackgroundSection section --- @tparam Nullable`1 color --- @tparam Nullable`1 strength -function SetSectionColorOrStrength(section, color, strength) end - ---- CleanSection --- @realm shared --- @tparam BackgroundSection section --- @tparam number cleanVal --- @tparam bool updateRequired -function CleanSection(section, cleanVal, updateRequired) end - ---- Load --- @realm shared --- @tparam ContentXElement element --- @tparam Submarine submarine --- @tparam IdRemap idRemap --- @treturn Hull -function Hull.Load(element, submarine, idRemap) end - ---- Save --- @realm shared --- @tparam XElement parentElement --- @treturn XElement -function Save(parentElement) end - ---- IsMouseOn --- @realm shared --- @tparam Vector2 position --- @treturn bool -function IsMouseOn(position) end - ---- ServerEventWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c --- @tparam IData extraData -function ServerEventWrite(msg, c, extraData) end - ---- ServerEventRead --- @realm shared --- @tparam IReadMessage msg --- @tparam Client c -function ServerEventRead(msg, c) end - ---- GetBorders --- @realm shared --- @treturn Rectangle -function Hull.GetBorders() end - ---- Clone --- @realm shared --- @treturn MapEntity -function Clone() end - ---- GenerateEntityGrid --- @realm shared --- @tparam Rectangle worldRect --- @treturn EntityGrid -function Hull.GenerateEntityGrid(worldRect) end - ---- GenerateEntityGrid --- @realm shared --- @tparam Submarine submarine --- @treturn EntityGrid -function Hull.GenerateEntityGrid(submarine) end - ---- SetModuleTags --- @realm shared --- @tparam Enumerable tags -function SetModuleTags(tags) end - ---- OnMapLoaded --- @realm shared -function OnMapLoaded() end - ---- AddToGrid --- @realm shared --- @tparam Submarine submarine -function AddToGrid(submarine) end - ---- GetWaveIndex --- @realm shared --- @tparam Vector2 position --- @treturn number -function GetWaveIndex(position) end - ---- GetWaveIndex --- @realm shared --- @tparam number xPos --- @treturn number -function GetWaveIndex(xPos) end - ---- Move --- @realm shared --- @tparam Vector2 amount -function Move(amount) end - ---- ShallowRemove --- @realm shared -function ShallowRemove() end - ---- Remove --- @realm shared -function Remove() end - ---- AddFireSource --- @realm shared --- @tparam FireSource fireSource -function AddFireSource(fireSource) end - ---- AddDecal --- @realm shared --- @tparam number decalId --- @tparam Vector2 worldPosition --- @tparam number scale --- @tparam bool isNetworkEvent --- @tparam Nullable`1 spriteIndex --- @treturn Decal -function AddDecal(decalId, worldPosition, scale, isNetworkEvent, spriteIndex) end - ---- AddDecal --- @realm shared --- @tparam string decalName --- @tparam Vector2 worldPosition --- @tparam number scale --- @tparam bool isNetworkEvent --- @tparam Nullable`1 spriteIndex --- @treturn Decal -function AddDecal(decalName, worldPosition, scale, isNetworkEvent, spriteIndex) end - ---- Update --- @realm shared --- @tparam number deltaTime --- @tparam Camera cam -function Update(deltaTime, cam) end - ---- ApplyFlowForces --- @realm shared --- @tparam number deltaTime --- @tparam Item item -function ApplyFlowForces(deltaTime, item) end - ---- Extinguish --- @realm shared --- @tparam number deltaTime --- @tparam number amount --- @tparam Vector2 position --- @tparam bool extinguishRealFires --- @tparam bool extinguishFakeFires -function Extinguish(deltaTime, amount, position, extinguishRealFires, extinguishFakeFires) end - ---- RemoveFire --- @realm shared --- @tparam FireSource fire -function RemoveFire(fire) end - ---- GetConnectedHulls --- @realm shared --- @tparam bool includingThis --- @tparam Nullable`1 searchDepth --- @tparam bool ignoreClosedGaps --- @treturn Enumerable -function GetConnectedHulls(includingThis, searchDepth, ignoreClosedGaps) end - ---- GetApproximateDistance --- @realm shared --- @tparam Vector2 startPos --- @tparam Vector2 endPos --- @tparam Hull targetHull --- @tparam number maxDistance --- @tparam number distanceMultiplierPerClosedDoor --- @treturn number -function GetApproximateDistance(startPos, endPos, targetHull, maxDistance, distanceMultiplierPerClosedDoor) end - ---- FindHull --- @realm shared --- @tparam Vector2 position --- @tparam Hull guess --- @tparam bool useWorldCoordinates --- @tparam bool inclusive --- @treturn Hull -function Hull.FindHull(position, guess, useWorldCoordinates, inclusive) end - ---- FindHullUnoptimized --- @realm shared --- @tparam Vector2 position --- @tparam Hull guess --- @tparam bool useWorldCoordinates --- @tparam bool inclusive --- @treturn Hull -function Hull.FindHullUnoptimized(position, guess, useWorldCoordinates, inclusive) end - ---- DetectItemVisibility --- @realm shared --- @tparam Character c -function Hull.DetectItemVisibility(c) end - ---- CreateRoomName --- @realm shared --- @treturn string -function CreateRoomName() end - ---- IsTaggedAirlock --- @realm shared --- @treturn bool -function IsTaggedAirlock() end - ---- LeadsOutside --- @realm shared --- @tparam Character character --- @treturn bool -function LeadsOutside(character) end - ---- GetCleanTarget --- @realm shared --- @tparam Vector2 worldPosition --- @treturn Hull -function Hull.GetCleanTarget(worldPosition) end - ---- GetBackgroundSection --- @realm shared --- @tparam Vector2 worldPosition --- @treturn BackgroundSection -function GetBackgroundSection(worldPosition) end - ---- GetBackgroundSectionsViaContaining --- @realm shared --- @tparam Rectangle rectArea --- @treturn Enumerable -function GetBackgroundSectionsViaContaining(rectArea) end - ---- DoesSectionMatch --- @realm shared --- @tparam number index --- @tparam number row --- @treturn bool -function DoesSectionMatch(index, row) end - ---- AddLinked --- @realm shared --- @tparam MapEntity entity -function AddLinked(entity) end - ---- ResolveLinks --- @realm shared --- @tparam IdRemap childRemap -function ResolveLinks(childRemap) end - ---- HasUpgrade --- @realm shared --- @tparam Identifier identifier --- @treturn bool -function HasUpgrade(identifier) end - ---- GetUpgrade --- @realm shared --- @tparam Identifier identifier --- @treturn Upgrade -function GetUpgrade(identifier) end - ---- GetUpgrades --- @realm shared --- @treturn table -function GetUpgrades() end - ---- SetUpgrade --- @realm shared --- @tparam Upgrade upgrade --- @tparam bool createNetworkEvent -function SetUpgrade(upgrade, createNetworkEvent) end - ---- AddUpgrade --- @realm shared --- @tparam Upgrade upgrade --- @tparam bool createNetworkEvent --- @treturn bool -function AddUpgrade(upgrade, createNetworkEvent) end - ---- FlipX --- @realm shared --- @tparam bool relativeToSub -function FlipX(relativeToSub) end - ---- FlipY --- @realm shared --- @tparam bool relativeToSub -function FlipY(relativeToSub) end - ---- RemoveLinked --- @realm shared --- @tparam MapEntity e -function RemoveLinked(e) end - ---- GetLinkedEntities --- @realm shared --- @tparam HashSet`1 list --- @tparam Nullable`1 maxDepth --- @tparam function filter --- @treturn HashSet`1 -function GetLinkedEntities(list, maxDepth, filter) end - ---- FreeID --- @realm shared -function FreeID() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- SerializableProperties, Field of type table --- @realm shared --- @table SerializableProperties - ---- --- Name, Field of type string --- @realm shared --- @string Name - ---- --- DisplayName, Field of type LocalizedString --- @realm shared --- @LocalizedString DisplayName - ---- --- OutpostModuleTags, Field of type Enumerable --- @realm shared --- @Enumerable OutpostModuleTags - ---- --- RoomName, Field of type string --- @realm shared --- @string RoomName - ---- --- AmbientLight, Field of type Color --- @realm shared --- @Color AmbientLight - ---- --- Rect, Field of type Rectangle --- @realm shared --- @Rectangle Rect - ---- --- Linkable, Field of type bool --- @realm shared --- @bool Linkable - ---- --- LethalPressure, Field of type number --- @realm shared --- @number LethalPressure - ---- --- Size, Field of type Vector2 --- @realm shared --- @Vector2 Size - ---- --- CeilingHeight, Field of type number --- @realm shared --- @number CeilingHeight - ---- --- Surface, Field of type number --- @realm shared --- @number Surface - ---- --- WorldSurface, Field of type number --- @realm shared --- @number WorldSurface - ---- --- WaterVolume, Field of type number --- @realm shared --- @number WaterVolume - ---- --- Oxygen, Field of type number --- @realm shared --- @number Oxygen - ---- --- IsWetRoom, Field of type bool --- @realm shared --- @bool IsWetRoom - ---- --- AvoidStaying, Field of type bool --- @realm shared --- @bool AvoidStaying - ---- --- WaterPercentage, Field of type number --- @realm shared --- @number WaterPercentage - ---- --- OxygenPercentage, Field of type number --- @realm shared --- @number OxygenPercentage - ---- --- Volume, Field of type number --- @realm shared --- @number Volume - ---- --- Pressure, Field of type number --- @realm shared --- @number Pressure - ---- --- WaveY, Field of type Single[] --- @realm shared --- @Single[] WaveY - ---- --- WaveVel, Field of type Single[] --- @realm shared --- @Single[] WaveVel - ---- --- BackgroundSections, Field of type table --- @realm shared --- @table BackgroundSections - ---- --- SupportsPaintedColors, Field of type bool --- @realm shared --- @bool SupportsPaintedColors - ---- --- FireSources, Field of type table --- @realm shared --- @table FireSources - ---- --- FakeFireSources, Field of type table --- @realm shared --- @table FakeFireSources - ---- --- BallastFlora, Field of type BallastFloraBehavior --- @realm shared --- @BallastFloraBehavior BallastFlora - ---- --- DisallowedUpgrades, Field of type string --- @realm shared --- @string DisallowedUpgrades - ---- --- FlippedX, Field of type bool --- @realm shared --- @bool FlippedX - ---- --- FlippedY, Field of type bool --- @realm shared --- @bool FlippedY - ---- --- IsHighlighted, Field of type bool --- @realm shared --- @bool IsHighlighted - ---- --- WorldRect, Field of type Rectangle --- @realm shared --- @Rectangle WorldRect - ---- --- Sprite, Field of type Sprite --- @realm shared --- @Sprite Sprite - ---- --- DrawBelowWater, Field of type bool --- @realm shared --- @bool DrawBelowWater - ---- --- DrawOverWater, Field of type bool --- @realm shared --- @bool DrawOverWater - ---- --- AllowedLinks, Field of type Enumerable --- @realm shared --- @Enumerable AllowedLinks - ---- --- ResizeHorizontal, Field of type bool --- @realm shared --- @bool ResizeHorizontal - ---- --- ResizeVertical, Field of type bool --- @realm shared --- @bool ResizeVertical - ---- --- RectWidth, Field of type number --- @realm shared --- @number RectWidth - ---- --- RectHeight, Field of type number --- @realm shared --- @number RectHeight - ---- --- SpriteDepthOverrideIsSet, Field of type bool --- @realm shared --- @bool SpriteDepthOverrideIsSet - ---- --- SpriteOverrideDepth, Field of type number --- @realm shared --- @number SpriteOverrideDepth - ---- --- SpriteDepth, Field of type number --- @realm shared --- @number SpriteDepth - ---- --- Scale, Field of type number --- @realm shared --- @number Scale - ---- --- HiddenInGame, Field of type bool --- @realm shared --- @bool HiddenInGame - ---- --- Position, Field of type Vector2 --- @realm shared --- @Vector2 Position - ---- --- SimPosition, Field of type Vector2 --- @realm shared --- @Vector2 SimPosition - ---- --- SoundRange, Field of type number --- @realm shared --- @number SoundRange - ---- --- SightRange, Field of type number --- @realm shared --- @number SightRange - ---- --- RemoveIfLinkedOutpostDoorInUse, Field of type bool --- @realm shared --- @bool RemoveIfLinkedOutpostDoorInUse - ---- --- Layer, Field of type string --- @realm shared --- @string Layer - ---- --- Removed, Field of type bool --- @realm shared --- @bool Removed - ---- --- IdFreed, Field of type bool --- @realm shared --- @bool IdFreed - ---- --- WorldPosition, Field of type Vector2 --- @realm shared --- @Vector2 WorldPosition - ---- --- DrawPosition, Field of type Vector2 --- @realm shared --- @Vector2 DrawPosition - ---- --- Submarine, Field of type Submarine --- @realm shared --- @Submarine Submarine - ---- --- AiTarget, Field of type AITarget --- @realm shared --- @AITarget AiTarget - ---- --- InDetectable, Field of type bool --- @realm shared --- @bool InDetectable - ---- --- SpawnTime, Field of type number --- @realm shared --- @number SpawnTime - ---- --- ErrorLine, Field of type string --- @realm shared --- @string ErrorLine - ---- --- properties, Field of type table --- @realm shared --- @table properties - ---- --- Visible, Field of type bool --- @realm shared --- @bool Visible - ---- --- ConnectedGaps, Field of type table --- @realm shared --- @table ConnectedGaps - ---- --- OriginalAmbientLight, Field of type Nullable`1 --- @realm shared --- @Nullable`1 OriginalAmbientLight - ---- --- xBackgroundMax, Field of type number --- @realm shared --- @number xBackgroundMax - ---- --- yBackgroundMax, Field of type number --- @realm shared --- @number yBackgroundMax - ---- --- Hull.HullList, Field of type table --- @realm shared --- @table Hull.HullList - ---- --- Hull.EntityGrids, Field of type table --- @realm shared --- @table Hull.EntityGrids - ---- --- Hull.ShowHulls, Field of type bool --- @realm shared --- @bool Hull.ShowHulls - ---- --- Hull.EditWater, Field of type bool --- @realm shared --- @bool Hull.EditWater - ---- --- Hull.EditFire, Field of type bool --- @realm shared --- @bool Hull.EditFire - ---- --- Hull.WaveStiffness, Field of type number --- @realm shared --- @number Hull.WaveStiffness - ---- --- Hull.WaveSpread, Field of type number --- @realm shared --- @number Hull.WaveSpread - ---- --- Hull.WaveDampening, Field of type number --- @realm shared --- @number Hull.WaveDampening - ---- --- Hull.OxygenDistributionSpeed, Field of type number --- @realm shared --- @number Hull.OxygenDistributionSpeed - ---- --- Hull.OxygenDeteriorationSpeed, Field of type number --- @realm shared --- @number Hull.OxygenDeteriorationSpeed - ---- --- Hull.OxygenConsumptionSpeed, Field of type number --- @realm shared --- @number Hull.OxygenConsumptionSpeed - ---- --- Hull.WaveWidth, Field of type number --- @realm shared --- @number Hull.WaveWidth - ---- --- Hull.MaxCompress, Field of type number --- @realm shared --- @number Hull.MaxCompress - ---- --- Hull.BackgroundSectionSize, Field of type number --- @realm shared --- @number Hull.BackgroundSectionSize - ---- --- Hull.BackgroundSectionsPerNetworkEvent, Field of type number --- @realm shared --- @number Hull.BackgroundSectionsPerNetworkEvent - ---- --- Hull.MaxDecalsPerHull, Field of type number --- @realm shared --- @number Hull.MaxDecalsPerHull - ---- --- Prefab, Field of type MapEntityPrefab --- @realm shared --- @MapEntityPrefab Prefab - ---- --- unresolvedLinkedToID, Field of type table --- @realm shared --- @table unresolvedLinkedToID - ---- --- DisallowedUpgradeSet, Field of type HashSet`1 --- @realm shared --- @HashSet`1 DisallowedUpgradeSet - ---- --- linkedTo, Field of type table --- @realm shared --- @table linkedTo - ---- --- ShouldBeSaved, Field of type bool --- @realm shared --- @bool ShouldBeSaved - ---- --- ExternalHighlight, Field of type bool --- @realm shared --- @bool ExternalHighlight - ---- --- OriginalModuleIndex, Field of type number --- @realm shared --- @number OriginalModuleIndex - ---- --- OriginalContainerIndex, Field of type number --- @realm shared --- @number OriginalContainerIndex - ---- --- ID, Field of type number --- @realm shared --- @number ID - ---- --- CreationStackTrace, Field of type string --- @realm shared --- @string CreationStackTrace - ---- --- CreationIndex, Field of type number --- @realm shared --- @number CreationIndex - diff --git a/docs/lua/generated/Inventory.lua b/docs/lua/generated/Inventory.lua deleted file mode 100644 index bc009be5a..000000000 --- a/docs/lua/generated/Inventory.lua +++ /dev/null @@ -1,276 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.Inventory -]] --- @code Inventory --- @pragma nostrip -local Inventory = {} - ---- ServerEventRead --- @realm shared --- @tparam IReadMessage msg --- @tparam Client c -function ServerEventRead(msg, c) end - ---- ServerEventWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c --- @tparam IData extraData -function ServerEventWrite(msg, c, extraData) end - ---- Contains --- @realm shared --- @tparam Item item --- @treturn bool -function Contains(item) end - ---- FirstOrDefault --- @realm shared --- @treturn Item -function FirstOrDefault() end - ---- LastOrDefault --- @realm shared --- @treturn Item -function LastOrDefault() end - ---- GetItemAt --- @realm shared --- @tparam number index --- @treturn Item -function GetItemAt(index) end - ---- GetItemsAt --- @realm shared --- @tparam number index --- @treturn Enumerable -function GetItemsAt(index) end - ---- FindIndex --- @realm shared --- @tparam Item item --- @treturn number -function FindIndex(item) end - ---- FindIndices --- @realm shared --- @tparam Item item --- @treturn table -function FindIndices(item) end - ---- ItemOwnsSelf --- @realm shared --- @tparam Item item --- @treturn bool -function ItemOwnsSelf(item) end - ---- FindAllowedSlot --- @realm shared --- @tparam Item item --- @tparam bool ignoreCondition --- @treturn number -function FindAllowedSlot(item, ignoreCondition) end - ---- CanBePut --- @realm shared --- @tparam Item item --- @treturn bool -function CanBePut(item) end - ---- CanBePutInSlot --- @realm shared --- @tparam Item item --- @tparam number i --- @tparam bool ignoreCondition --- @treturn bool -function CanBePutInSlot(item, i, ignoreCondition) end - ---- CanBePut --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam Nullable`1 condition --- @tparam Nullable`1 quality --- @treturn bool -function CanBePut(itemPrefab, condition, quality) end - ---- CanBePutInSlot --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam number i --- @tparam Nullable`1 condition --- @tparam Nullable`1 quality --- @treturn bool -function CanBePutInSlot(itemPrefab, i, condition, quality) end - ---- HowManyCanBePut --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam Nullable`1 condition --- @treturn number -function HowManyCanBePut(itemPrefab, condition) end - ---- HowManyCanBePut --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam number i --- @tparam Nullable`1 condition --- @treturn number -function HowManyCanBePut(itemPrefab, i, condition) end - ---- TryPutItem --- @realm shared --- @tparam Item item --- @tparam Character user --- @tparam Enumerable allowedSlots --- @tparam bool createNetworkEvent --- @tparam bool ignoreCondition --- @treturn bool -function TryPutItem(item, user, allowedSlots, createNetworkEvent, ignoreCondition) end - ---- TryPutItem --- @realm shared --- @tparam Item item --- @tparam number i --- @tparam bool allowSwapping --- @tparam bool allowCombine --- @tparam Character user --- @tparam bool createNetworkEvent --- @tparam bool ignoreCondition --- @treturn bool -function TryPutItem(item, i, allowSwapping, allowCombine, user, createNetworkEvent, ignoreCondition) end - ---- IsEmpty --- @realm shared --- @treturn bool -function IsEmpty() end - ---- IsFull --- @realm shared --- @tparam bool takeStacksIntoAccount --- @treturn bool -function IsFull(takeStacksIntoAccount) end - ---- CreateNetworkEvent --- @realm shared -function CreateNetworkEvent() end - ---- FindItem --- @realm shared --- @tparam function predicate --- @tparam bool recursive --- @treturn Item -function FindItem(predicate, recursive) end - ---- FindAllItems --- @realm shared --- @tparam function predicate --- @tparam bool recursive --- @tparam table list --- @treturn table -function FindAllItems(predicate, recursive, list) end - ---- FindItemByTag --- @realm shared --- @tparam Identifier tag --- @tparam bool recursive --- @treturn Item -function FindItemByTag(tag, recursive) end - ---- FindItemByIdentifier --- @realm shared --- @tparam Identifier identifier --- @tparam bool recursive --- @treturn Item -function FindItemByIdentifier(identifier, recursive) end - ---- RemoveItem --- @realm shared --- @tparam Item item -function RemoveItem(item) end - ---- ForceToSlot --- @realm shared --- @tparam Item item --- @tparam number index -function ForceToSlot(item, index) end - ---- ForceRemoveFromSlot --- @realm shared --- @tparam Item item --- @tparam number index -function ForceRemoveFromSlot(item, index) end - ---- SharedRead --- @realm shared --- @tparam IReadMessage msg --- @tparam List`1[]& newItemIds -function SharedRead(msg, newItemIds) end - ---- SharedWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam IData extraData -function SharedWrite(msg, extraData) end - ---- DeleteAllItems --- @realm shared -function DeleteAllItems() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- AllItems, Field of type Enumerable --- @realm shared --- @Enumerable AllItems - ---- --- AllItemsMod, Field of type Enumerable --- @realm shared --- @Enumerable AllItemsMod - ---- --- Capacity, Field of type number --- @realm shared --- @number Capacity - ---- --- Owner, Field of type Entity --- @realm shared --- @Entity Owner - ---- --- Locked, Field of type bool --- @realm shared --- @bool Locked - ---- --- AllowSwappingContainedItems, Field of type bool --- @realm shared --- @bool AllowSwappingContainedItems - ---- --- Inventory.MaxStackSize, Field of type number --- @realm shared --- @number Inventory.MaxStackSize - diff --git a/docs/lua/generated/Item.lua b/docs/lua/generated/Item.lua deleted file mode 100644 index 240d48f5a..000000000 --- a/docs/lua/generated/Item.lua +++ /dev/null @@ -1,1254 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma Item class with some additional functions and fields - -Barotrauma source code: [Item.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs) -]] --- @code Item --- @pragma nostrip - -Item = {} - ---- Adds to remove queue, use this instead of Remove, to prevent desync. --- @realm server -function Item.AddToRemoveQueue(item) end - ---- Gets a component from an item by a string name. --- @treturn Component component --- @realm server -function GetComponentString(componentName) end - ---- Sends a signal. --- @realm server -function SendSignal(signalOrString, connectionOrConnectionName) end - ---- --- Physics body of the item. --- @realm shared --- @PhysicsBody body --- @usage --- Item.ItemList[1].body.position = CreateVector2(0, 0) -- teleports first item created to 0, 0 of the level - ---- --- Item.ItemList, Table containing all items. --- @realm shared --- @Item Item.ItemList - ---- --- Prefab, ItemPrefab containing the original prefab of the item. --- @realm shared --- @ItemPrefab Prefab - ---- --- WorldPosition, Vector2 position of the item in the world --- @realm shared --- @Vector2 WorldPosition - - ---- ApplyStatusEffects --- @realm shared --- @tparam function type --- @tparam number deltaTime --- @tparam Character character --- @tparam Limb limb --- @tparam Entity useTarget --- @tparam bool isNetworkEvent --- @tparam Nullable`1 worldPosition -function ApplyStatusEffects(type, deltaTime, character, limb, useTarget, isNetworkEvent, worldPosition) end - ---- ApplyStatusEffect --- @realm shared --- @tparam StatusEffect effect --- @tparam function type --- @tparam number deltaTime --- @tparam Character character --- @tparam Limb limb --- @tparam Entity useTarget --- @tparam bool isNetworkEvent --- @tparam bool checkCondition --- @tparam Nullable`1 worldPosition -function ApplyStatusEffect(effect, type, deltaTime, character, limb, useTarget, isNetworkEvent, checkCondition, worldPosition) end - ---- AddDamage --- @realm shared --- @tparam Character attacker --- @tparam Vector2 worldPosition --- @tparam Attack attack --- @tparam number deltaTime --- @tparam bool playSound --- @treturn AttackResult -function AddDamage(attacker, worldPosition, attack, deltaTime, playSound) end - ---- SendPendingNetworkUpdates --- @realm shared -function SendPendingNetworkUpdates() end - ---- CreateStatusEvent --- @realm shared -function CreateStatusEvent() end - ---- Update --- @realm shared --- @tparam number deltaTime --- @tparam Camera cam -function Update(deltaTime, cam) end - ---- UpdateTransform --- @realm shared -function UpdateTransform() end - ---- FlipX --- @realm shared --- @tparam bool relativeToSub -function FlipX(relativeToSub) end - ---- FlipY --- @realm shared --- @tparam bool relativeToSub -function FlipY(relativeToSub) end - ---- GetConnectedComponents --- @realm shared --- @tparam bool recursive --- @tparam bool allowTraversingBackwards --- @treturn table -function GetConnectedComponents(recursive, allowTraversingBackwards) end - ---- GetConnectedComponentsRecursive --- @realm shared --- @tparam Connection c --- @tparam bool ignoreInactiveRelays --- @tparam bool allowTraversingBackwards --- @treturn table -function GetConnectedComponentsRecursive(c, ignoreInactiveRelays, allowTraversingBackwards) end - ---- FindController --- @realm shared --- @tparam Nullable`1 tags --- @treturn Controller -function FindController(tags) end - ---- TryFindController --- @realm shared --- @tparam Controller& controller --- @tparam Nullable`1 tags --- @treturn bool -function TryFindController(controller, tags) end - ---- SendSignal --- @realm shared --- @tparam string signal --- @tparam string connectionName -function SendSignal(signal, connectionName) end - ---- SendSignal --- @realm shared --- @tparam Signal signal --- @tparam string connectionName -function SendSignal(signal, connectionName) end - ---- SendSignal --- @realm shared --- @tparam Signal signal --- @tparam Connection connection -function SendSignal(signal, connection) end - ---- IsInsideTrigger --- @realm shared --- @tparam Vector2 worldPosition --- @treturn bool -function IsInsideTrigger(worldPosition) end - ---- IsInsideTrigger --- @realm shared --- @tparam Vector2 worldPosition --- @tparam Rectangle& transformedTrigger --- @treturn bool -function IsInsideTrigger(worldPosition, transformedTrigger) end - ---- CanClientAccess --- @realm shared --- @tparam Client c --- @treturn bool -function CanClientAccess(c) end - ---- TryInteract --- @realm shared --- @tparam Character user --- @tparam bool ignoreRequiredItems --- @tparam bool forceSelectKey --- @tparam bool forceUseKey --- @treturn bool -function TryInteract(user, ignoreRequiredItems, forceSelectKey, forceUseKey) end - ---- GetContainedItemConditionPercentage --- @realm shared --- @treturn number -function GetContainedItemConditionPercentage() end - ---- Use --- @realm shared --- @tparam number deltaTime --- @tparam Character character --- @tparam Limb targetLimb -function Use(deltaTime, character, targetLimb) end - ---- SecondaryUse --- @realm shared --- @tparam number deltaTime --- @tparam Character character -function SecondaryUse(deltaTime, character) end - ---- ApplyTreatment --- @realm shared --- @tparam Character user --- @tparam Character character --- @tparam Limb targetLimb -function ApplyTreatment(user, character, targetLimb) end - ---- Combine --- @realm shared --- @tparam Item item --- @tparam Character user --- @treturn bool -function Combine(item, user) end - ---- Drop --- @realm shared --- @tparam Character dropper --- @tparam bool createNetworkEvent --- @tparam bool setTransform -function Drop(dropper, createNetworkEvent, setTransform) end - ---- Equip --- @realm shared --- @tparam Character character -function Equip(character) end - ---- Unequip --- @realm shared --- @tparam Character character -function Unequip(character) end - ---- GetProperties --- @realm shared --- @treturn table -function GetProperties() end - ---- Load --- @realm shared --- @tparam ContentXElement element --- @tparam Submarine submarine --- @tparam IdRemap idRemap --- @treturn Item -function Item.Load(element, submarine, idRemap) end - ---- Load --- @realm shared --- @tparam ContentXElement element --- @tparam Submarine submarine --- @tparam bool createNetworkEvent --- @tparam IdRemap idRemap --- @treturn Item -function Item.Load(element, submarine, createNetworkEvent, idRemap) end - ---- Save --- @realm shared --- @tparam XElement parentElement --- @treturn XElement -function Save(parentElement) end - ---- Reset --- @realm shared -function Reset() end - ---- OnMapLoaded --- @realm shared -function OnMapLoaded() end - ---- ShallowRemove --- @realm shared -function ShallowRemove() end - ---- Remove --- @realm shared -function Remove() end - ---- RemoveByPrefab --- @realm shared --- @tparam ItemPrefab prefab -function Item.RemoveByPrefab(prefab) end - ---- GetComponentString --- @realm shared --- @tparam string component --- @treturn Object -function GetComponentString(component) end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- IgnoreByAI --- @realm shared --- @tparam Character character --- @treturn bool -function IgnoreByAI(character) end - ---- IsContainerPreferred --- @realm shared --- @tparam ItemContainer container --- @tparam Boolean& isPreferencesDefined --- @tparam Boolean& isSecondary --- @tparam bool requireConditionRestriction --- @treturn bool -function IsContainerPreferred(container, isPreferencesDefined, isSecondary, requireConditionRestriction) end - ---- Clone --- @realm shared --- @treturn MapEntity -function Clone() end - ---- AddComponent --- @realm shared --- @tparam ItemComponent component -function AddComponent(component) end - ---- EnableDrawableComponent --- @realm shared --- @tparam IDrawableComponent drawable -function EnableDrawableComponent(drawable) end - ---- DisableDrawableComponent --- @realm shared --- @tparam IDrawableComponent drawable -function DisableDrawableComponent(drawable) end - ---- GetComponentIndex --- @realm shared --- @tparam ItemComponent component --- @treturn number -function GetComponentIndex(component) end - ---- GetComponent --- @realm shared --- @treturn T -function GetComponent() end - ---- GetComponents --- @realm shared --- @treturn Enumerable -function GetComponents() end - ---- GetQualityModifier --- @realm shared --- @tparam StatType statType --- @treturn number -function GetQualityModifier(statType) end - ---- RemoveContained --- @realm shared --- @tparam Item contained -function RemoveContained(contained) end - ---- SetTransform --- @realm shared --- @tparam Vector2 simPosition --- @tparam number rotation --- @tparam bool findNewHull --- @tparam bool setPrevTransform -function SetTransform(simPosition, rotation, findNewHull, setPrevTransform) end - ---- AllowDroppingOnSwapWith --- @realm shared --- @tparam Item otherItem --- @treturn bool -function AllowDroppingOnSwapWith(otherItem) end - ---- SetActiveSprite --- @realm shared -function SetActiveSprite() end - ---- Move --- @realm shared --- @tparam Vector2 amount -function Move(amount) end - ---- Move --- @realm shared --- @tparam Vector2 amount --- @tparam bool ignoreContacts -function Move(amount, ignoreContacts) end - ---- TransformTrigger --- @realm shared --- @tparam Rectangle trigger --- @tparam bool world --- @treturn Rectangle -function TransformTrigger(trigger, world) end - ---- UpdateHulls --- @realm shared -function Item.UpdateHulls() end - ---- FindHull --- @realm shared --- @treturn Hull -function FindHull() end - ---- GetRootContainer --- @realm shared --- @treturn Item -function GetRootContainer() end - ---- HasAccess --- @realm shared --- @tparam Character character --- @treturn bool -function HasAccess(character) end - ---- IsOwnedBy --- @realm shared --- @tparam Entity entity --- @treturn bool -function IsOwnedBy(entity) end - ---- GetRootInventoryOwner --- @realm shared --- @treturn Entity -function GetRootInventoryOwner() end - ---- FindParentInventory --- @realm shared --- @tparam function predicate --- @treturn Inventory -function FindParentInventory(predicate) end - ---- SetContainedItemPositions --- @realm shared -function SetContainedItemPositions() end - ---- AddTag --- @realm shared --- @tparam string tag -function AddTag(tag) end - ---- AddTag --- @realm shared --- @tparam Identifier tag -function AddTag(tag) end - ---- HasTag --- @realm shared --- @tparam string tag --- @treturn bool -function HasTag(tag) end - ---- HasTag --- @realm shared --- @tparam Identifier tag --- @treturn bool -function HasTag(tag) end - ---- ReplaceTag --- @realm shared --- @tparam string tag --- @tparam string newTag -function ReplaceTag(tag, newTag) end - ---- ReplaceTag --- @realm shared --- @tparam Identifier tag --- @tparam Identifier newTag -function ReplaceTag(tag, newTag) end - ---- GetTags --- @realm shared --- @treturn Enumerable -function GetTags() end - ---- HasTag --- @realm shared --- @tparam Enumerable allowedTags --- @treturn bool -function HasTag(allowedTags) end - ---- ServerEventWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c --- @tparam IData extraData -function ServerEventWrite(msg, c, extraData) end - ---- ServerEventRead --- @realm shared --- @tparam IReadMessage msg --- @tparam Client c -function ServerEventRead(msg, c) end - ---- WriteSpawnData --- @realm shared --- @tparam IWriteMessage msg --- @tparam number entityID --- @tparam number originalInventoryID --- @tparam Byte originalItemContainerIndex --- @tparam number originalSlotIndex -function WriteSpawnData(msg, entityID, originalInventoryID, originalItemContainerIndex, originalSlotIndex) end - ---- GetPositionUpdateInterval --- @realm shared --- @tparam Client recipient --- @treturn number -function GetPositionUpdateInterval(recipient) end - ---- ServerWritePosition --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c -function ServerWritePosition(msg, c) end - ---- CreateServerEvent --- @realm shared --- @tparam T ic -function CreateServerEvent(ic) end - ---- CreateServerEvent --- @realm shared --- @tparam T ic --- @tparam IEventData extraData -function CreateServerEvent(ic, extraData) end - ---- TryCreateServerEventSpam --- @realm shared -function TryCreateServerEventSpam() end - ---- CreateServerEventString --- @realm shared --- @tparam string component --- @treturn Object -function CreateServerEventString(component) end - ---- CreateServerEventString --- @realm shared --- @tparam string component --- @tparam Object[] extraData --- @treturn Object -function CreateServerEventString(component, extraData) end - ---- IsInteractable --- @realm shared --- @tparam Character character --- @treturn bool -function IsInteractable(character) end - ---- AddLinked --- @realm shared --- @tparam MapEntity entity -function AddLinked(entity) end - ---- ResolveLinks --- @realm shared --- @tparam IdRemap childRemap -function ResolveLinks(childRemap) end - ---- IsMouseOn --- @realm shared --- @tparam Vector2 position --- @treturn bool -function IsMouseOn(position) end - ---- HasUpgrade --- @realm shared --- @tparam Identifier identifier --- @treturn bool -function HasUpgrade(identifier) end - ---- GetUpgrade --- @realm shared --- @tparam Identifier identifier --- @treturn Upgrade -function GetUpgrade(identifier) end - ---- GetUpgrades --- @realm shared --- @treturn table -function GetUpgrades() end - ---- SetUpgrade --- @realm shared --- @tparam Upgrade upgrade --- @tparam bool createNetworkEvent -function SetUpgrade(upgrade, createNetworkEvent) end - ---- AddUpgrade --- @realm shared --- @tparam Upgrade upgrade --- @tparam bool createNetworkEvent --- @treturn bool -function AddUpgrade(upgrade, createNetworkEvent) end - ---- RemoveLinked --- @realm shared --- @tparam MapEntity e -function RemoveLinked(e) end - ---- GetLinkedEntities --- @realm shared --- @tparam HashSet`1 list --- @tparam Nullable`1 maxDepth --- @tparam function filter --- @treturn HashSet`1 -function GetLinkedEntities(list, maxDepth, filter) end - ---- FreeID --- @realm shared -function FreeID() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Sprite, Field of type Sprite --- @realm shared --- @Sprite Sprite - ---- --- Prefab, Field of type ItemPrefab --- @realm shared --- @ItemPrefab Prefab - ---- --- CurrentHull, Field of type Hull --- @realm shared --- @Hull CurrentHull - ---- --- HullOxygenPercentage, Field of type number --- @realm shared --- @number HullOxygenPercentage - ---- --- CampaignInteractionType, Field of type InteractionType --- @realm shared --- @InteractionType CampaignInteractionType - ---- --- DefaultRect, Field of type Rectangle --- @realm shared --- @Rectangle DefaultRect - ---- --- SerializableProperties, Field of type table --- @realm shared --- @table SerializableProperties - ---- --- EditableWhenEquipped, Field of type bool --- @realm shared --- @bool EditableWhenEquipped - ---- --- ParentInventory, Field of type Inventory --- @realm shared --- @Inventory ParentInventory - ---- --- Container, Field of type Item --- @realm shared --- @Item Container - ---- --- Name, Field of type string --- @realm shared --- @string Name - ---- --- Description, Field of type string --- @realm shared --- @string Description - ---- --- NonInteractable, Field of type bool --- @realm shared --- @bool NonInteractable - ---- --- NonPlayerTeamInteractable, Field of type bool --- @realm shared --- @bool NonPlayerTeamInteractable - ---- --- AllowSwapping, Field of type bool --- @realm shared --- @bool AllowSwapping - ---- --- PurchasedNewSwap, Field of type bool --- @realm shared --- @bool PurchasedNewSwap - ---- --- IsPlayerTeamInteractable, Field of type bool --- @realm shared --- @bool IsPlayerTeamInteractable - ---- --- Rotation, Field of type number --- @realm shared --- @number Rotation - ---- --- ImpactTolerance, Field of type number --- @realm shared --- @number ImpactTolerance - ---- --- InteractDistance, Field of type number --- @realm shared --- @number InteractDistance - ---- --- InteractPriority, Field of type number --- @realm shared --- @number InteractPriority - ---- --- Position, Field of type Vector2 --- @realm shared --- @Vector2 Position - ---- --- SimPosition, Field of type Vector2 --- @realm shared --- @Vector2 SimPosition - ---- --- InteractionRect, Field of type Rectangle --- @realm shared --- @Rectangle InteractionRect - ---- --- Scale, Field of type number --- @realm shared --- @number Scale - ---- --- PositionUpdateInterval, Field of type number --- @realm shared --- @number PositionUpdateInterval - ---- --- SpriteColor, Field of type Color --- @realm shared --- @Color SpriteColor - ---- --- InventoryIconColor, Field of type Color --- @realm shared --- @Color InventoryIconColor - ---- --- ContainerColor, Field of type Color --- @realm shared --- @Color ContainerColor - ---- --- ContainerIdentifier, Field of type Identifier --- @realm shared --- @Identifier ContainerIdentifier - ---- --- SonarLabel, Field of type string --- @realm shared --- @string SonarLabel - ---- --- PhysicsBodyActive, Field of type bool --- @realm shared --- @bool PhysicsBodyActive - ---- --- SoundRange, Field of type number --- @realm shared --- @number SoundRange - ---- --- SightRange, Field of type number --- @realm shared --- @number SightRange - ---- --- IsShootable, Field of type bool --- @realm shared --- @bool IsShootable - ---- --- RequireAimToUse, Field of type bool --- @realm shared --- @bool RequireAimToUse - ---- --- RequireAimToSecondaryUse, Field of type bool --- @realm shared --- @bool RequireAimToSecondaryUse - ---- --- Color, Field of type Color --- @realm shared --- @Color Color - ---- --- IsFullCondition, Field of type bool --- @realm shared --- @bool IsFullCondition - ---- --- MaxCondition, Field of type number --- @realm shared --- @number MaxCondition - ---- --- ConditionPercentage, Field of type number --- @realm shared --- @number ConditionPercentage - ---- --- OffsetOnSelectedMultiplier, Field of type number --- @realm shared --- @number OffsetOnSelectedMultiplier - ---- --- HealthMultiplier, Field of type number --- @realm shared --- @number HealthMultiplier - ---- --- MaxRepairConditionMultiplier, Field of type number --- @realm shared --- @number MaxRepairConditionMultiplier - ---- --- Condition, Field of type number --- @realm shared --- @number Condition - ---- --- ConditionIncreasedRecently, Field of type bool --- @realm shared --- @bool ConditionIncreasedRecently - ---- --- Health, Field of type number --- @realm shared --- @number Health - ---- --- Indestructible, Field of type bool --- @realm shared --- @bool Indestructible - ---- --- AllowDeconstruct, Field of type bool --- @realm shared --- @bool AllowDeconstruct - ---- --- InvulnerableToDamage, Field of type bool --- @realm shared --- @bool InvulnerableToDamage - ---- --- SpawnedInCurrentOutpost, Field of type bool --- @realm shared --- @bool SpawnedInCurrentOutpost - ---- --- AllowStealing, Field of type bool --- @realm shared --- @bool AllowStealing - ---- --- OriginalOutpost, Field of type string --- @realm shared --- @string OriginalOutpost - ---- --- Tags, Field of type string --- @realm shared --- @string Tags - ---- --- FireProof, Field of type bool --- @realm shared --- @bool FireProof - ---- --- WaterProof, Field of type bool --- @realm shared --- @bool WaterProof - ---- --- UseInHealthInterface, Field of type bool --- @realm shared --- @bool UseInHealthInterface - ---- --- Quality, Field of type number --- @realm shared --- @number Quality - ---- --- InWater, Field of type bool --- @realm shared --- @bool InWater - ---- --- LastSentSignalRecipients, Field of type table --- @realm shared --- @table LastSentSignalRecipients - ---- --- ConfigFilePath, Field of type ContentPath --- @realm shared --- @ContentPath ConfigFilePath - ---- --- AllowedSlots, Field of type Enumerable --- @realm shared --- @Enumerable AllowedSlots - ---- --- Connections, Field of type table --- @realm shared --- @table Connections - ---- --- ContainedItems, Field of type Enumerable --- @realm shared --- @Enumerable ContainedItems - ---- --- OwnInventory, Field of type ItemInventory --- @realm shared --- @ItemInventory OwnInventory - ---- --- DisplaySideBySideWhenLinked, Field of type bool --- @realm shared --- @bool DisplaySideBySideWhenLinked - ---- --- Repairables, Field of type table --- @realm shared --- @table Repairables - ---- --- Components, Field of type table --- @realm shared --- @table Components - ---- --- Linkable, Field of type bool --- @realm shared --- @bool Linkable - ---- --- PositionX, Field of type number --- @realm shared --- @number PositionX - ---- --- PositionY, Field of type number --- @realm shared --- @number PositionY - ---- --- Infector, Field of type BallastFloraBranch --- @realm shared --- @BallastFloraBranch Infector - ---- --- PendingItemSwap, Field of type ItemPrefab --- @realm shared --- @ItemPrefab PendingItemSwap - ---- --- AllPropertyObjects, Field of type IReadOnlyList`1 --- @realm shared --- @IReadOnlyList`1 AllPropertyObjects - ---- --- OrderedToBeIgnored, Field of type bool --- @realm shared --- @bool OrderedToBeIgnored - ---- --- HasBallastFloraInHull, Field of type bool --- @realm shared --- @bool HasBallastFloraInHull - ---- --- IsClaimedByBallastFlora, Field of type bool --- @realm shared --- @bool IsClaimedByBallastFlora - ---- --- DisallowedUpgrades, Field of type string --- @realm shared --- @string DisallowedUpgrades - ---- --- FlippedX, Field of type bool --- @realm shared --- @bool FlippedX - ---- --- FlippedY, Field of type bool --- @realm shared --- @bool FlippedY - ---- --- IsHighlighted, Field of type bool --- @realm shared --- @bool IsHighlighted - ---- --- Rect, Field of type Rectangle --- @realm shared --- @Rectangle Rect - ---- --- WorldRect, Field of type Rectangle --- @realm shared --- @Rectangle WorldRect - ---- --- DrawBelowWater, Field of type bool --- @realm shared --- @bool DrawBelowWater - ---- --- DrawOverWater, Field of type bool --- @realm shared --- @bool DrawOverWater - ---- --- AllowedLinks, Field of type Enumerable --- @realm shared --- @Enumerable AllowedLinks - ---- --- ResizeHorizontal, Field of type bool --- @realm shared --- @bool ResizeHorizontal - ---- --- ResizeVertical, Field of type bool --- @realm shared --- @bool ResizeVertical - ---- --- RectWidth, Field of type number --- @realm shared --- @number RectWidth - ---- --- RectHeight, Field of type number --- @realm shared --- @number RectHeight - ---- --- SpriteDepthOverrideIsSet, Field of type bool --- @realm shared --- @bool SpriteDepthOverrideIsSet - ---- --- SpriteOverrideDepth, Field of type number --- @realm shared --- @number SpriteOverrideDepth - ---- --- SpriteDepth, Field of type number --- @realm shared --- @number SpriteDepth - ---- --- HiddenInGame, Field of type bool --- @realm shared --- @bool HiddenInGame - ---- --- RemoveIfLinkedOutpostDoorInUse, Field of type bool --- @realm shared --- @bool RemoveIfLinkedOutpostDoorInUse - ---- --- Layer, Field of type string --- @realm shared --- @string Layer - ---- --- Removed, Field of type bool --- @realm shared --- @bool Removed - ---- --- IdFreed, Field of type bool --- @realm shared --- @bool IdFreed - ---- --- WorldPosition, Field of type Vector2 --- @realm shared --- @Vector2 WorldPosition - ---- --- DrawPosition, Field of type Vector2 --- @realm shared --- @Vector2 DrawPosition - ---- --- Submarine, Field of type Submarine --- @realm shared --- @Submarine Submarine - ---- --- AiTarget, Field of type AITarget --- @realm shared --- @AITarget AiTarget - ---- --- InDetectable, Field of type bool --- @realm shared --- @bool InDetectable - ---- --- SpawnTime, Field of type number --- @realm shared --- @number SpawnTime - ---- --- ErrorLine, Field of type string --- @realm shared --- @string ErrorLine - ---- --- PreviousParentInventory, Field of type Inventory --- @realm shared --- @Inventory PreviousParentInventory - ---- --- Visible, Field of type bool --- @realm shared --- @bool Visible - ---- --- body, Field of type PhysicsBody --- @realm shared --- @PhysicsBody body - ---- --- StaticBodyConfig, Field of type XElement --- @realm shared --- @XElement StaticBodyConfig - ---- --- StaticFixtures, Field of type table --- @realm shared --- @table StaticFixtures - ---- --- StolenDuringRound, Field of type bool --- @realm shared --- @bool StolenDuringRound - ---- --- AvailableSwaps, Field of type HashSet`1 --- @realm shared --- @HashSet`1 AvailableSwaps - ---- --- Item.ItemList, Field of type table --- @realm shared --- @table Item.ItemList - ---- --- Item.ShowLinks, Field of type bool --- @realm shared --- @bool Item.ShowLinks - ---- --- Item.connectionPairs, Field of type ImmutableArray`1 --- @realm shared --- @ImmutableArray`1 Item.connectionPairs - ---- --- Prefab, Field of type MapEntityPrefab --- @realm shared --- @MapEntityPrefab Prefab - ---- --- unresolvedLinkedToID, Field of type table --- @realm shared --- @table unresolvedLinkedToID - ---- --- DisallowedUpgradeSet, Field of type HashSet`1 --- @realm shared --- @HashSet`1 DisallowedUpgradeSet - ---- --- linkedTo, Field of type table --- @realm shared --- @table linkedTo - ---- --- ShouldBeSaved, Field of type bool --- @realm shared --- @bool ShouldBeSaved - ---- --- ExternalHighlight, Field of type bool --- @realm shared --- @bool ExternalHighlight - ---- --- OriginalModuleIndex, Field of type number --- @realm shared --- @number OriginalModuleIndex - ---- --- OriginalContainerIndex, Field of type number --- @realm shared --- @number OriginalContainerIndex - ---- --- ID, Field of type number --- @realm shared --- @number ID - ---- --- CreationStackTrace, Field of type string --- @realm shared --- @string CreationStackTrace - ---- --- CreationIndex, Field of type number --- @realm shared --- @number CreationIndex - diff --git a/docs/lua/generated/ItemInventory.lua b/docs/lua/generated/ItemInventory.lua deleted file mode 100644 index f7b914b4e..000000000 --- a/docs/lua/generated/ItemInventory.lua +++ /dev/null @@ -1,276 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.ItemInventory -]] --- @code ItemInventory --- @pragma nostrip -local ItemInventory = {} - ---- FindAllowedSlot --- @realm shared --- @tparam Item item --- @tparam bool ignoreCondition --- @treturn number -function FindAllowedSlot(item, ignoreCondition) end - ---- CanBePutInSlot --- @realm shared --- @tparam Item item --- @tparam number i --- @tparam bool ignoreCondition --- @treturn bool -function CanBePutInSlot(item, i, ignoreCondition) end - ---- CanBePutInSlot --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam number i --- @tparam Nullable`1 condition --- @tparam Nullable`1 quality --- @treturn bool -function CanBePutInSlot(itemPrefab, i, condition, quality) end - ---- HowManyCanBePut --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam number i --- @tparam Nullable`1 condition --- @treturn number -function HowManyCanBePut(itemPrefab, i, condition) end - ---- IsFull --- @realm shared --- @tparam bool takeStacksIntoAccount --- @treturn bool -function IsFull(takeStacksIntoAccount) end - ---- TryPutItem --- @realm shared --- @tparam Item item --- @tparam Character user --- @tparam Enumerable allowedSlots --- @tparam bool createNetworkEvent --- @tparam bool ignoreCondition --- @treturn bool -function TryPutItem(item, user, allowedSlots, createNetworkEvent, ignoreCondition) end - ---- TryPutItem --- @realm shared --- @tparam Item item --- @tparam number i --- @tparam bool allowSwapping --- @tparam bool allowCombine --- @tparam Character user --- @tparam bool createNetworkEvent --- @tparam bool ignoreCondition --- @treturn bool -function TryPutItem(item, i, allowSwapping, allowCombine, user, createNetworkEvent, ignoreCondition) end - ---- CreateNetworkEvent --- @realm shared -function CreateNetworkEvent() end - ---- RemoveItem --- @realm shared --- @tparam Item item -function RemoveItem(item) end - ---- ServerEventRead --- @realm shared --- @tparam IReadMessage msg --- @tparam Client c -function ServerEventRead(msg, c) end - ---- ServerEventWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c --- @tparam IData extraData -function ServerEventWrite(msg, c, extraData) end - ---- Contains --- @realm shared --- @tparam Item item --- @treturn bool -function Contains(item) end - ---- FirstOrDefault --- @realm shared --- @treturn Item -function FirstOrDefault() end - ---- LastOrDefault --- @realm shared --- @treturn Item -function LastOrDefault() end - ---- GetItemAt --- @realm shared --- @tparam number index --- @treturn Item -function GetItemAt(index) end - ---- GetItemsAt --- @realm shared --- @tparam number index --- @treturn Enumerable -function GetItemsAt(index) end - ---- FindIndex --- @realm shared --- @tparam Item item --- @treturn number -function FindIndex(item) end - ---- FindIndices --- @realm shared --- @tparam Item item --- @treturn table -function FindIndices(item) end - ---- ItemOwnsSelf --- @realm shared --- @tparam Item item --- @treturn bool -function ItemOwnsSelf(item) end - ---- CanBePut --- @realm shared --- @tparam Item item --- @treturn bool -function CanBePut(item) end - ---- CanBePut --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam Nullable`1 condition --- @tparam Nullable`1 quality --- @treturn bool -function CanBePut(itemPrefab, condition, quality) end - ---- HowManyCanBePut --- @realm shared --- @tparam ItemPrefab itemPrefab --- @tparam Nullable`1 condition --- @treturn number -function HowManyCanBePut(itemPrefab, condition) end - ---- IsEmpty --- @realm shared --- @treturn bool -function IsEmpty() end - ---- FindItem --- @realm shared --- @tparam function predicate --- @tparam bool recursive --- @treturn Item -function FindItem(predicate, recursive) end - ---- FindAllItems --- @realm shared --- @tparam function predicate --- @tparam bool recursive --- @tparam table list --- @treturn table -function FindAllItems(predicate, recursive, list) end - ---- FindItemByTag --- @realm shared --- @tparam Identifier tag --- @tparam bool recursive --- @treturn Item -function FindItemByTag(tag, recursive) end - ---- FindItemByIdentifier --- @realm shared --- @tparam Identifier identifier --- @tparam bool recursive --- @treturn Item -function FindItemByIdentifier(identifier, recursive) end - ---- ForceToSlot --- @realm shared --- @tparam Item item --- @tparam number index -function ForceToSlot(item, index) end - ---- ForceRemoveFromSlot --- @realm shared --- @tparam Item item --- @tparam number index -function ForceRemoveFromSlot(item, index) end - ---- SharedRead --- @realm shared --- @tparam IReadMessage msg --- @tparam List`1[]& newItemIds -function SharedRead(msg, newItemIds) end - ---- SharedWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam IData extraData -function SharedWrite(msg, extraData) end - ---- DeleteAllItems --- @realm shared -function DeleteAllItems() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Container, Field of type ItemContainer --- @realm shared --- @ItemContainer Container - ---- --- AllItems, Field of type Enumerable --- @realm shared --- @Enumerable AllItems - ---- --- AllItemsMod, Field of type Enumerable --- @realm shared --- @Enumerable AllItemsMod - ---- --- Capacity, Field of type number --- @realm shared --- @number Capacity - ---- --- Owner, Field of type Entity --- @realm shared --- @Entity Owner - ---- --- Locked, Field of type bool --- @realm shared --- @bool Locked - ---- --- AllowSwappingContainedItems, Field of type bool --- @realm shared --- @bool AllowSwappingContainedItems - diff --git a/docs/lua/generated/ItemPrefab.lua b/docs/lua/generated/ItemPrefab.lua deleted file mode 100644 index 5fe67ba45..000000000 --- a/docs/lua/generated/ItemPrefab.lua +++ /dev/null @@ -1,628 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma ItemPrefab class with some additional functions and fields - -Barotrauma source code: [ItemPrefab.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Items/ItemPrefab.cs) -]] --- @code ItemPrefab --- @pragma nostrip - -local ItemPrefab = {} - ---- Add ItemPrefab to spawn queue and spawns it at the specified position --- @tparam ItemPrefab itemPrefab --- @tparam Vector2 position --- @tparam function spawned --- @realm server -function ItemPrefab.AddToSpawnQueue(itemPrefab, position, spawned) end - ---- Add ItemPrefab to spawn queue and spawns it inside the specified inventory --- @tparam ItemPrefab itemPrefab --- @tparam Inventory inventory --- @tparam function spawned --- @realm server -function ItemPrefab.AddToSpawnQueue(itemPrefab, inventory, spawned) end - ---- Get a item prefab via name or id --- @tparam string itemNameOrId --- @treturn ItemPrefab --- @realm shared -function ItemPrefab.GetItemPrefab(itemNameOrId) end - ---- --- Identifier, the identifier of the prefab. --- @realm shared --- @string Identifier - - ---- GenerateLegacyIdentifier --- @realm shared --- @tparam string name --- @treturn Identifier -function ItemPrefab.GenerateLegacyIdentifier(name) end - ---- GetTreatmentSuitability --- @realm shared --- @tparam Identifier treatmentIdentifier --- @treturn number -function GetTreatmentSuitability(treatmentIdentifier) end - ---- GetPriceInfo --- @realm shared --- @tparam StoreInfo store --- @treturn PriceInfo -function GetPriceInfo(store) end - ---- CanBeBoughtFrom --- @realm shared --- @tparam StoreInfo store --- @tparam PriceInfo& priceInfo --- @treturn bool -function CanBeBoughtFrom(store, priceInfo) end - ---- CanBeBoughtFrom --- @realm shared --- @tparam Location location --- @treturn bool -function CanBeBoughtFrom(location) end - ---- GetMinPrice --- @realm shared --- @treturn Nullable`1 -function GetMinPrice() end - ---- GetBuyPricesUnder --- @realm shared --- @tparam number maxCost --- @treturn ImmutableDictionary`2 -function GetBuyPricesUnder(maxCost) end - ---- GetSellPricesOver --- @realm shared --- @tparam number minCost --- @tparam bool sellingImportant --- @treturn ImmutableDictionary`2 -function GetSellPricesOver(minCost, sellingImportant) end - ---- Find --- @realm shared --- @tparam string name --- @tparam Identifier identifier --- @treturn ItemPrefab -function ItemPrefab.Find(name, identifier) end - ---- IsContainerPreferred --- @realm shared --- @tparam Item item --- @tparam ItemContainer targetContainer --- @tparam Boolean& isPreferencesDefined --- @tparam Boolean& isSecondary --- @tparam bool requireConditionRequirement --- @treturn bool -function IsContainerPreferred(item, targetContainer, isPreferencesDefined, isSecondary, requireConditionRequirement) end - ---- IsContainerPreferred --- @realm shared --- @tparam Item item --- @tparam Identifier[] identifiersOrTags --- @tparam Boolean& isPreferencesDefined --- @tparam Boolean& isSecondary --- @treturn bool -function IsContainerPreferred(item, identifiersOrTags, isPreferencesDefined, isSecondary) end - ---- IsContainerPreferred --- @realm shared --- @tparam Enumerable preferences --- @tparam ItemContainer c --- @treturn bool -function ItemPrefab.IsContainerPreferred(preferences, c) end - ---- IsContainerPreferred --- @realm shared --- @tparam Enumerable preferences --- @tparam Enumerable ids --- @treturn bool -function ItemPrefab.IsContainerPreferred(preferences, ids) end - ---- Dispose --- @realm shared -function Dispose() end - ---- InheritFrom --- @realm shared --- @tparam ItemPrefab parent -function InheritFrom(parent) end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- GetItemPrefab --- @realm shared --- @tparam string itemNameOrId --- @treturn ItemPrefab -function ItemPrefab.GetItemPrefab(itemNameOrId) end - ---- GetItemNameTextId --- @realm shared --- @treturn string -function GetItemNameTextId() end - ---- GetHullNameTextId --- @realm shared --- @treturn string -function GetHullNameTextId() end - ---- GetAllowedUpgrades --- @realm shared --- @treturn Enumerable -function GetAllowedUpgrades() end - ---- HasSubCategory --- @realm shared --- @tparam string subcategory --- @treturn bool -function HasSubCategory(subcategory) end - ---- DebugCreateInstance --- @realm shared -function DebugCreateInstance() end - ---- NameMatches --- @realm shared --- @tparam string name --- @tparam StringComparison comparisonType --- @treturn bool -function NameMatches(name, comparisonType) end - ---- NameMatches --- @realm shared --- @tparam Enumerable allowedNames --- @tparam StringComparison comparisonType --- @treturn bool -function NameMatches(allowedNames, comparisonType) end - ---- IsLinkAllowed --- @realm shared --- @tparam MapEntityPrefab target --- @treturn bool -function IsLinkAllowed(target) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Size, Field of type Vector2 --- @realm shared --- @Vector2 Size - ---- --- DefaultPrice, Field of type PriceInfo --- @realm shared --- @PriceInfo DefaultPrice - ---- --- CanBeBought, Field of type bool --- @realm shared --- @bool CanBeBought - ---- --- CanBeSold, Field of type bool --- @realm shared --- @bool CanBeSold - ---- --- Triggers, Field of type ImmutableArray`1 --- @realm shared --- @ImmutableArray`1 Triggers - ---- --- IsOverride, Field of type bool --- @realm shared --- @bool IsOverride - ---- --- ConfigElement, Field of type ContentXElement --- @realm shared --- @ContentXElement ConfigElement - ---- --- DeconstructItems, Field of type ImmutableArray`1 --- @realm shared --- @ImmutableArray`1 DeconstructItems - ---- --- FabricationRecipes, Field of type ImmutableDictionary`2 --- @realm shared --- @ImmutableDictionary`2 FabricationRecipes - ---- --- DeconstructTime, Field of type number --- @realm shared --- @number DeconstructTime - ---- --- AllowDeconstruct, Field of type bool --- @realm shared --- @bool AllowDeconstruct - ---- --- PreferredContainers, Field of type ImmutableArray`1 --- @realm shared --- @ImmutableArray`1 PreferredContainers - ---- --- SwappableItem, Field of type SwappableItem --- @realm shared --- @SwappableItem SwappableItem - ---- --- LevelCommonness, Field of type ImmutableDictionary`2 --- @realm shared --- @ImmutableDictionary`2 LevelCommonness - ---- --- LevelQuantity, Field of type ImmutableDictionary`2 --- @realm shared --- @ImmutableDictionary`2 LevelQuantity - ---- --- CanSpriteFlipX, Field of type bool --- @realm shared --- @bool CanSpriteFlipX - ---- --- CanSpriteFlipY, Field of type bool --- @realm shared --- @bool CanSpriteFlipY - ---- --- AllowAsExtraCargo, Field of type Nullable`1 --- @realm shared --- @Nullable`1 AllowAsExtraCargo - ---- --- RandomDeconstructionOutput, Field of type bool --- @realm shared --- @bool RandomDeconstructionOutput - ---- --- RandomDeconstructionOutputAmount, Field of type number --- @realm shared --- @number RandomDeconstructionOutputAmount - ---- --- Sprite, Field of type Sprite --- @realm shared --- @Sprite Sprite - ---- --- OriginalName, Field of type string --- @realm shared --- @string OriginalName - ---- --- Name, Field of type LocalizedString --- @realm shared --- @LocalizedString Name - ---- --- Tags, Field of type ImmutableHashSet`1 --- @realm shared --- @ImmutableHashSet`1 Tags - ---- --- AllowedLinks, Field of type ImmutableHashSet`1 --- @realm shared --- @ImmutableHashSet`1 AllowedLinks - ---- --- Category, Field of type MapEntityCategory --- @realm shared --- @MapEntityCategory Category - ---- --- Aliases, Field of type ImmutableHashSet`1 --- @realm shared --- @ImmutableHashSet`1 Aliases - ---- --- InteractDistance, Field of type number --- @realm shared --- @number InteractDistance - ---- --- InteractPriority, Field of type number --- @realm shared --- @number InteractPriority - ---- --- InteractThroughWalls, Field of type bool --- @realm shared --- @bool InteractThroughWalls - ---- --- HideConditionBar, Field of type bool --- @realm shared --- @bool HideConditionBar - ---- --- HideConditionInTooltip, Field of type bool --- @realm shared --- @bool HideConditionInTooltip - ---- --- RequireBodyInsideTrigger, Field of type bool --- @realm shared --- @bool RequireBodyInsideTrigger - ---- --- RequireCursorInsideTrigger, Field of type bool --- @realm shared --- @bool RequireCursorInsideTrigger - ---- --- RequireCampaignInteract, Field of type bool --- @realm shared --- @bool RequireCampaignInteract - ---- --- FocusOnSelected, Field of type bool --- @realm shared --- @bool FocusOnSelected - ---- --- OffsetOnSelected, Field of type number --- @realm shared --- @number OffsetOnSelected - ---- --- Health, Field of type number --- @realm shared --- @number Health - ---- --- AllowSellingWhenBroken, Field of type bool --- @realm shared --- @bool AllowSellingWhenBroken - ---- --- Indestructible, Field of type bool --- @realm shared --- @bool Indestructible - ---- --- DamagedByExplosions, Field of type bool --- @realm shared --- @bool DamagedByExplosions - ---- --- ExplosionDamageMultiplier, Field of type number --- @realm shared --- @number ExplosionDamageMultiplier - ---- --- DamagedByProjectiles, Field of type bool --- @realm shared --- @bool DamagedByProjectiles - ---- --- DamagedByMeleeWeapons, Field of type bool --- @realm shared --- @bool DamagedByMeleeWeapons - ---- --- DamagedByRepairTools, Field of type bool --- @realm shared --- @bool DamagedByRepairTools - ---- --- DamagedByMonsters, Field of type bool --- @realm shared --- @bool DamagedByMonsters - ---- --- FireProof, Field of type bool --- @realm shared --- @bool FireProof - ---- --- WaterProof, Field of type bool --- @realm shared --- @bool WaterProof - ---- --- ImpactTolerance, Field of type number --- @realm shared --- @number ImpactTolerance - ---- --- OnDamagedThreshold, Field of type number --- @realm shared --- @number OnDamagedThreshold - ---- --- SonarSize, Field of type number --- @realm shared --- @number SonarSize - ---- --- UseInHealthInterface, Field of type bool --- @realm shared --- @bool UseInHealthInterface - ---- --- DisableItemUsageWhenSelected, Field of type bool --- @realm shared --- @bool DisableItemUsageWhenSelected - ---- --- CargoContainerIdentifier, Field of type string --- @realm shared --- @string CargoContainerIdentifier - ---- --- UseContainedSpriteColor, Field of type bool --- @realm shared --- @bool UseContainedSpriteColor - ---- --- UseContainedInventoryIconColor, Field of type bool --- @realm shared --- @bool UseContainedInventoryIconColor - ---- --- AddedRepairSpeedMultiplier, Field of type number --- @realm shared --- @number AddedRepairSpeedMultiplier - ---- --- AddedPickingSpeedMultiplier, Field of type number --- @realm shared --- @number AddedPickingSpeedMultiplier - ---- --- CannotRepairFail, Field of type bool --- @realm shared --- @bool CannotRepairFail - ---- --- EquipConfirmationText, Field of type string --- @realm shared --- @string EquipConfirmationText - ---- --- AllowRotatingInEditor, Field of type bool --- @realm shared --- @bool AllowRotatingInEditor - ---- --- ShowContentsInTooltip, Field of type bool --- @realm shared --- @bool ShowContentsInTooltip - ---- --- CanFlipX, Field of type bool --- @realm shared --- @bool CanFlipX - ---- --- CanFlipY, Field of type bool --- @realm shared --- @bool CanFlipY - ---- --- IsDangerous, Field of type bool --- @realm shared --- @bool IsDangerous - ---- --- MaxStackSize, Field of type number --- @realm shared --- @number MaxStackSize - ---- --- AllowDroppingOnSwap, Field of type bool --- @realm shared --- @bool AllowDroppingOnSwap - ---- --- AllowDroppingOnSwapWith, Field of type ImmutableHashSet`1 --- @realm shared --- @ImmutableHashSet`1 AllowDroppingOnSwapWith - ---- --- VariantOf, Field of type Identifier --- @realm shared --- @Identifier VariantOf - ---- --- ResizeHorizontal, Field of type bool --- @realm shared --- @bool ResizeHorizontal - ---- --- ResizeVertical, Field of type bool --- @realm shared --- @bool ResizeVertical - ---- --- Description, Field of type LocalizedString --- @realm shared --- @LocalizedString Description - ---- --- AllowedUpgrades, Field of type string --- @realm shared --- @string AllowedUpgrades - ---- --- HideInMenus, Field of type bool --- @realm shared --- @bool HideInMenus - ---- --- Subcategory, Field of type string --- @realm shared --- @string Subcategory - ---- --- Linkable, Field of type bool --- @realm shared --- @bool Linkable - ---- --- SpriteColor, Field of type Color --- @realm shared --- @Color SpriteColor - ---- --- Scale, Field of type number --- @realm shared --- @number Scale - ---- --- UintIdentifier, Field of type number --- @realm shared --- @number UintIdentifier - ---- --- ContentPackage, Field of type ContentPackage --- @realm shared --- @ContentPackage ContentPackage - ---- --- FilePath, Field of type ContentPath --- @realm shared --- @ContentPath FilePath - ---- --- ItemPrefab.Prefabs, Field of type PrefabCollection`1 --- @realm shared --- @PrefabCollection`1 ItemPrefab.Prefabs - ---- --- Identifier, Field of type Identifier --- @realm shared --- @Identifier Identifier - ---- --- ContentFile, Field of type ContentFile --- @realm shared --- @ContentFile ContentFile - diff --git a/docs/lua/generated/Job.lua b/docs/lua/generated/Job.lua deleted file mode 100644 index 22400e28b..000000000 --- a/docs/lua/generated/Job.lua +++ /dev/null @@ -1,106 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma Job class with some additional functions and fields - -Barotrauma source code: [Job.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/Job.cs) -]] --- @code Job --- @pragma nostrip - -local Job = {} - - ---- Random --- @realm shared --- @tparam RandSync randSync --- @treturn Job -function Job.Random(randSync) end - ---- GetSkills --- @realm shared --- @treturn Enumerable -function GetSkills() end - ---- GetSkillLevel --- @realm shared --- @tparam Identifier skillIdentifier --- @treturn number -function GetSkillLevel(skillIdentifier) end - ---- GetSkill --- @realm shared --- @tparam Identifier skillIdentifier --- @treturn Skill -function GetSkill(skillIdentifier) end - ---- OverrideSkills --- @realm shared --- @tparam table newSkills -function OverrideSkills(newSkills) end - ---- IncreaseSkillLevel --- @realm shared --- @tparam Identifier skillIdentifier --- @tparam number increase --- @tparam bool increasePastMax -function IncreaseSkillLevel(skillIdentifier, increase, increasePastMax) end - ---- GiveJobItems --- @realm shared --- @tparam Character character --- @tparam WayPoint spawnPoint -function GiveJobItems(character, spawnPoint) end - ---- Save --- @realm shared --- @tparam XElement parentElement --- @treturn XElement -function Save(parentElement) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Name, Field of type LocalizedString --- @realm shared --- @LocalizedString Name - ---- --- Description, Field of type LocalizedString --- @realm shared --- @LocalizedString Description - ---- --- Prefab, Field of type JobPrefab --- @realm shared --- @JobPrefab Prefab - ---- --- PrimarySkill, Field of type Skill --- @realm shared --- @Skill PrimarySkill - ---- --- Variant, Field of type number --- @realm shared --- @number Variant - diff --git a/docs/lua/generated/JobPrefab.lua b/docs/lua/generated/JobPrefab.lua deleted file mode 100644 index f81b4b359..000000000 --- a/docs/lua/generated/JobPrefab.lua +++ /dev/null @@ -1,214 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma JobPrefab class with some additional functions and fields - -Barotrauma source code: [JobPrefab.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/JobPrefab.cs) -]] --- @code JobPrefab --- @pragma nostrip - -local JobPrefab = {} - ---- Dispose --- @realm shared -function Dispose() end - ---- Get --- @realm shared --- @tparam string identifier --- @treturn JobPrefab -function JobPrefab.Get(identifier) end - ---- Random --- @realm shared --- @tparam RandSync sync --- @treturn JobPrefab -function JobPrefab.Random(sync) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- JobPrefab.ItemRepairPriorities, Field of type IReadOnlyDictionary`2 --- @realm shared --- @IReadOnlyDictionary`2 JobPrefab.ItemRepairPriorities - ---- --- UIColor, Field of type Color --- @realm shared --- @Color UIColor - ---- --- IdleBehavior, Field of type BehaviorType --- @realm shared --- @BehaviorType IdleBehavior - ---- --- OnlyJobSpecificDialog, Field of type bool --- @realm shared --- @bool OnlyJobSpecificDialog - ---- --- InitialCount, Field of type number --- @realm shared --- @number InitialCount - ---- --- AllowAlways, Field of type bool --- @realm shared --- @bool AllowAlways - ---- --- MaxNumber, Field of type number --- @realm shared --- @number MaxNumber - ---- --- MinNumber, Field of type number --- @realm shared --- @number MinNumber - ---- --- MinKarma, Field of type number --- @realm shared --- @number MinKarma - ---- --- PriceMultiplier, Field of type number --- @realm shared --- @number PriceMultiplier - ---- --- Commonness, Field of type number --- @realm shared --- @number Commonness - ---- --- VitalityModifier, Field of type number --- @realm shared --- @number VitalityModifier - ---- --- HiddenJob, Field of type bool --- @realm shared --- @bool HiddenJob - ---- --- PrimarySkill, Field of type SkillPrefab --- @realm shared --- @SkillPrefab PrimarySkill - ---- --- Element, Field of type ContentXElement --- @realm shared --- @ContentXElement Element - ---- --- ClothingElement, Field of type ContentXElement --- @realm shared --- @ContentXElement ClothingElement - ---- --- Variants, Field of type number --- @realm shared --- @number Variants - ---- --- UintIdentifier, Field of type number --- @realm shared --- @number UintIdentifier - ---- --- ContentPackage, Field of type ContentPackage --- @realm shared --- @ContentPackage ContentPackage - ---- --- FilePath, Field of type ContentPath --- @realm shared --- @ContentPath FilePath - ---- --- ItemSets, Field of type table --- @realm shared --- @table ItemSets - ---- --- PreviewItems, Field of type ImmutableDictionary`2 --- @realm shared --- @ImmutableDictionary`2 PreviewItems - ---- --- Skills, Field of type table --- @realm shared --- @table Skills - ---- --- AutonomousObjectives, Field of type table --- @realm shared --- @table AutonomousObjectives - ---- --- AppropriateOrders, Field of type table --- @realm shared --- @table AppropriateOrders - ---- --- Name, Field of type LocalizedString --- @realm shared --- @LocalizedString Name - ---- --- Description, Field of type LocalizedString --- @realm shared --- @LocalizedString Description - ---- --- Icon, Field of type Sprite --- @realm shared --- @Sprite Icon - ---- --- IconSmall, Field of type Sprite --- @realm shared --- @Sprite IconSmall - ---- --- JobPrefab.Prefabs, Field of type PrefabCollection`1 --- @realm shared --- @PrefabCollection`1 JobPrefab.Prefabs - ---- --- JobPrefab.NoJobElement, Field of type ContentXElement --- @realm shared --- @ContentXElement JobPrefab.NoJobElement - ---- --- Identifier, Field of type Identifier --- @realm shared --- @Identifier Identifier - ---- --- ContentFile, Field of type ContentFile --- @realm shared --- @ContentFile ContentFile - diff --git a/docs/lua/generated/Level.lua b/docs/lua/generated/Level.lua deleted file mode 100644 index f4d1f7d3e..000000000 --- a/docs/lua/generated/Level.lua +++ /dev/null @@ -1,559 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.Level -]] --- @code Level --- @pragma nostrip -local Level = {} - ---- GenerateMissionResources --- @realm shared --- @tparam ItemPrefab prefab --- @tparam number requiredAmount --- @tparam Single& rotation --- @treturn table -function GenerateMissionResources(prefab, requiredAmount, rotation) end - ---- GetRandomItemPos --- @realm shared --- @tparam PositionType spawnPosType --- @tparam number randomSpread --- @tparam number minDistFromSubs --- @tparam number offsetFromWall --- @tparam function filter --- @treturn Vector2 -function GetRandomItemPos(spawnPosType, randomSpread, minDistFromSubs, offsetFromWall, filter) end - ---- TryGetInterestingPositionAwayFromPoint --- @realm shared --- @tparam bool useSyncedRand --- @tparam PositionType positionType --- @tparam number minDistFromSubs --- @tparam Vector2& position --- @tparam Vector2 awayPoint --- @tparam number minDistFromPoint --- @tparam function filter --- @treturn bool -function TryGetInterestingPositionAwayFromPoint(useSyncedRand, positionType, minDistFromSubs, position, awayPoint, minDistFromPoint, filter) end - ---- TryGetInterestingPosition --- @realm shared --- @tparam bool useSyncedRand --- @tparam PositionType positionType --- @tparam number minDistFromSubs --- @tparam Vector2& position --- @tparam function filter --- @treturn bool -function TryGetInterestingPosition(useSyncedRand, positionType, minDistFromSubs, position, filter) end - ---- TryGetInterestingPosition --- @realm shared --- @tparam bool useSyncedRand --- @tparam PositionType positionType --- @tparam number minDistFromSubs --- @tparam Point& position --- @tparam Vector2 awayPoint --- @tparam number minDistFromPoint --- @tparam function filter --- @treturn bool -function TryGetInterestingPosition(useSyncedRand, positionType, minDistFromSubs, position, awayPoint, minDistFromPoint, filter) end - ---- Update --- @realm shared --- @tparam number deltaTime --- @tparam Camera cam -function Update(deltaTime, cam) end - ---- GetBottomPosition --- @realm shared --- @tparam number xPosition --- @treturn Vector2 -function GetBottomPosition(xPosition) end - ---- GetAllCells --- @realm shared --- @treturn table -function GetAllCells() end - ---- GetCells --- @realm shared --- @tparam Vector2 worldPos --- @tparam number searchDepth --- @treturn table -function GetCells(worldPos, searchDepth) end - ---- GetClosestCell --- @realm shared --- @tparam Vector2 worldPos --- @treturn VoronoiCell -function GetClosestCell(worldPos) end - ---- IsCloseToStart --- @realm shared --- @tparam Vector2 position --- @tparam number minDist --- @treturn bool -function IsCloseToStart(position, minDist) end - ---- IsCloseToEnd --- @realm shared --- @tparam Vector2 position --- @tparam number minDist --- @treturn bool -function IsCloseToEnd(position, minDist) end - ---- IsCloseToStart --- @realm shared --- @tparam Point position --- @tparam number minDist --- @treturn bool -function IsCloseToStart(position, minDist) end - ---- IsCloseToEnd --- @realm shared --- @tparam Point position --- @tparam number minDist --- @treturn bool -function IsCloseToEnd(position, minDist) end - ---- PrepareBeaconStation --- @realm shared -function PrepareBeaconStation() end - ---- CheckBeaconActive --- @realm shared --- @treturn bool -function CheckBeaconActive() end - ---- SpawnCorpses --- @realm shared -function SpawnCorpses() end - ---- SpawnNPCs --- @realm shared -function SpawnNPCs() end - ---- GetRealWorldDepth --- @realm shared --- @tparam number worldPositionY --- @treturn number -function GetRealWorldDepth(worldPositionY) end - ---- DebugSetStartLocation --- @realm shared --- @tparam Location newStartLocation -function DebugSetStartLocation(newStartLocation) end - ---- DebugSetEndLocation --- @realm shared --- @tparam Location newEndLocation -function DebugSetEndLocation(newEndLocation) end - ---- Remove --- @realm shared -function Remove() end - ---- ServerEventWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c --- @tparam IData extraData -function ServerEventWrite(msg, c, extraData) end - ---- Generate --- @realm shared --- @tparam LevelData levelData --- @tparam bool mirror --- @tparam SubmarineInfo startOutpost --- @tparam SubmarineInfo endOutpost --- @treturn Level -function Level.Generate(levelData, mirror, startOutpost, endOutpost) end - ---- GetTooCloseCells --- @realm shared --- @tparam Vector2 position --- @tparam number minDistance --- @treturn table -function GetTooCloseCells(position, minDistance) end - ---- FreeID --- @realm shared -function FreeID() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Level.Loaded, Field of type Level --- @realm shared --- @Level Level.Loaded - ---- --- AbyssArea, Field of type Rectangle --- @realm shared --- @Rectangle AbyssArea - ---- --- AbyssStart, Field of type number --- @realm shared --- @number AbyssStart - ---- --- AbyssEnd, Field of type number --- @realm shared --- @number AbyssEnd - ---- --- StartPosition, Field of type Vector2 --- @realm shared --- @Vector2 StartPosition - ---- --- StartExitPosition, Field of type Vector2 --- @realm shared --- @Vector2 StartExitPosition - ---- --- Size, Field of type Point --- @realm shared --- @Point Size - ---- --- EndPosition, Field of type Vector2 --- @realm shared --- @Vector2 EndPosition - ---- --- EndExitPosition, Field of type Vector2 --- @realm shared --- @Vector2 EndExitPosition - ---- --- BottomPos, Field of type number --- @realm shared --- @number BottomPos - ---- --- SeaFloorTopPos, Field of type number --- @realm shared --- @number SeaFloorTopPos - ---- --- CrushDepth, Field of type number --- @realm shared --- @number CrushDepth - ---- --- RealWorldCrushDepth, Field of type number --- @realm shared --- @number RealWorldCrushDepth - ---- --- SeaFloor, Field of type LevelWall --- @realm shared --- @LevelWall SeaFloor - ---- --- Ruins, Field of type table --- @realm shared --- @table Ruins - ---- --- Wrecks, Field of type table --- @realm shared --- @table Wrecks - ---- --- BeaconStation, Field of type Submarine --- @realm shared --- @Submarine BeaconStation - ---- --- ExtraWalls, Field of type table --- @realm shared --- @table ExtraWalls - ---- --- UnsyncedExtraWalls, Field of type table --- @realm shared --- @table UnsyncedExtraWalls - ---- --- Tunnels, Field of type table --- @realm shared --- @table Tunnels - ---- --- Caves, Field of type table --- @realm shared --- @table Caves - ---- --- PositionsOfInterest, Field of type table --- @realm shared --- @table PositionsOfInterest - ---- --- StartOutpost, Field of type Submarine --- @realm shared --- @Submarine StartOutpost - ---- --- EndOutpost, Field of type Submarine --- @realm shared --- @Submarine EndOutpost - ---- --- EqualityCheckValues, Field of type table --- @realm shared --- @table EqualityCheckValues - ---- --- EntitiesBeforeGenerate, Field of type table --- @realm shared --- @table EntitiesBeforeGenerate - ---- --- EntityCountBeforeGenerate, Field of type number --- @realm shared --- @number EntityCountBeforeGenerate - ---- --- EntityCountAfterGenerate, Field of type number --- @realm shared --- @number EntityCountAfterGenerate - ---- --- TopBarrier, Field of type Body --- @realm shared --- @Body TopBarrier - ---- --- BottomBarrier, Field of type Body --- @realm shared --- @Body BottomBarrier - ---- --- LevelObjectManager, Field of type LevelObjectManager --- @realm shared --- @LevelObjectManager LevelObjectManager - ---- --- Generating, Field of type bool --- @realm shared --- @bool Generating - ---- --- StartLocation, Field of type Location --- @realm shared --- @Location StartLocation - ---- --- EndLocation, Field of type Location --- @realm shared --- @Location EndLocation - ---- --- Mirrored, Field of type bool --- @realm shared --- @bool Mirrored - ---- --- Seed, Field of type string --- @realm shared --- @string Seed - ---- --- Difficulty, Field of type number --- @realm shared --- @number Difficulty - ---- --- Type, Field of type LevelType --- @realm shared --- @LevelType Type - ---- --- Level.IsLoadedOutpost, Field of type bool --- @realm shared --- @bool Level.IsLoadedOutpost - ---- --- GenerationParams, Field of type LevelGenerationParams --- @realm shared --- @LevelGenerationParams GenerationParams - ---- --- BackgroundTextureColor, Field of type Color --- @realm shared --- @Color BackgroundTextureColor - ---- --- BackgroundColor, Field of type Color --- @realm shared --- @Color BackgroundColor - ---- --- WallColor, Field of type Color --- @realm shared --- @Color WallColor - ---- --- PathPoints, Field of type table --- @realm shared --- @table PathPoints - ---- --- AbyssResources, Field of type table --- @realm shared --- @table AbyssResources - ---- --- Removed, Field of type bool --- @realm shared --- @bool Removed - ---- --- IdFreed, Field of type bool --- @realm shared --- @bool IdFreed - ---- --- SimPosition, Field of type Vector2 --- @realm shared --- @Vector2 SimPosition - ---- --- Position, Field of type Vector2 --- @realm shared --- @Vector2 Position - ---- --- WorldPosition, Field of type Vector2 --- @realm shared --- @Vector2 WorldPosition - ---- --- DrawPosition, Field of type Vector2 --- @realm shared --- @Vector2 DrawPosition - ---- --- Submarine, Field of type Submarine --- @realm shared --- @Submarine Submarine - ---- --- AiTarget, Field of type AITarget --- @realm shared --- @AITarget AiTarget - ---- --- InDetectable, Field of type bool --- @realm shared --- @bool InDetectable - ---- --- SpawnTime, Field of type number --- @realm shared --- @number SpawnTime - ---- --- ErrorLine, Field of type string --- @realm shared --- @string ErrorLine - ---- --- AbyssIslands, Field of type table --- @realm shared --- @table AbyssIslands - ---- --- siteCoordsX, Field of type table --- @realm shared --- @table siteCoordsX - ---- --- siteCoordsY, Field of type table --- @realm shared --- @table siteCoordsY - ---- --- distanceField, Field of type table --- @realm shared --- @table distanceField - ---- --- LevelData, Field of type LevelData --- @realm shared --- @LevelData LevelData - ---- --- Level.ForcedDifficulty, Field of type Nullable`1 --- @realm shared --- @Nullable`1 Level.ForcedDifficulty - ---- --- Level.MaxEntityDepth, Field of type number --- @realm shared --- @number Level.MaxEntityDepth - ---- --- Level.ShaftHeight, Field of type number --- @realm shared --- @number Level.ShaftHeight - ---- --- Level.MaxSubmarineWidth, Field of type number --- @realm shared --- @number Level.MaxSubmarineWidth - ---- --- Level.ExitDistance, Field of type number --- @realm shared --- @number Level.ExitDistance - ---- --- Level.GridCellSize, Field of type number --- @realm shared --- @number Level.GridCellSize - ---- --- Level.DefaultRealWorldCrushDepth, Field of type number --- @realm shared --- @number Level.DefaultRealWorldCrushDepth - ---- --- ID, Field of type number --- @realm shared --- @number ID - ---- --- CreationStackTrace, Field of type string --- @realm shared --- @string CreationStackTrace - ---- --- CreationIndex, Field of type number --- @realm shared --- @number CreationIndex - diff --git a/docs/lua/generated/NetLobbyScreen.lua b/docs/lua/generated/NetLobbyScreen.lua deleted file mode 100644 index cb348987b..000000000 --- a/docs/lua/generated/NetLobbyScreen.lua +++ /dev/null @@ -1,167 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.NetLobbyScreen -]] --- @code Game.NetLobbyScreen --- @pragma nostrip -local NetLobbyScreen = {} - ---- ChangeServerName --- @realm shared --- @tparam string n -function ChangeServerName(n) end - ---- ChangeServerMessage --- @realm shared --- @tparam string m -function ChangeServerMessage(m) end - ---- GetSubList --- @realm shared --- @treturn IReadOnlyList`1 -function GetSubList() end - ---- AddSub --- @realm shared --- @tparam SubmarineInfo sub -function AddSub(sub) end - ---- ToggleCampaignMode --- @realm shared --- @tparam bool enabled -function ToggleCampaignMode(enabled) end - ---- Select --- @realm shared -function Select() end - ---- RandomizeSettings --- @realm shared -function RandomizeSettings() end - ---- SetLevelDifficulty --- @realm shared --- @tparam number difficulty -function SetLevelDifficulty(difficulty) end - ---- ToggleTraitorsEnabled --- @realm shared --- @tparam number dir -function ToggleTraitorsEnabled(dir) end - ---- SetBotCount --- @realm shared --- @tparam number botCount -function SetBotCount(botCount) end - ---- SetBotSpawnMode --- @realm shared --- @tparam BotSpawnMode botSpawnMode -function SetBotSpawnMode(botSpawnMode) end - ---- SetTraitorsEnabled --- @realm shared --- @tparam YesNoMaybe enabled -function SetTraitorsEnabled(enabled) end - ---- Deselect --- @realm shared -function Deselect() end - ---- Update --- @realm shared --- @tparam number deltaTime -function Update(deltaTime) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- SelectedSub, Field of type SubmarineInfo --- @realm shared --- @SubmarineInfo SelectedSub - ---- --- SelectedShuttle, Field of type SubmarineInfo --- @realm shared --- @SubmarineInfo SelectedShuttle - ---- --- GameModes, Field of type GameModePreset[] --- @realm shared --- @GameModePreset[] GameModes - ---- --- SelectedModeIndex, Field of type number --- @realm shared --- @number SelectedModeIndex - ---- --- SelectedModeIdentifier, Field of type Identifier --- @realm shared --- @Identifier SelectedModeIdentifier - ---- --- SelectedMode, Field of type GameModePreset --- @realm shared --- @GameModePreset SelectedMode - ---- --- MissionType, Field of type MissionType --- @realm shared --- @MissionType MissionType - ---- --- MissionTypeName, Field of type string --- @realm shared --- @string MissionTypeName - ---- --- JobPreferences, Field of type table --- @realm shared --- @table JobPreferences - ---- --- LevelSeed, Field of type string --- @realm shared --- @string LevelSeed - ---- --- LastUpdateID, Field of type number --- @realm shared --- @number LastUpdateID - ---- --- Cam, Field of type Camera --- @realm shared --- @Camera Cam - ---- --- IsEditor, Field of type bool --- @realm shared --- @bool IsEditor - ---- --- RadiationEnabled, Field of type bool --- @realm shared --- @bool RadiationEnabled - diff --git a/docs/lua/generated/ServerSettings.lua b/docs/lua/generated/ServerSettings.lua deleted file mode 100644 index 07c5128dc..000000000 --- a/docs/lua/generated/ServerSettings.lua +++ /dev/null @@ -1,588 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.Networking.ServerSettings -]] --- @code Game.ServerSettings --- @pragma nostrip -local ServerSettings = {} - ---- ReadMonsterEnabled --- @realm shared --- @tparam IReadMessage inc -function ReadMonsterEnabled(inc) end - ---- WriteMonsterEnabled --- @realm shared --- @tparam IWriteMessage msg --- @tparam table monsterEnabled -function WriteMonsterEnabled(msg, monsterEnabled) end - ---- ReadExtraCargo --- @realm shared --- @tparam IReadMessage msg --- @treturn bool -function ReadExtraCargo(msg) end - ---- WriteExtraCargo --- @realm shared --- @tparam IWriteMessage msg -function WriteExtraCargo(msg) end - ---- ReadHiddenSubs --- @realm shared --- @tparam IReadMessage msg -function ReadHiddenSubs(msg) end - ---- WriteHiddenSubs --- @realm shared --- @tparam IWriteMessage msg -function WriteHiddenSubs(msg) end - ---- SetPassword --- @realm shared --- @tparam string password -function SetPassword(password) end - ---- SaltPassword --- @realm shared --- @tparam Byte[] password --- @tparam number salt --- @treturn Byte[] -function ServerSettings.SaltPassword(password, salt) end - ---- IsPasswordCorrect --- @realm shared --- @tparam Byte[] input --- @tparam number salt --- @treturn bool -function IsPasswordCorrect(input, salt) end - ---- UpdateFlag --- @realm shared --- @tparam NetFlags flag -function UpdateFlag(flag) end - ---- GetRequiredFlags --- @realm shared --- @tparam Client c --- @treturn NetFlags -function GetRequiredFlags(c) end - ---- ServerAdminWrite --- @realm shared --- @tparam IWriteMessage outMsg --- @tparam Client c -function ServerAdminWrite(outMsg, c) end - ---- ServerWrite --- @realm shared --- @tparam IWriteMessage outMsg --- @tparam Client c -function ServerWrite(outMsg, c) end - ---- ServerRead --- @realm shared --- @tparam IReadMessage incMsg --- @tparam Client c -function ServerRead(incMsg, c) end - ---- SaveSettings --- @realm shared -function SaveSettings() end - ---- SelectNonHiddenSubmarine --- @realm shared --- @tparam string current --- @treturn string -function SelectNonHiddenSubmarine(current) end - ---- LoadClientPermissions --- @realm shared -function LoadClientPermissions() end - ---- SaveClientPermissions --- @realm shared -function SaveClientPermissions() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- LastPropertyUpdateId, Field of type number --- @realm shared --- @number LastPropertyUpdateId - ---- --- Name, Field of type string --- @realm shared --- @string Name - ---- --- SerializableProperties, Field of type table --- @realm shared --- @table SerializableProperties - ---- --- ServerName, Field of type string --- @realm shared --- @string ServerName - ---- --- ServerMessageText, Field of type string --- @realm shared --- @string ServerMessageText - ---- --- MonsterEnabled, Field of type table --- @realm shared --- @table MonsterEnabled - ---- --- ExtraCargo, Field of type table --- @realm shared --- @table ExtraCargo - ---- --- HiddenSubs, Field of type HashSet`1 --- @realm shared --- @HashSet`1 HiddenSubs - ---- --- ClientPermissions, Field of type table --- @realm shared --- @table ClientPermissions - ---- --- Whitelist, Field of type WhiteList --- @realm shared --- @WhiteList Whitelist - ---- --- TickRate, Field of type number --- @realm shared --- @number TickRate - ---- --- RandomizeSeed, Field of type bool --- @realm shared --- @bool RandomizeSeed - ---- --- UseRespawnShuttle, Field of type bool --- @realm shared --- @bool UseRespawnShuttle - ---- --- RespawnInterval, Field of type number --- @realm shared --- @number RespawnInterval - ---- --- MaxTransportTime, Field of type number --- @realm shared --- @number MaxTransportTime - ---- --- MinRespawnRatio, Field of type number --- @realm shared --- @number MinRespawnRatio - ---- --- AutoRestartInterval, Field of type number --- @realm shared --- @number AutoRestartInterval - ---- --- StartWhenClientsReady, Field of type bool --- @realm shared --- @bool StartWhenClientsReady - ---- --- StartWhenClientsReadyRatio, Field of type number --- @realm shared --- @number StartWhenClientsReadyRatio - ---- --- AllowSpectating, Field of type bool --- @realm shared --- @bool AllowSpectating - ---- --- SaveServerLogs, Field of type bool --- @realm shared --- @bool SaveServerLogs - ---- --- AllowModDownloads, Field of type bool --- @realm shared --- @bool AllowModDownloads - ---- --- AllowRagdollButton, Field of type bool --- @realm shared --- @bool AllowRagdollButton - ---- --- AllowFileTransfers, Field of type bool --- @realm shared --- @bool AllowFileTransfers - ---- --- VoiceChatEnabled, Field of type bool --- @realm shared --- @bool VoiceChatEnabled - ---- --- PlayStyle, Field of type PlayStyle --- @realm shared --- @PlayStyle PlayStyle - ---- --- LosMode, Field of type LosMode --- @realm shared --- @LosMode LosMode - ---- --- LinesPerLogFile, Field of type number --- @realm shared --- @number LinesPerLogFile - ---- --- AutoRestart, Field of type bool --- @realm shared --- @bool AutoRestart - ---- --- HasPassword, Field of type bool --- @realm shared --- @bool HasPassword - ---- --- AllowVoteKick, Field of type bool --- @realm shared --- @bool AllowVoteKick - ---- --- AllowEndVoting, Field of type bool --- @realm shared --- @bool AllowEndVoting - ---- --- AllowRespawn, Field of type bool --- @realm shared --- @bool AllowRespawn - ---- --- BotCount, Field of type number --- @realm shared --- @number BotCount - ---- --- MaxBotCount, Field of type number --- @realm shared --- @number MaxBotCount - ---- --- BotSpawnMode, Field of type BotSpawnMode --- @realm shared --- @BotSpawnMode BotSpawnMode - ---- --- DisableBotConversations, Field of type bool --- @realm shared --- @bool DisableBotConversations - ---- --- SelectedLevelDifficulty, Field of type number --- @realm shared --- @number SelectedLevelDifficulty - ---- --- AllowDisguises, Field of type bool --- @realm shared --- @bool AllowDisguises - ---- --- AllowRewiring, Field of type bool --- @realm shared --- @bool AllowRewiring - ---- --- LockAllDefaultWires, Field of type bool --- @realm shared --- @bool LockAllDefaultWires - ---- --- AllowLinkingWifiToChat, Field of type bool --- @realm shared --- @bool AllowLinkingWifiToChat - ---- --- AllowFriendlyFire, Field of type bool --- @realm shared --- @bool AllowFriendlyFire - ---- --- DestructibleOutposts, Field of type bool --- @realm shared --- @bool DestructibleOutposts - ---- --- KillableNPCs, Field of type bool --- @realm shared --- @bool KillableNPCs - ---- --- BanAfterWrongPassword, Field of type bool --- @realm shared --- @bool BanAfterWrongPassword - ---- --- MaxPasswordRetriesBeforeBan, Field of type number --- @realm shared --- @number MaxPasswordRetriesBeforeBan - ---- --- SelectedSubmarine, Field of type string --- @realm shared --- @string SelectedSubmarine - ---- --- SelectedShuttle, Field of type string --- @realm shared --- @string SelectedShuttle - ---- --- TraitorsEnabled, Field of type YesNoMaybe --- @realm shared --- @YesNoMaybe TraitorsEnabled - ---- --- TraitorsMinPlayerCount, Field of type number --- @realm shared --- @number TraitorsMinPlayerCount - ---- --- TraitorsMinStartDelay, Field of type number --- @realm shared --- @number TraitorsMinStartDelay - ---- --- TraitorsMaxStartDelay, Field of type number --- @realm shared --- @number TraitorsMaxStartDelay - ---- --- TraitorsMinRestartDelay, Field of type number --- @realm shared --- @number TraitorsMinRestartDelay - ---- --- TraitorsMaxRestartDelay, Field of type number --- @realm shared --- @number TraitorsMaxRestartDelay - ---- --- SubSelectionMode, Field of type SelectionMode --- @realm shared --- @SelectionMode SubSelectionMode - ---- --- ModeSelectionMode, Field of type SelectionMode --- @realm shared --- @SelectionMode ModeSelectionMode - ---- --- BanList, Field of type BanList --- @realm shared --- @BanList BanList - ---- --- EndVoteRequiredRatio, Field of type number --- @realm shared --- @number EndVoteRequiredRatio - ---- --- VoteRequiredRatio, Field of type number --- @realm shared --- @number VoteRequiredRatio - ---- --- VoteTimeout, Field of type number --- @realm shared --- @number VoteTimeout - ---- --- KickVoteRequiredRatio, Field of type number --- @realm shared --- @number KickVoteRequiredRatio - ---- --- KillDisconnectedTime, Field of type number --- @realm shared --- @number KillDisconnectedTime - ---- --- KickAFKTime, Field of type number --- @realm shared --- @number KickAFKTime - ---- --- KarmaEnabled, Field of type bool --- @realm shared --- @bool KarmaEnabled - ---- --- KarmaPreset, Field of type string --- @realm shared --- @string KarmaPreset - ---- --- GameModeIdentifier, Field of type Identifier --- @realm shared --- @Identifier GameModeIdentifier - ---- --- MissionType, Field of type string --- @realm shared --- @string MissionType - ---- --- MaxPlayers, Field of type number --- @realm shared --- @number MaxPlayers - ---- --- AllowedRandomMissionTypes, Field of type table --- @realm shared --- @table AllowedRandomMissionTypes - ---- --- AutoBanTime, Field of type number --- @realm shared --- @number AutoBanTime - ---- --- MaxAutoBanTime, Field of type number --- @realm shared --- @number MaxAutoBanTime - ---- --- RadiationEnabled, Field of type bool --- @realm shared --- @bool RadiationEnabled - ---- --- MaxMissionCount, Field of type number --- @realm shared --- @number MaxMissionCount - ---- --- AllowSubVoting, Field of type bool --- @realm shared --- @bool AllowSubVoting - ---- --- AllowModeVoting, Field of type bool --- @realm shared --- @bool AllowModeVoting - ---- --- AllowedClientNameChars, Field of type table --- @realm shared --- @table AllowedClientNameChars - ---- --- LastUpdateIdForFlag, Field of type table --- @realm shared --- @table LastUpdateIdForFlag - ---- --- ServerDetailsChanged, Field of type bool --- @realm shared --- @bool ServerDetailsChanged - ---- --- Port, Field of type number --- @realm shared --- @number Port - ---- --- QueryPort, Field of type number --- @realm shared --- @number QueryPort - ---- --- ListenIPAddress, Field of type IPAddress --- @realm shared --- @IPAddress ListenIPAddress - ---- --- EnableUPnP, Field of type bool --- @realm shared --- @bool EnableUPnP - ---- --- ServerLog, Field of type ServerLog --- @realm shared --- @ServerLog ServerLog - ---- --- AutoRestartTimer, Field of type number --- @realm shared --- @number AutoRestartTimer - ---- --- IsPublic, Field of type bool --- @realm shared --- @bool IsPublic - ---- --- ServerSettings.ClientPermissionsFile, Field of type string --- @realm shared --- @string ServerSettings.ClientPermissionsFile - ---- --- ServerSettings.SubmarineSeparatorChar, Field of type Char --- @realm shared --- @Char ServerSettings.SubmarineSeparatorChar - ---- --- ServerSettings.PermissionPresetFile, Field of type string --- @realm shared --- @string ServerSettings.PermissionPresetFile - ---- --- ServerSettings.SettingsFile, Field of type string --- @realm shared --- @string ServerSettings.SettingsFile - ---- --- ServerSettings.MaxExtraCargoItemsOfType, Field of type number --- @realm shared --- @number ServerSettings.MaxExtraCargoItemsOfType - ---- --- ServerSettings.MaxExtraCargoItemTypes, Field of type number --- @realm shared --- @number ServerSettings.MaxExtraCargoItemTypes - diff --git a/docs/lua/generated/Submarine.lua b/docs/lua/generated/Submarine.lua deleted file mode 100644 index 5faa65415..000000000 --- a/docs/lua/generated/Submarine.lua +++ /dev/null @@ -1,623 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma Submarine class with some additional functions and fields - -Barotrauma source code: [Submarine.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs) - -Not all fields and methods will work, this doc was autogenerated. -]] --- @code Submarine --- @pragma nostrip - -local Submarine = {} - ---- FindContaining --- @realm shared --- @tparam Vector2 position --- @treturn Submarine -function Submarine.FindContaining(position) end - ---- GetBorders --- @realm shared --- @tparam XElement submarineElement --- @treturn Rectangle -function Submarine.GetBorders(submarineElement) end - ---- Load --- @realm shared --- @tparam SubmarineInfo info --- @tparam bool unloadPrevious --- @tparam IdRemap linkedRemap --- @treturn Submarine -function Submarine.Load(info, unloadPrevious, linkedRemap) end - ---- RepositionEntities --- @realm shared --- @tparam Vector2 moveAmount --- @tparam Enumerable entities -function Submarine.RepositionEntities(moveAmount, entities) end - ---- SaveToXElement --- @realm shared --- @tparam XElement element -function SaveToXElement(element) end - ---- TrySaveAs --- @realm shared --- @tparam string filePath --- @tparam MemoryStream previewImage --- @treturn bool -function TrySaveAs(filePath, previewImage) end - ---- Unload --- @realm shared -function Submarine.Unload() end - ---- Remove --- @realm shared -function Remove() end - ---- Dispose --- @realm shared -function Dispose() end - ---- DisableObstructedWayPoints --- @realm shared -function DisableObstructedWayPoints() end - ---- DisableObstructedWayPoints --- @realm shared --- @tparam Submarine otherSub -function DisableObstructedWayPoints(otherSub) end - ---- EnableObstructedWaypoints --- @realm shared --- @tparam Submarine otherSub -function EnableObstructedWaypoints(otherSub) end - ---- RefreshOutdoorNodes --- @realm shared -function RefreshOutdoorNodes() end - ---- ServerWritePosition --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c -function ServerWritePosition(msg, c) end - ---- ServerEventWrite --- @realm shared --- @tparam IWriteMessage msg --- @tparam Client c --- @tparam IData extraData -function ServerEventWrite(msg, c, extraData) end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- CalculateBasePrice --- @realm shared --- @treturn number -function CalculateBasePrice() end - ---- AttemptBallastFloraInfection --- @realm shared --- @tparam Identifier identifier --- @tparam number deltaTime --- @tparam number probability -function AttemptBallastFloraInfection(identifier, deltaTime, probability) end - ---- MakeWreck --- @realm shared -function MakeWreck() end - ---- CreateWreckAI --- @realm shared --- @treturn bool -function CreateWreckAI() end - ---- DisableWreckAI --- @realm shared -function DisableWreckAI() end - ---- GetDockedBorders --- @realm shared --- @tparam table checkd --- @treturn Rectangle -function GetDockedBorders(checkd) end - ---- GetConnectedSubs --- @realm shared --- @treturn table -function GetConnectedSubs() end - ---- FindSpawnPos --- @realm shared --- @tparam Vector2 spawnPos --- @tparam Nullable`1 submarineSize --- @tparam number subDockingPortOffset --- @tparam number verticalMoveDir --- @treturn Vector2 -function FindSpawnPos(spawnPos, submarineSize, subDockingPortOffset, verticalMoveDir) end - ---- UpdateTransform --- @realm shared --- @tparam bool interpolate -function UpdateTransform(interpolate) end - ---- VectorToWorldGrid --- @realm shared --- @tparam Vector2 position --- @treturn Vector2 -function Submarine.VectorToWorldGrid(position) end - ---- CalculateDimensions --- @realm shared --- @tparam bool onlyHulls --- @treturn Rectangle -function CalculateDimensions(onlyHulls) end - ---- AbsRect --- @realm shared --- @tparam Vector2 pos --- @tparam Vector2 size --- @treturn Rectangle -function Submarine.AbsRect(pos, size) end - ---- RectContains --- @realm shared --- @tparam Rectangle rect --- @tparam Vector2 pos --- @tparam bool inclusive --- @treturn bool -function Submarine.RectContains(rect, pos, inclusive) end - ---- RectsOverlap --- @realm shared --- @tparam Rectangle rect1 --- @tparam Rectangle rect2 --- @tparam bool inclusive --- @treturn bool -function Submarine.RectsOverlap(rect1, rect2, inclusive) end - ---- PickBody --- @realm shared --- @tparam Vector2 rayStart --- @tparam Vector2 rayEnd --- @tparam Enumerable ignoredBodies --- @tparam Nullable`1 collisionCategory --- @tparam bool ignoreSensors --- @tparam Predicate`1 customPredicate --- @tparam bool allowInsideFixture --- @treturn Body -function Submarine.PickBody(rayStart, rayEnd, ignoredBodies, collisionCategory, ignoreSensors, customPredicate, allowInsideFixture) end - ---- LastPickedBodyDist --- @realm shared --- @tparam Body body --- @treturn number -function Submarine.LastPickedBodyDist(body) end - ---- PickBodies --- @realm shared --- @tparam Vector2 rayStart --- @tparam Vector2 rayEnd --- @tparam Enumerable ignoredBodies --- @tparam Nullable`1 collisionCategory --- @tparam bool ignoreSensors --- @tparam Predicate`1 customPredicate --- @tparam bool allowInsideFixture --- @treturn Enumerable -function Submarine.PickBodies(rayStart, rayEnd, ignoredBodies, collisionCategory, ignoreSensors, customPredicate, allowInsideFixture) end - ---- CheckVisibility --- @realm shared --- @tparam Vector2 rayStart --- @tparam Vector2 rayEnd --- @tparam bool ignoreLevel --- @tparam bool ignoreSubs --- @tparam bool ignoreSensors --- @tparam bool ignoreDisabledWalls --- @tparam bool ignoreBranches --- @treturn Body -function Submarine.CheckVisibility(rayStart, rayEnd, ignoreLevel, ignoreSubs, ignoreSensors, ignoreDisabledWalls, ignoreBranches) end - ---- FlipX --- @realm shared --- @tparam table parents -function FlipX(parents) end - ---- Update --- @realm shared --- @tparam number deltaTime -function Update(deltaTime) end - ---- ApplyForce --- @realm shared --- @tparam Vector2 force -function ApplyForce(force) end - ---- EnableMaintainPosition --- @realm shared -function EnableMaintainPosition() end - ---- NeutralizeBallast --- @realm shared -function NeutralizeBallast() end - ---- SetPrevTransform --- @realm shared --- @tparam Vector2 position -function SetPrevTransform(position) end - ---- SetPosition --- @realm shared --- @tparam Vector2 position --- @tparam table checkd --- @tparam bool forceUndockFromStaticSubmarines -function SetPosition(position, checkd, forceUndockFromStaticSubmarines) end - ---- CalculateDockOffset --- @realm shared --- @tparam Submarine sub --- @tparam Submarine dockedSub --- @treturn Nullable`1 -function Submarine.CalculateDockOffset(sub, dockedSub) end - ---- Translate --- @realm shared --- @tparam Vector2 amount -function Translate(amount) end - ---- FindClosest --- @realm shared --- @tparam Vector2 worldPosition --- @tparam bool ignoreOutposts --- @tparam bool ignoreOutsideLevel --- @tparam bool ignoreRespawnShuttle --- @tparam Nullable`1 teamType --- @treturn Submarine -function Submarine.FindClosest(worldPosition, ignoreOutposts, ignoreOutsideLevel, ignoreRespawnShuttle, teamType) end - ---- IsConnectedTo --- @realm shared --- @tparam Submarine otherSub --- @treturn bool -function IsConnectedTo(otherSub) end - ---- GetHulls --- @realm shared --- @tparam bool alsoFromConnectedSubs --- @treturn table -function GetHulls(alsoFromConnectedSubs) end - ---- GetGaps --- @realm shared --- @tparam bool alsoFromConnectedSubs --- @treturn table -function GetGaps(alsoFromConnectedSubs) end - ---- GetItems --- @realm shared --- @tparam bool alsoFromConnectedSubs --- @treturn table -function GetItems(alsoFromConnectedSubs) end - ---- GetWaypoints --- @realm shared --- @tparam bool alsoFromConnectedSubs --- @treturn table -function GetWaypoints(alsoFromConnectedSubs) end - ---- GetWalls --- @realm shared --- @tparam bool alsoFromConnectedSubs --- @treturn table -function GetWalls(alsoFromConnectedSubs) end - ---- GetEntities --- @realm shared --- @tparam bool includingConnectedSubs --- @tparam table list --- @treturn table -function GetEntities(includingConnectedSubs, list) end - ---- GetCargoContainers --- @realm shared --- @treturn table -function GetCargoContainers() end - ---- GetEntities --- @realm shared --- @tparam bool includingConnectedSubs --- @tparam Enumerable list --- @treturn Enumerable -function GetEntities(includingConnectedSubs, list) end - ---- IsEntityFoundOnThisSub --- @realm shared --- @tparam MapEntity entity --- @tparam bool includingConnectedSubs --- @tparam bool allowDifferentTeam --- @tparam bool allowDifferentType --- @treturn bool -function IsEntityFoundOnThisSub(entity, includingConnectedSubs, allowDifferentTeam, allowDifferentType) end - ---- FreeID --- @realm shared -function FreeID() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Info, Field of type SubmarineInfo --- @realm shared --- @SubmarineInfo Info - ---- --- HiddenSubPosition, Field of type Vector2 --- @realm shared --- @Vector2 HiddenSubPosition - ---- --- IdOffset, Field of type number --- @realm shared --- @number IdOffset - ---- --- Submarine.MainSub, Field of type Submarine --- @realm shared --- @Submarine Submarine.MainSub - ---- --- Submarine.VisibleEntities, Field of type Enumerable --- @realm shared --- @Enumerable Submarine.VisibleEntities - ---- --- DockedTo, Field of type Enumerable --- @realm shared --- @Enumerable DockedTo - ---- --- Submarine.LastPickedPosition, Field of type Vector2 --- @realm shared --- @Vector2 Submarine.LastPickedPosition - ---- --- Submarine.LastPickedFraction, Field of type number --- @realm shared --- @number Submarine.LastPickedFraction - ---- --- Submarine.LastPickedFixture, Field of type Fixture --- @realm shared --- @Fixture Submarine.LastPickedFixture - ---- --- Submarine.LastPickedNormal, Field of type Vector2 --- @realm shared --- @Vector2 Submarine.LastPickedNormal - ---- --- Loading, Field of type bool --- @realm shared --- @bool Loading - ---- --- GodMode, Field of type bool --- @realm shared --- @bool GodMode - ---- --- Submarine.Loaded, Field of type table --- @realm shared --- @table Submarine.Loaded - ---- --- SubBody, Field of type SubmarineBody --- @realm shared --- @SubmarineBody SubBody - ---- --- PhysicsBody, Field of type PhysicsBody --- @realm shared --- @PhysicsBody PhysicsBody - ---- --- Borders, Field of type Rectangle --- @realm shared --- @Rectangle Borders - ---- --- VisibleBorders, Field of type Rectangle --- @realm shared --- @Rectangle VisibleBorders - ---- --- Position, Field of type Vector2 --- @realm shared --- @Vector2 Position - ---- --- WorldPosition, Field of type Vector2 --- @realm shared --- @Vector2 WorldPosition - ---- --- RealWorldCrushDepth, Field of type number --- @realm shared --- @number RealWorldCrushDepth - ---- --- RealWorldDepth, Field of type number --- @realm shared --- @number RealWorldDepth - ---- --- AtEndExit, Field of type bool --- @realm shared --- @bool AtEndExit - ---- --- AtStartExit, Field of type bool --- @realm shared --- @bool AtStartExit - ---- --- DrawPosition, Field of type Vector2 --- @realm shared --- @Vector2 DrawPosition - ---- --- SimPosition, Field of type Vector2 --- @realm shared --- @Vector2 SimPosition - ---- --- Velocity, Field of type Vector2 --- @realm shared --- @Vector2 Velocity - ---- --- HullVertices, Field of type table --- @realm shared --- @table HullVertices - ---- --- SubmarineSpecificIDTag, Field of type number --- @realm shared --- @number SubmarineSpecificIDTag - ---- --- AtDamageDepth, Field of type bool --- @realm shared --- @bool AtDamageDepth - ---- --- ImmuneToBallastFlora, Field of type bool --- @realm shared --- @bool ImmuneToBallastFlora - ---- --- WreckAI, Field of type WreckAI --- @realm shared --- @WreckAI WreckAI - ---- --- FlippedX, Field of type bool --- @realm shared --- @bool FlippedX - ---- --- Submarine.Unloading, Field of type bool --- @realm shared --- @bool Submarine.Unloading - ---- --- Removed, Field of type bool --- @realm shared --- @bool Removed - ---- --- IdFreed, Field of type bool --- @realm shared --- @bool IdFreed - ---- --- Submarine, Field of type Submarine --- @realm shared --- @Submarine Submarine - ---- --- AiTarget, Field of type AITarget --- @realm shared --- @AITarget AiTarget - ---- --- InDetectable, Field of type bool --- @realm shared --- @bool InDetectable - ---- --- SpawnTime, Field of type number --- @realm shared --- @number SpawnTime - ---- --- ErrorLine, Field of type string --- @realm shared --- @string ErrorLine - ---- --- TeamID, Field of type CharacterTeamType --- @realm shared --- @CharacterTeamType TeamID - ---- --- ConnectedDockingPorts, Field of type table --- @realm shared --- @table ConnectedDockingPorts - ---- --- ShowSonarMarker, Field of type bool --- @realm shared --- @bool ShowSonarMarker - ---- --- Submarine.HiddenSubStartPosition, Field of type Vector2 --- @realm shared --- @Vector2 Submarine.HiddenSubStartPosition - ---- --- Submarine.LockX, Field of type bool --- @realm shared --- @bool Submarine.LockX - ---- --- Submarine.LockY, Field of type bool --- @realm shared --- @bool Submarine.LockY - ---- --- Submarine.GridSize, Field of type Vector2 --- @realm shared --- @Vector2 Submarine.GridSize - ---- --- Submarine.MainSubs, Field of type Submarine[] --- @realm shared --- @Submarine[] Submarine.MainSubs - ---- --- ID, Field of type number --- @realm shared --- @number ID - ---- --- CreationStackTrace, Field of type string --- @realm shared --- @string CreationStackTrace - ---- --- CreationIndex, Field of type number --- @realm shared --- @number CreationIndex - diff --git a/docs/lua/generated/SubmarineInfo.lua b/docs/lua/generated/SubmarineInfo.lua deleted file mode 100644 index 9bf39fed4..000000000 --- a/docs/lua/generated/SubmarineInfo.lua +++ /dev/null @@ -1,307 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.SubmarineInfo -]] --- @code SubmarineInfo --- @pragma nostrip -local SubmarineInfo = {} - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Reload --- @realm shared -function Reload() end - ---- Dispose --- @realm shared -function Dispose() end - ---- IsVanillaSubmarine --- @realm shared --- @treturn bool -function IsVanillaSubmarine() end - ---- StartHashDocTask --- @realm shared --- @tparam XDocument doc -function StartHashDocTask(doc) end - ---- HasTag --- @realm shared --- @tparam SubmarineTag tag --- @treturn bool -function HasTag(tag) end - ---- AddTag --- @realm shared --- @tparam SubmarineTag tag -function AddTag(tag) end - ---- RemoveTag --- @realm shared --- @tparam SubmarineTag tag -function RemoveTag(tag) end - ---- CheckSubsLeftBehind --- @realm shared --- @tparam XElement element -function CheckSubsLeftBehind(element) end - ---- GetRealWorldCrushDepth --- @realm shared --- @treturn number -function GetRealWorldCrushDepth() end - ---- GetRealWorldCrushDepthMultiplier --- @realm shared --- @treturn number -function GetRealWorldCrushDepthMultiplier() end - ---- SaveAs --- @realm shared --- @tparam string filePath --- @tparam MemoryStream previewImage -function SaveAs(filePath, previewImage) end - ---- AddToSavedSubs --- @realm shared --- @tparam SubmarineInfo subInfo -function SubmarineInfo.AddToSavedSubs(subInfo) end - ---- RemoveSavedSub --- @realm shared --- @tparam string filePath -function SubmarineInfo.RemoveSavedSub(filePath) end - ---- RefreshSavedSub --- @realm shared --- @tparam string filePath -function SubmarineInfo.RefreshSavedSub(filePath) end - ---- RefreshSavedSubs --- @realm shared -function SubmarineInfo.RefreshSavedSubs() end - ---- OpenFile --- @realm shared --- @tparam string file --- @treturn XDocument -function SubmarineInfo.OpenFile(file) end - ---- OpenFile --- @realm shared --- @tparam string file --- @tparam Exception& exception --- @treturn XDocument -function SubmarineInfo.OpenFile(file, exception) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- SubmarineInfo.SavedSubmarines, Field of type Enumerable --- @realm shared --- @Enumerable SubmarineInfo.SavedSubmarines - ---- --- Tags, Field of type SubmarineTag --- @realm shared --- @SubmarineTag Tags - ---- --- EqualityCheckVal, Field of type number --- @realm shared --- @number EqualityCheckVal - ---- --- Name, Field of type string --- @realm shared --- @string Name - ---- --- DisplayName, Field of type LocalizedString --- @realm shared --- @LocalizedString DisplayName - ---- --- Description, Field of type LocalizedString --- @realm shared --- @LocalizedString Description - ---- --- Price, Field of type number --- @realm shared --- @number Price - ---- --- InitialSuppliesSpawned, Field of type bool --- @realm shared --- @bool InitialSuppliesSpawned - ---- --- GameVersion, Field of type Version --- @realm shared --- @Version GameVersion - ---- --- Type, Field of type SubmarineType --- @realm shared --- @SubmarineType Type - ---- --- OutpostModuleInfo, Field of type OutpostModuleInfo --- @realm shared --- @OutpostModuleInfo OutpostModuleInfo - ---- --- IsOutpost, Field of type bool --- @realm shared --- @bool IsOutpost - ---- --- IsWreck, Field of type bool --- @realm shared --- @bool IsWreck - ---- --- IsBeacon, Field of type bool --- @realm shared --- @bool IsBeacon - ---- --- IsPlayer, Field of type bool --- @realm shared --- @bool IsPlayer - ---- --- IsRuin, Field of type bool --- @realm shared --- @bool IsRuin - ---- --- IsCampaignCompatible, Field of type bool --- @realm shared --- @bool IsCampaignCompatible - ---- --- IsCampaignCompatibleIgnoreClass, Field of type bool --- @realm shared --- @bool IsCampaignCompatibleIgnoreClass - ---- --- MD5Hash, Field of type Md5Hash --- @realm shared --- @Md5Hash MD5Hash - ---- --- CalculatingHash, Field of type bool --- @realm shared --- @bool CalculatingHash - ---- --- Dimensions, Field of type Vector2 --- @realm shared --- @Vector2 Dimensions - ---- --- CargoCapacity, Field of type number --- @realm shared --- @number CargoCapacity - ---- --- FilePath, Field of type string --- @realm shared --- @string FilePath - ---- --- SubmarineElement, Field of type XElement --- @realm shared --- @XElement SubmarineElement - ---- --- IsFileCorrupted, Field of type bool --- @realm shared --- @bool IsFileCorrupted - ---- --- RequiredContentPackagesInstalled, Field of type bool --- @realm shared --- @bool RequiredContentPackagesInstalled - ---- --- SubsLeftBehind, Field of type bool --- @realm shared --- @bool SubsLeftBehind - ---- --- LeftBehindSubDockingPortOccupied, Field of type bool --- @realm shared --- @bool LeftBehindSubDockingPortOccupied - ---- --- LastModifiedTime, Field of type DateTime --- @realm shared --- @DateTime LastModifiedTime - ---- --- RecommendedCrewSizeMin, Field of type number --- @realm shared --- @number RecommendedCrewSizeMin - ---- --- RecommendedCrewSizeMax, Field of type number --- @realm shared --- @number RecommendedCrewSizeMax - ---- --- RecommendedCrewExperience, Field of type string --- @realm shared --- @string RecommendedCrewExperience - ---- --- RequiredContentPackages, Field of type HashSet`1 --- @realm shared --- @HashSet`1 RequiredContentPackages - ---- --- SubmarineClass, Field of type SubmarineClass --- @realm shared --- @SubmarineClass SubmarineClass - ---- --- LeftBehindDockingPortIDs, Field of type table --- @realm shared --- @table LeftBehindDockingPortIDs - ---- --- BlockedDockingPortIDs, Field of type table --- @realm shared --- @table BlockedDockingPortIDs - ---- --- OutpostGenerationParams, Field of type OutpostGenerationParams --- @realm shared --- @OutpostGenerationParams OutpostGenerationParams - ---- --- OutpostNPCs, Field of type table --- @realm shared --- @table OutpostNPCs - diff --git a/docs/lua/generated/WayPoint.lua b/docs/lua/generated/WayPoint.lua deleted file mode 100644 index ea7cde27f..000000000 --- a/docs/lua/generated/WayPoint.lua +++ /dev/null @@ -1,507 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -Barotrauma.WayPoint -]] --- @code WayPoint --- @pragma nostrip -local WayPoint = {} - ---- Clone --- @realm shared --- @treturn MapEntity -function Clone() end - ---- GenerateSubWaypoints --- @realm shared --- @tparam Submarine submarine --- @treturn bool -function WayPoint.GenerateSubWaypoints(submarine) end - ---- ConnectTo --- @realm shared --- @tparam WayPoint wayPoint2 -function ConnectTo(wayPoint2) end - ---- GetRandom --- @realm shared --- @tparam SpawnType spawnType --- @tparam JobPrefab assignedJob --- @tparam Submarine sub --- @tparam bool useSyncedRand --- @tparam string spawnPointTag --- @tparam bool ignoreSubmarine --- @treturn WayPoint -function WayPoint.GetRandom(spawnType, assignedJob, sub, useSyncedRand, spawnPointTag, ignoreSubmarine) end - ---- SelectCrewSpawnPoints --- @realm shared --- @tparam table crew --- @tparam Submarine submarine --- @treturn WayPoint[] -function WayPoint.SelectCrewSpawnPoints(crew, submarine) end - ---- FindHull --- @realm shared -function FindHull() end - ---- OnMapLoaded --- @realm shared -function OnMapLoaded() end - ---- InitializeLinks --- @realm shared -function InitializeLinks() end - ---- Load --- @realm shared --- @tparam ContentXElement element --- @tparam Submarine submarine --- @tparam IdRemap idRemap --- @treturn WayPoint -function WayPoint.Load(element, submarine, idRemap) end - ---- Save --- @realm shared --- @tparam XElement parentElement --- @treturn XElement -function Save(parentElement) end - ---- ShallowRemove --- @realm shared -function ShallowRemove() end - ---- Remove --- @realm shared -function Remove() end - ---- AddLinked --- @realm shared --- @tparam MapEntity entity -function AddLinked(entity) end - ---- ResolveLinks --- @realm shared --- @tparam IdRemap childRemap -function ResolveLinks(childRemap) end - ---- Move --- @realm shared --- @tparam Vector2 amount -function Move(amount) end - ---- IsMouseOn --- @realm shared --- @tparam Vector2 position --- @treturn bool -function IsMouseOn(position) end - ---- HasUpgrade --- @realm shared --- @tparam Identifier identifier --- @treturn bool -function HasUpgrade(identifier) end - ---- GetUpgrade --- @realm shared --- @tparam Identifier identifier --- @treturn Upgrade -function GetUpgrade(identifier) end - ---- GetUpgrades --- @realm shared --- @treturn table -function GetUpgrades() end - ---- SetUpgrade --- @realm shared --- @tparam Upgrade upgrade --- @tparam bool createNetworkEvent -function SetUpgrade(upgrade, createNetworkEvent) end - ---- AddUpgrade --- @realm shared --- @tparam Upgrade upgrade --- @tparam bool createNetworkEvent --- @treturn bool -function AddUpgrade(upgrade, createNetworkEvent) end - ---- Update --- @realm shared --- @tparam number deltaTime --- @tparam Camera cam -function Update(deltaTime, cam) end - ---- FlipX --- @realm shared --- @tparam bool relativeToSub -function FlipX(relativeToSub) end - ---- FlipY --- @realm shared --- @tparam bool relativeToSub -function FlipY(relativeToSub) end - ---- RemoveLinked --- @realm shared --- @tparam MapEntity e -function RemoveLinked(e) end - ---- GetLinkedEntities --- @realm shared --- @tparam HashSet`1 list --- @tparam Nullable`1 maxDepth --- @tparam function filter --- @treturn HashSet`1 -function GetLinkedEntities(list, maxDepth, filter) end - ---- FreeID --- @realm shared -function FreeID() end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- ConnectedGap, Field of type Gap --- @realm shared --- @Gap ConnectedGap - ---- --- ConnectedDoor, Field of type Door --- @realm shared --- @Door ConnectedDoor - ---- --- CurrentHull, Field of type Hull --- @realm shared --- @Hull CurrentHull - ---- --- SpawnType, Field of type SpawnType --- @realm shared --- @SpawnType SpawnType - ---- --- OnLinksChanged, Field of type function --- @realm shared --- @function OnLinksChanged - ---- --- Name, Field of type string --- @realm shared --- @string Name - ---- --- IdCardDesc, Field of type string --- @realm shared --- @string IdCardDesc - ---- --- IdCardTags, Field of type String[] --- @realm shared --- @String[] IdCardTags - ---- --- Tags, Field of type Enumerable --- @realm shared --- @Enumerable Tags - ---- --- AssignedJob, Field of type JobPrefab --- @realm shared --- @JobPrefab AssignedJob - ---- --- DisallowedUpgrades, Field of type string --- @realm shared --- @string DisallowedUpgrades - ---- --- FlippedX, Field of type bool --- @realm shared --- @bool FlippedX - ---- --- FlippedY, Field of type bool --- @realm shared --- @bool FlippedY - ---- --- IsHighlighted, Field of type bool --- @realm shared --- @bool IsHighlighted - ---- --- Rect, Field of type Rectangle --- @realm shared --- @Rectangle Rect - ---- --- WorldRect, Field of type Rectangle --- @realm shared --- @Rectangle WorldRect - ---- --- Sprite, Field of type Sprite --- @realm shared --- @Sprite Sprite - ---- --- DrawBelowWater, Field of type bool --- @realm shared --- @bool DrawBelowWater - ---- --- DrawOverWater, Field of type bool --- @realm shared --- @bool DrawOverWater - ---- --- Linkable, Field of type bool --- @realm shared --- @bool Linkable - ---- --- AllowedLinks, Field of type Enumerable --- @realm shared --- @Enumerable AllowedLinks - ---- --- ResizeHorizontal, Field of type bool --- @realm shared --- @bool ResizeHorizontal - ---- --- ResizeVertical, Field of type bool --- @realm shared --- @bool ResizeVertical - ---- --- RectWidth, Field of type number --- @realm shared --- @number RectWidth - ---- --- RectHeight, Field of type number --- @realm shared --- @number RectHeight - ---- --- SpriteDepthOverrideIsSet, Field of type bool --- @realm shared --- @bool SpriteDepthOverrideIsSet - ---- --- SpriteOverrideDepth, Field of type number --- @realm shared --- @number SpriteOverrideDepth - ---- --- SpriteDepth, Field of type number --- @realm shared --- @number SpriteDepth - ---- --- Scale, Field of type number --- @realm shared --- @number Scale - ---- --- HiddenInGame, Field of type bool --- @realm shared --- @bool HiddenInGame - ---- --- Position, Field of type Vector2 --- @realm shared --- @Vector2 Position - ---- --- SimPosition, Field of type Vector2 --- @realm shared --- @Vector2 SimPosition - ---- --- SoundRange, Field of type number --- @realm shared --- @number SoundRange - ---- --- SightRange, Field of type number --- @realm shared --- @number SightRange - ---- --- RemoveIfLinkedOutpostDoorInUse, Field of type bool --- @realm shared --- @bool RemoveIfLinkedOutpostDoorInUse - ---- --- Layer, Field of type string --- @realm shared --- @string Layer - ---- --- Removed, Field of type bool --- @realm shared --- @bool Removed - ---- --- IdFreed, Field of type bool --- @realm shared --- @bool IdFreed - ---- --- WorldPosition, Field of type Vector2 --- @realm shared --- @Vector2 WorldPosition - ---- --- DrawPosition, Field of type Vector2 --- @realm shared --- @Vector2 DrawPosition - ---- --- Submarine, Field of type Submarine --- @realm shared --- @Submarine Submarine - ---- --- AiTarget, Field of type AITarget --- @realm shared --- @AITarget AiTarget - ---- --- InDetectable, Field of type bool --- @realm shared --- @bool InDetectable - ---- --- SpawnTime, Field of type number --- @realm shared --- @number SpawnTime - ---- --- ErrorLine, Field of type string --- @realm shared --- @string ErrorLine - ---- --- Ladders, Field of type Ladder --- @realm shared --- @Ladder Ladders - ---- --- Stairs, Field of type Structure --- @realm shared --- @Structure Stairs - ---- --- isObstructed, Field of type bool --- @realm shared --- @bool isObstructed - ---- --- Tunnel, Field of type Tunnel --- @realm shared --- @Tunnel Tunnel - ---- --- Ruin, Field of type Ruin --- @realm shared --- @Ruin Ruin - ---- --- WayPoint.WayPointList, Field of type table --- @realm shared --- @table WayPoint.WayPointList - ---- --- WayPoint.ShowWayPoints, Field of type bool --- @realm shared --- @bool WayPoint.ShowWayPoints - ---- --- WayPoint.ShowSpawnPoints, Field of type bool --- @realm shared --- @bool WayPoint.ShowSpawnPoints - ---- --- WayPoint.LadderWaypointInterval, Field of type number --- @realm shared --- @number WayPoint.LadderWaypointInterval - ---- --- Prefab, Field of type MapEntityPrefab --- @realm shared --- @MapEntityPrefab Prefab - ---- --- unresolvedLinkedToID, Field of type table --- @realm shared --- @table unresolvedLinkedToID - ---- --- DisallowedUpgradeSet, Field of type HashSet`1 --- @realm shared --- @HashSet`1 DisallowedUpgradeSet - ---- --- linkedTo, Field of type table --- @realm shared --- @table linkedTo - ---- --- ShouldBeSaved, Field of type bool --- @realm shared --- @bool ShouldBeSaved - ---- --- ExternalHighlight, Field of type bool --- @realm shared --- @bool ExternalHighlight - ---- --- OriginalModuleIndex, Field of type number --- @realm shared --- @number OriginalModuleIndex - ---- --- OriginalContainerIndex, Field of type number --- @realm shared --- @number OriginalContainerIndex - ---- --- ID, Field of type number --- @realm shared --- @number ID - ---- --- CreationStackTrace, Field of type string --- @realm shared --- @string CreationStackTrace - ---- --- CreationIndex, Field of type number --- @realm shared --- @number CreationIndex - diff --git a/docs/lua/generated/World.lua b/docs/lua/generated/World.lua deleted file mode 100644 index d930c88cf..000000000 --- a/docs/lua/generated/World.lua +++ /dev/null @@ -1,478 +0,0 @@ --- luacheck: ignore 111 - ---[[-- -FarseerPhysics.Dynamics.World -]] --- @code Game.World --- @pragma nostrip -local World = {} - ---- Add --- @realm shared --- @tparam Body body -function Add(body) end - ---- Remove --- @realm shared --- @tparam Body body -function Remove(body) end - ---- Add --- @realm shared --- @tparam Joint joint -function Add(joint) end - ---- Remove --- @realm shared --- @tparam Joint joint -function Remove(joint) end - ---- AddAsync --- @realm shared --- @tparam Body body -function AddAsync(body) end - ---- RemoveAsync --- @realm shared --- @tparam Body body -function RemoveAsync(body) end - ---- AddAsync --- @realm shared --- @tparam Joint joint -function AddAsync(joint) end - ---- RemoveAsync --- @realm shared --- @tparam Joint joint -function RemoveAsync(joint) end - ---- ProcessChanges --- @realm shared -function ProcessChanges() end - ---- Step --- @realm shared --- @tparam TimeSpan dt -function Step(dt) end - ---- Step --- @realm shared --- @tparam TimeSpan dt --- @tparam SolverIterations& iterations -function Step(dt, iterations) end - ---- Step --- @realm shared --- @tparam number dt -function Step(dt) end - ---- Step --- @realm shared --- @tparam number dt --- @tparam SolverIterations& iterations -function Step(dt, iterations) end - ---- ClearForces --- @realm shared -function ClearForces() end - ---- QueryAABB --- @realm shared --- @tparam function callback --- @tparam AABB& aabb -function QueryAABB(callback, aabb) end - ---- QueryAABB --- @realm shared --- @tparam AABB& aabb --- @treturn table -function QueryAABB(aabb) end - ---- RayCast --- @realm shared --- @tparam function callback --- @tparam Vector2 point1 --- @tparam Vector2 point2 --- @tparam Category collisionCategory -function RayCast(callback, point1, point2, collisionCategory) end - ---- RayCast --- @realm shared --- @tparam Vector2 point1 --- @tparam Vector2 point2 --- @treturn table -function RayCast(point1, point2) end - ---- Add --- @realm shared --- @tparam Controller controller -function Add(controller) end - ---- Remove --- @realm shared --- @tparam Controller controller -function Remove(controller) end - ---- TestPoint --- @realm shared --- @tparam Vector2 point --- @treturn Fixture -function TestPoint(point) end - ---- TestPointAll --- @realm shared --- @tparam Vector2 point --- @treturn table -function TestPointAll(point) end - ---- ShiftOrigin --- @realm shared --- @tparam Vector2 newOrigin -function ShiftOrigin(newOrigin) end - ---- Clear --- @realm shared -function Clear() end - ---- CreateBody --- @realm shared --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateBody(position, rotation, bodyType) end - ---- CreateEdge --- @realm shared --- @tparam Vector2 start --- @tparam Vector2 endparam --- @treturn Body -function CreateEdge(start, endparam) end - ---- CreateChainShape --- @realm shared --- @tparam Vertices vertices --- @tparam Vector2 position --- @treturn Body -function CreateChainShape(vertices, position) end - ---- CreateLoopShape --- @realm shared --- @tparam Vertices vertices --- @tparam Vector2 position --- @treturn Body -function CreateLoopShape(vertices, position) end - ---- CreateRectangle --- @realm shared --- @tparam number width --- @tparam number height --- @tparam number density --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateRectangle(width, height, density, position, rotation, bodyType) end - ---- CreateCircle --- @realm shared --- @tparam number radius --- @tparam number density --- @tparam Vector2 position --- @tparam BodyType bodyType --- @treturn Body -function CreateCircle(radius, density, position, bodyType) end - ---- CreateEllipse --- @realm shared --- @tparam number xRadius --- @tparam number yRadius --- @tparam number edges --- @tparam number density --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateEllipse(xRadius, yRadius, edges, density, position, rotation, bodyType) end - ---- CreatePolygon --- @realm shared --- @tparam Vertices vertices --- @tparam number density --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreatePolygon(vertices, density, position, rotation, bodyType) end - ---- CreateCompoundPolygon --- @realm shared --- @tparam table list --- @tparam number density --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateCompoundPolygon(list, density, position, rotation, bodyType) end - ---- CreateGear --- @realm shared --- @tparam number radius --- @tparam number numberOfTeeth --- @tparam number tipPercentage --- @tparam number toothHeight --- @tparam number density --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateGear(radius, numberOfTeeth, tipPercentage, toothHeight, density, position, rotation, bodyType) end - ---- CreateCapsule --- @realm shared --- @tparam number height --- @tparam number topRadius --- @tparam number topEdges --- @tparam number bottomRadius --- @tparam number bottomEdges --- @tparam number density --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateCapsule(height, topRadius, topEdges, bottomRadius, bottomEdges, density, position, rotation, bodyType) end - ---- CreateCapsuleHorizontal --- @realm shared --- @tparam number width --- @tparam number endRadius --- @tparam number density --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateCapsuleHorizontal(width, endRadius, density, position, rotation, bodyType) end - ---- CreateCapsule --- @realm shared --- @tparam number height --- @tparam number endRadius --- @tparam number density --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateCapsule(height, endRadius, density, position, rotation, bodyType) end - ---- CreateRoundedRectangle --- @realm shared --- @tparam number width --- @tparam number height --- @tparam number xRadius --- @tparam number yRadius --- @tparam number segments --- @tparam number density --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateRoundedRectangle(width, height, xRadius, yRadius, segments, density, position, rotation, bodyType) end - ---- CreateLineArc --- @realm shared --- @tparam number radians --- @tparam number sides --- @tparam number radius --- @tparam bool closed --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateLineArc(radians, sides, radius, closed, position, rotation, bodyType) end - ---- CreateSolidArc --- @realm shared --- @tparam number density --- @tparam number radians --- @tparam number sides --- @tparam number radius --- @tparam Vector2 position --- @tparam number rotation --- @tparam BodyType bodyType --- @treturn Body -function CreateSolidArc(density, radians, sides, radius, position, rotation, bodyType) end - ---- CreateChain --- @realm shared --- @tparam Vector2 start --- @tparam Vector2 endparam --- @tparam number linkWidth --- @tparam number linkHeight --- @tparam number numberOfLinks --- @tparam number linkDensity --- @tparam bool attachRopeJoint --- @treturn Path -function CreateChain(start, endparam, linkWidth, linkHeight, numberOfLinks, linkDensity, attachRopeJoint) end - ---- GetType --- @realm shared --- @treturn Type -function GetType() end - ---- ToString --- @realm shared --- @treturn string -function ToString() end - ---- Equals --- @realm shared --- @tparam Object obj --- @treturn bool -function Equals(obj) end - ---- GetHashCode --- @realm shared --- @treturn number -function GetHashCode() end - ---- --- Fluid, Field of type FluidSystem2 --- @realm shared --- @FluidSystem2 Fluid - ---- --- UpdateTime, Field of type TimeSpan --- @realm shared --- @TimeSpan UpdateTime - ---- --- ContinuousPhysicsTime, Field of type TimeSpan --- @realm shared --- @TimeSpan ContinuousPhysicsTime - ---- --- ControllersUpdateTime, Field of type TimeSpan --- @realm shared --- @TimeSpan ControllersUpdateTime - ---- --- AddRemoveTime, Field of type TimeSpan --- @realm shared --- @TimeSpan AddRemoveTime - ---- --- NewContactsTime, Field of type TimeSpan --- @realm shared --- @TimeSpan NewContactsTime - ---- --- ContactsUpdateTime, Field of type TimeSpan --- @realm shared --- @TimeSpan ContactsUpdateTime - ---- --- SolveUpdateTime, Field of type TimeSpan --- @realm shared --- @TimeSpan SolveUpdateTime - ---- --- ProxyCount, Field of type number --- @realm shared --- @number ProxyCount - ---- --- ContactCount, Field of type number --- @realm shared --- @number ContactCount - ---- --- IsLocked, Field of type bool --- @realm shared --- @bool IsLocked - ---- --- ContactList, Field of type ContactListHead --- @realm shared --- @ContactListHead ContactList - ---- --- Enabled, Field of type bool --- @realm shared --- @bool Enabled - ---- --- Island, Field of type Island --- @realm shared --- @Island Island - ---- --- Tag, Field of type Object --- @realm shared --- @Object Tag - ---- --- BodyAdded, Field of type BodyDelegate --- @realm shared --- @BodyDelegate BodyAdded - ---- --- BodyRemoved, Field of type BodyDelegate --- @realm shared --- @BodyDelegate BodyRemoved - ---- --- FixtureAdded, Field of type FixtureDelegate --- @realm shared --- @FixtureDelegate FixtureAdded - ---- --- FixtureRemoved, Field of type FixtureDelegate --- @realm shared --- @FixtureDelegate FixtureRemoved - ---- --- JointAdded, Field of type JointDelegate --- @realm shared --- @JointDelegate JointAdded - ---- --- JointRemoved, Field of type JointDelegate --- @realm shared --- @JointDelegate JointRemoved - ---- --- ControllerAdded, Field of type ControllerDelegate --- @realm shared --- @ControllerDelegate ControllerAdded - ---- --- ControllerRemoved, Field of type ControllerDelegate --- @realm shared --- @ControllerDelegate ControllerRemoved - ---- --- ControllerList, Field of type table --- @realm shared --- @table ControllerList - ---- --- Gravity, Field of type Vector2 --- @realm shared --- @Vector2 Gravity - ---- --- ContactManager, Field of type ContactManager --- @realm shared --- @ContactManager ContactManager - ---- --- BodyList, Field of type table --- @realm shared --- @table BodyList - ---- --- JointList, Field of type table --- @realm shared --- @table JointList - diff --git a/docs/manual/how-to-use-hooks.md b/docs/manual/how-to-use-hooks.md deleted file mode 100644 index c57a42036..000000000 --- a/docs/manual/how-to-use-hooks.md +++ /dev/null @@ -1,51 +0,0 @@ -# How to use hooks - -Hooks are basically functions that get called when events happen in-game, like chat messages. They can be triggered either by Lua itself or the game code. - -## Adding hooks - -Hooks can be added like this: - -``` -Hook.Add("chatMessage", "test", function(message, client) - print(client.Name .. " has sent " .. message) -end) -``` - -The event name (first argument), is case-insensitive, so you can call it chatMessage, cHaTmEsSaGe, chatmessage, etc. - -## Calling hooks - -You can also call hooks with the following code: - -``` -Hook.Call("myCustomEvent", {"some", "arguments", 123}) -``` - -## XML Status Effect Hooks - -With Lua, a new XML tags is added, it can be used to call Lua hooks inside status effects: - -``` - - - -``` - -``` -Hook.Add("doSomething", "something", function (effect, deltaTime, item, targets, worldPosition) - print(effect, ' ', item) -end) -``` - -## Patching - -Patching allows you to hook into existing methods in the game code, notice that it can be a little unstable depending on the method that you are patching, so be aware. - -``` -Hook.HookMethod("Barotrauma.CharacterInfo", "IncreaseSkillLevel", function (instance, ptable) - print(string.format("%s gained % xp", instance.Character.Name, ptable.increase)) -end, Hook.HookMethodType.After) -``` - -If you return anything other than nil, it will stop the execution of the method, if the method has a return type, it will also return what you returned in the Lua function. (Only in Hook.HookMethodType.After) \ No newline at end of file diff --git a/docs/templates/landing.ltp b/docs/templates/landing.ltp deleted file mode 100644 index 060380193..000000000 --- a/docs/templates/landing.ltp +++ /dev/null @@ -1,24 +0,0 @@ - -
-

Lua For Barotrauma Documentation

-
- -
-

-

Welcome to the Lua For Barotrauma documentation!

-

This is a work in progress documentation, not everything is documented here, but because Barotrauma classes are exposed to Lua, you can check the Barotrauma source code for functions and fields that you can access.

- -

Installing Lua For Barotrauma

-

Downloading and using the Core Content Package from Workshop should be enough to have it installed, but if you want to install it manually, you can check out this guide. -

- -

Getting Started

-

If you want to get started with Lua For Barotrauma modding, check out this guide. -

- -

Links

-

- Github
- Discord Server -

-
diff --git a/docs/templates/ldoc.ltp b/docs/templates/ldoc.ltp deleted file mode 100644 index d0b6f6e6f..000000000 --- a/docs/templates/ldoc.ltp +++ /dev/null @@ -1,90 +0,0 @@ - -{% -local baseUrl = ldoc.css:gsub("ldoc.css", "") -local repo = "https://github.com/evilfactory/Barotrauma-lua-attempt/" -local pageTitle = mod and (ldoc.display_name(mod) .. " - " .. ldoc.title) or ldoc.title - -local oldmarkup = ldoc.markup -function ldoc.markup(text, item) - return oldmarkup(text, item, ldoc.plain) -end - -function ldoc.url(path) - return baseUrl .. path -end - -function ldoc.realm_icon(realm) - return ""; -end - -function ldoc.is_kind_classmethod(kind) - return kind ~= "libraries" -end - -function ldoc.repo_reference(item) - return repo .. "tree/master" .. item.file.filename:gsub(item.file.base, "/gamemode") .. "#L" .. item.lineno -end - -local function moduleDescription(mod) - if (mod.type == "topic") then - return mod.body:gsub(mod.display_name, ""):gsub("#", ""):sub(1, 256) .. "..." - end - - return mod.summary -end -%} - - - - {{pageTitle}} - - - - - - {% if (mod) then %} - - {% else %} - - {% end %} - - - - - - - -
- {(docs/templates/sidebar.ltp)} - -
- {% if (ldoc.root) then -- we're rendering the landing page (index.html) %} - {(docs/templates/landing.ltp)} - {% elseif (ldoc.body) then -- we're rendering non-code elements %} -
- {* ldoc.body *} -
- {% elseif (module) then -- we're rendering libary contents %} -
- {(docs/templates/module.ltp)} -
- {% end %} -
-
- - - - - - diff --git a/docs/templates/module.ltp b/docs/templates/module.ltp deleted file mode 100644 index 6e9e76931..000000000 --- a/docs/templates/module.ltp +++ /dev/null @@ -1,147 +0,0 @@ - -
-

{{mod.name}}

-

{* ldoc.markup(mod.summary) *}

-
- -

{* ldoc.markup(mod.description) *}

- -{% - local kinds = {} - local kindsIpairs = {} - for kind, items in mod.kinds() do - local name = kind - if kind == "Tables" then - name = "Fields" - end - - for item in items() do - if kinds[name] == nil then - kinds[name] = {} - - local value = {} - value.kind = name - value.items = kinds[name] - table.insert(kindsIpairs, value) - end - kinds[name][item] = true - end - end - - -%} - -{% for i, value in ipairs(kindsIpairs) do - local kind = value.kind - local items = value.items -%} -

{{kind}}

- - {% for item, _ in pairs(items) do %} -
-
- -

{* ldoc.realm_icon(item.tags.realm[1]) *}{{ldoc.display_name(item)}}

-
- - {% if (item.tags.internal) then %} -
-
Internal
-

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

-
- {% end %} - - {% if (ldoc.descript(item):len() == 0) then %} -
-
Incomplete
-

Documentation for this section is incomplete and needs expanding.

-
- {% else %} -

{* ldoc.markup(ldoc.descript(item)) *}

- {% end %} -
- - {# function arguments #} - {% if (item.params and #item.params > 0) then %} - {% local subnames = mod.kinds:type_of(item).subnames %} - - {% if (subnames) then %} -

{{subnames}}

- {% end %} - - {% for argument in ldoc.modules.iter(item.params) do %} - {% local argument, sublist = item:subparam(argument) %} - -
    - {% for argumentName in ldoc.modules.iter(argument) do %} - {% local displayName = item:display_name_of(argumentName) %} - {% local type = ldoc.typename(item:type_of_param(argumentName)) %} - {% local default = item:default_of_param(argumentName) %} - -
  • - {{displayName}} - - {% if (type ~= "") then %} - {* type *} - {% end %} - - {% if (default and default ~= true) then %} - default: {{default}} - {% elseif (default) then %} - optional - {% end %} - -

    {* ldoc.markup(item.params.map[argumentName]) *}

    -
  • - {% end %} -
- {% end %} - {% end %} - - {# function returns #} - {% if ((not ldoc.no_return_or_parms) and item.retgroups) then %} - {% local groups = item.retgroups %} - -

Returns

-
    - {% for i, group in ldoc.ipairs(groups) do %} - {% for returnValue in group:iter() do %} - {% local type, ctypes = item:return_type(returnValue) %} - {% type = ldoc.typename(type) %} - -
  • - {% if (type ~= "") then %} - {* type *} - {% else -- we'll assume that it will return a variable type if none is set %} - any - {% end %} - -

    {* ldoc.markup(returnValue.text) *}

    -
  • - {% end %} - - {% if (i ~= #groups) then %} -
    OR
    - {% end %} - {% end %} -
- {% end %} - - {% if (item.usage) then -- function usage %} -

Example Usage

- {% for usage in ldoc.modules.iter(item.usage) do %} -
{* usage *}
- {% end %} - {% end %} - - {% if (item.see) then %} -

See Also

-
    - {% for see in ldoc.modules.iter(item.see) do %} -
  • {{see.label}}
  • - {% end %} -
- {% end %} -
- {% end %} -{% end %} diff --git a/docs/templates/sidebar.ltp b/docs/templates/sidebar.ltp deleted file mode 100644 index c3f6dc3dc..000000000 --- a/docs/templates/sidebar.ltp +++ /dev/null @@ -1,116 +0,0 @@ - -{% -local function isKindExpandable(kind) - return kind ~= "Manual" -end -%} - - diff --git a/doxygen/DoxygenLayout.xml b/doxygen/DoxygenLayout.xml deleted file mode 100644 index 17afc9d01..000000000 --- a/doxygen/DoxygenLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/doxygen/baro-client/DoxygenLayout.xml b/doxygen/baro-client/DoxygenLayout.xml deleted file mode 100644 index eff4d0fbb..000000000 --- a/doxygen/baro-client/DoxygenLayout.xml +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/doxygen/baro-server/DoxygenLayout.xml b/doxygen/baro-server/DoxygenLayout.xml deleted file mode 100644 index 4eba30d35..000000000 --- a/doxygen/baro-server/DoxygenLayout.xml +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/doxygen/build-docs.bat b/doxygen/build-docs.bat deleted file mode 100644 index 959a3bcf9..000000000 --- a/doxygen/build-docs.bat +++ /dev/null @@ -1,16 +0,0 @@ -@echo off -if not exist ".\build" mkdir ".\build" -if not exist ".\build\baro-server" mkdir ".\build\baro-server" -if not exist ".\build\baro-client" mkdir ".\build\baro-client" - -cd .\baro-server -echo Building server documentation -doxygen Doxyfile - -cd ..\baro-client -echo Building client documentation -doxygen Doxyfile - -cd .. -echo Building shared documentation -doxygen Doxyfile \ No newline at end of file diff --git a/doxygen/build-shared.bat b/doxygen/build-shared.bat deleted file mode 100644 index 7023da7f2..000000000 --- a/doxygen/build-shared.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -if not exist ".\build" mkdir ".\build" - -echo Building shared documentation -doxygen Doxyfile \ No newline at end of file diff --git a/luacs-docs/.editorconfig b/luacs-docs/.editorconfig new file mode 100644 index 000000000..74e06f2a2 --- /dev/null +++ b/luacs-docs/.editorconfig @@ -0,0 +1,16 @@ +[*] +end_of_line = lf + +[*.cs] +indent_style = space +indent_size = 2 +csharp_prefer_braces = when_multiline:warning +csharp_indent_case_contents_when_block = false +# One True Brace style +csharp_new_line_before_open_brace = none +csharp_new_line_before_else = false +csharp_new_line_before_catch = false +csharp_new_line_before_finally = false +csharp_new_line_before_members_in_object_initializers = false +csharp_new_line_before_members_in_anonymous_types = false +csharp_new_line_between_query_expression_clauses = false diff --git a/luacs-docs/.gitattributes b/luacs-docs/.gitattributes new file mode 100644 index 000000000..734a45377 --- /dev/null +++ b/luacs-docs/.gitattributes @@ -0,0 +1,2 @@ +# prevent git from converting our line endings to CRLF +* text=auto eol=lf diff --git a/luacs-docs/cs/.gitignore b/luacs-docs/cs/.gitignore new file mode 100644 index 000000000..297697bce --- /dev/null +++ b/luacs-docs/cs/.gitignore @@ -0,0 +1,4 @@ +html +*/html +*/*.tag +build diff --git a/doxygen/Doxyfile b/luacs-docs/cs/Doxyfile similarity index 100% rename from doxygen/Doxyfile rename to luacs-docs/cs/Doxyfile diff --git a/luacs-docs/cs/DoxygenLayout.xml b/luacs-docs/cs/DoxygenLayout.xml new file mode 100644 index 000000000..d43a0a564 --- /dev/null +++ b/luacs-docs/cs/DoxygenLayout.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/doxygen/baro-client/Doxyfile b/luacs-docs/cs/baro-client/Doxyfile similarity index 99% rename from doxygen/baro-client/Doxyfile rename to luacs-docs/cs/baro-client/Doxyfile index 16faf32d5..66f47267f 100644 --- a/doxygen/baro-client/Doxyfile +++ b/luacs-docs/cs/baro-client/Doxyfile @@ -906,8 +906,8 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ../../Barotrauma/BarotraumaShared/SharedSource \ - ../../Barotrauma/BarotraumaClient/ClientSource +INPUT = ../../../Barotrauma/BarotraumaShared/SharedSource \ + ../../../Barotrauma/BarotraumaClient/ClientSource # 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 diff --git a/luacs-docs/cs/baro-client/DoxygenLayout.xml b/luacs-docs/cs/baro-client/DoxygenLayout.xml new file mode 100644 index 000000000..8dc37b112 --- /dev/null +++ b/luacs-docs/cs/baro-client/DoxygenLayout.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doxygen/baro-server/Doxyfile b/luacs-docs/cs/baro-server/Doxyfile similarity index 99% rename from doxygen/baro-server/Doxyfile rename to luacs-docs/cs/baro-server/Doxyfile index 9915adeeb..bf64a80e3 100644 --- a/doxygen/baro-server/Doxyfile +++ b/luacs-docs/cs/baro-server/Doxyfile @@ -906,8 +906,8 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ../../Barotrauma/BarotraumaShared/SharedSource \ - ../../Barotrauma/BarotraumaServer/ServerSource +INPUT = ../../../Barotrauma/BarotraumaShared/SharedSource \ + ../../../Barotrauma/BarotraumaServer/ServerSource # 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 diff --git a/luacs-docs/cs/baro-server/DoxygenLayout.xml b/luacs-docs/cs/baro-server/DoxygenLayout.xml new file mode 100644 index 000000000..e3cf9460f --- /dev/null +++ b/luacs-docs/cs/baro-server/DoxygenLayout.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doxygen/custom.css b/luacs-docs/cs/custom.css similarity index 72% rename from doxygen/custom.css rename to luacs-docs/cs/custom.css index 33add5ebf..95930c3ac 100644 --- a/doxygen/custom.css +++ b/luacs-docs/cs/custom.css @@ -18,164 +18,137 @@ div.fragment { padding-left: 3px; padding-right: 3px; } - -body -{ + +body { background-color: #333333; /** for docs **/ color: #a1a1a1; } -#page-content -{ +#page-content { background-color: #333333; color: #bcbcbc; } -pre, pre.fragment -{ +pre, pre.fragment { background-color: #282828; } -.icon -{ +.icon { color: #333; background-color: #2f436b; /* from orig #728DC1; */; } -.arrow -{ +.arrow { color: #324872; /* from orig #9CAFD4; */; } /* to make keyword visible for above 'pre' */ -.highlight .nf -{ +.highlight .nf { color: #00adee; } -img -{ +img { background-color: #333333; } /** Note/Message boxes **/ -div.admonition, div.warning -{ +div.admonition, div.warning { background-color: #474747; } -div.admonition p.admonition-title, div.warning p.admonition-title -{ +div.admonition p.admonition-title, div.warning p.admonition-title { background-color: #707070; } /**** News ***/ -#content-outer -{ +#content-outer { background-color: #333333; } -.postmeta -{ +.postmeta { background-color: #474747; border-color: #595959; } /**** Blog ****/ -div.blogpost -{ +div.blogpost { background-color: #333; } -div.blogpost-header -{ +div.blogpost-header { background-color: #333; } -div.blogbody -{ +div.blogbody { background-color: #474747; } /**** Jobs ****/ -.dataTable tbody .even -{ +.dataTable tbody .even { background-color: #474747; } -.dataTable thead th -{ +.dataTable thead th { background-color: #6b6b6b; } /* Job Post Overlay */ -#fancybox-outer -{ +#fancybox-outer { color: #bcbcbc; background-color: #282828; } /***** Search box *****/ -#MSearchBox -{ +#MSearchBox { background-color: #333333; } -#MSearchBox .left -{ +#MSearchBox .left { filter: invert(80%); } -#MSearchSelect -{ +#MSearchSelect { background-color: transparent; } -.MSearchBoxActive #MSearchField -{ +.MSearchBoxActive #MSearchField { color: #333333; - /* this is inverted */; + /* this is inverted */ } -#MSearchBox .right -{ +#MSearchBox .right { filter: invert(80%); } -#MSearchCloseImg -{ +#MSearchCloseImg { background-color: transparent; } /** Magnifying glass dropdown list **/ -#MSearchSelectWindow -{ +#MSearchSelectWindow { background-color: #333333; border-color: #404040; } -a.SelectItem, a.SelectItem:focus, a.SelectItem:active -{ +a.SelectItem, a.SelectItem:focus, a.SelectItem:active { color: #999; } -a.SelectItem:hover -{ +a.SelectItem:hover { color: #bcbcbc; } /** Query Results dropdown list **/ -#MSearchResultsWindow -{ -/* left: !important; / * from orig 992px; * / dynamically generated value */ +#MSearchResultsWindow { + /* left: !important; / * from orig 992px; * / dynamically generated value */ border-color: #404040; } @@ -187,48 +160,47 @@ a.SelectItem:hover /* #MSearchCloseImg { } */ -.SRPage .SREntry -{ +.SRPage .SREntry { font-size: 80%; } -.SRResult:hover -{ +.SRResult:hover { background-color: #404040; } -.SRSymbol:hover -{ +.SRSymbol:hover { color: #4a69a9; /* from orig #425E97; */; } /***** For Docs *****/ -div.header -{ +div.header { background-color: #333333; border-bottom-color: #001; background-image: none; } -div.directory -{ +div.directory { border-top-color: #404040; border-bottom-color: #404040; } -td.memItemLeft, td.memItemRight, .mdescLeft, .mdescRight, .memdoc, .memTemplParams, .memTemplItemLeft, .memTemplItemRight -{ +td.memItemLeft, +td.memItemRight, +.mdescLeft, +.mdescRight, +.memdoc, +.memTemplParams, +.memTemplItemLeft, +.memTemplItemRight { background-color: #282828; } -.memSeparator -{ +.memSeparator { border-bottom-color: #333333; } -.memtitle -{ +.memtitle { background-color: #333333; background-image: none; border-top-color: #404040; @@ -236,8 +208,7 @@ td.memItemLeft, td.memItemRight, .mdescLeft, .mdescRight, .memdoc, .memTemplPara border-right-color: #404040; } -.memproto, dl.reflist dt -{ +.memproto, dl.reflist dt { /* 2nd for ToDo List */ color: #949b8c; /* #878f7e; */ @@ -249,57 +220,48 @@ td.memItemLeft, td.memItemRight, .mdescLeft, .mdescRight, .memdoc, .memTemplPara border-right-color: #404040; } -.memname -{ +.memname { background-color: #333333; } -a -{ +a { color: #adb8a1; } -a.el, a.el:visited -{ +a.el, a.el:visited { color: #6f8b4c; - /* #6d7c5d; */; + /* #6d7c5d; */; } -.memdoc -{ +.memdoc { background-image: none; } -.memdoc, dl.reflist dd -{ - /* 2nd for ToDo List */ +.memdoc, dl.reflist dd { + /* 2nd for ToDo List */ background-color: #282828; border-bottom-color: #404040; border-left-color: #404040; border-right-color: #404040; } -.paramname -{ +.paramname { color: #8f6262; } -img.formulaInl -{ +img.formulaInl { filter: invert(84%); background-color: #fff; } /* Template box headers */ -.memtemplate -{ +.memtemplate { color: #607fbb; /* from orignial #4665A2; */; } /* Labels - protected, static, virtual */ -span.mlabel -{ +span.mlabel { background-color: #282828; border-color: #333; color: #aaa; @@ -307,153 +269,127 @@ span.mlabel } /* Header */ -h2.groupheader -{ +h2.groupheader { color: #4c6db0; - /* from orig. #354C7B; */ + /* from orig. #354C7B; */ border-bottom-color: #333333; } -.inherit_header img -{ +.inherit_header img { background-color: #333333; } /* To make comments visible */ -span.comment -{ +span.comment { color: #7b7b7b; } /* Even rows of lists */ -.directory tr.even -{ +.directory tr.even { background-color: #303030; } /* Tables */ -table.fieldtable -{ +table.fieldtable { border-color: #404040; } -.fieldtable th -{ +.fieldtable th { color: #aaa; background-color: #333333; border-bottom-color: #404040; background-image: none; } -.fieldtable td.fieldtype, .fieldtable td.fieldname -{ +.fieldtable td.fieldtype, .fieldtable td.fieldname { border-right-color: #404040; border-bottom-color: #404040; } -.fieldtable td.fielddoc -{ +.fieldtable td.fielddoc { border-bottom-color: #404040; } -div.center > img -{ +div.center > img { background-color: #cccccc; filter: invert(100%); } /**** Source Code View ****/ -div.fragment -{ +div.fragment { background-color: #282828; border-color: #333333; } -.navpath li.navelem a -{ +.navpath li.navelem a { color: #d1d1d1; text-shadow: none; } -.navpath li.navelem a:hover -{ +.navpath li.navelem a:hover { color: #f1f1f1; text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); } -span.lineno -{ +span.lineno { background-color: #333333; border-right-color: #333333; color: #666; } -span.line -{ +span.line { background-color: #3f3f3f; } -span.lineno a -{ +span.lineno a { background-color: #333333; } -span.lineno a:hover -{ +span.lineno a:hover { background-color: #444444; } -a.code, a.code:visited, a.line, a.line:visited -{ +a.code, a.code:visited, a.line, a.line:visited { color: #4fa2b3; } -span.keyword -{ +span.keyword { color: #00b300; } -span.keywordtype -{ +span.keywordtype { color: #ac7339; } -span.stringliteral -{ +span.stringliteral { color: #0140ff; } -#powerTip -{ +#powerTip { background-color: #282828; } -#powerTip div -{ +#powerTip div { background-color: #282828; } /**** Navigation ****/ -#nav-tree -{ +#nav-tree { background-color: #282828; background-image: none; } -#nav-tree img -{ +#nav-tree img { background-color: #282828; } -#nav-tree .selected a -{ +#nav-tree .selected a { color: #bcbcbc; } /** Split bar **/ -.ui-resizable-e -{ +.ui-resizable-e { filter: invert(70%); opacity: 0.2; } @@ -462,32 +398,27 @@ span.stringliteral /*** Type 1 e.g. https://dartsim.github.io/api/ ***/ -.tabs, .tabs2, .tabs3 -{ +.tabs, .tabs2, .tabs3 { background-image: none; } -.tablist li -{ +.tablist li { background-image: none; } -.tablist li.current a -{ +.tablist li.current a { color: #aaa; background-image: none; background-color: #444; } -.tablist a -{ +.tablist a { color: #bcbcbc; text-shadow: none; background-image: none; } -.tablist a:hover -{ +.tablist a:hover { color: #bcbcbc; background-color: #444444; background-image: none; @@ -495,20 +426,17 @@ span.stringliteral /*** Type 2 e.g. https://clang.llvm.org/doxygen/ ***/ -.sm-dox -{ +.sm-dox { background-image: none; } -.sm-dox a, .sm-dox a.highlighted -{ +.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 -{ +.sm-dox a:focus, .sm-dox a:active, .sm-dox a:hover { color: #bcbcbc; background-color: #444444; background-image: none; @@ -516,83 +444,69 @@ span.stringliteral /** Pop-Pane **/ -.sm-dox ul -{ +.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 -{ +.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 -{ +.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 -{ +.sm-dox span.scroll-up:hover, .sm-dox span.scroll-down:hover { background-color: #444444; } -.sm-dox a span.sub-arrow -{ +.sm-dox a span.sub-arrow { border-top-color: #bcbcbc; } -.sm-dox a:hover span.sub-arrow -{ +.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 -{ +.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 -{ +.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 -{ +.sm-dox a.highlighted { background-color: #444444; } -.sm-dox ul a.highlighted -{ +.sm-dox ul a.highlighted { background-color: #333333; } /**** Bottom Tab ****/ -.navpath ul -{ +.navpath ul { background-image: none; border-color: #666; } -img.footer -{ +img.footer { background-color: #333333; opacity: 0.1; } /**** Navigation Tab ****/ /* e.g. nlohmann.github.io/json */ -div.navtab -{ +div.navtab { background-color: #333333; } /**** Classes ****/ /*** Class List, Member List ***/ -td.indexkey, td.indexvalue, tr.memlist -{ +td.indexkey, td.indexvalue, tr.memlist { background-color: #333333; } -/* } */ \ No newline at end of file +/* } */ diff --git a/doxygen/intro.md b/luacs-docs/cs/intro.md similarity index 100% rename from doxygen/intro.md rename to luacs-docs/cs/intro.md diff --git a/luacs-docs/cs/scripts/build.ps1 b/luacs-docs/cs/scripts/build.ps1 new file mode 100644 index 000000000..8115ee92b --- /dev/null +++ b/luacs-docs/cs/scripts/build.ps1 @@ -0,0 +1,36 @@ +Import-Module $PSScriptRoot/../../scripts/location.ps1 + +try { + Change-Location $PSScriptRoot/.. + + if ((Get-Command "doxgen" -ErrorAction SilentlyContinue) -eq $null) { + echo "doxygen not found" + exit 1 + } + + Remove-Item -Force -Recurse ./build | Out-Null + New-Item -ItemType Directory ./build | Out-Null + New-Item -ItemType Directory ./build/baro-server | Out-Null + New-Item -ItemType Directory ./build/baro-client | Out-Null + + echo "Building server docs" + try { + Change-Location ./baro-server + doxygen ./Doxyfile + } finally { + Restore-Location + } + + echo "Building client docs" + try { + Change-Location ./baro-client + doxygen ./Doxyfile + } finally { + Restore-Location + } + + echo "Building shared docs" + doxygen ./Doxyfile +} finally { + Restore-Location +} diff --git a/luacs-docs/cs/scripts/build.sh b/luacs-docs/cs/scripts/build.sh new file mode 100755 index 000000000..4e697f227 --- /dev/null +++ b/luacs-docs/cs/scripts/build.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +cd "$DIR/.." + +if ! command -v "doxygen" &> /dev/null; then + echo "doxygen not found" + exit 1 +fi + +rm -rf ./build +mkdir -p ./build +mkdir -p ./build/baro-server +mkdir -p ./build/baro-client + +echo "Building server docs" +( + cd ./baro-server + doxygen ./Doxyfile +) + +echo "Building client docs" +( + cd ./baro-client + doxygen ./Doxyfile +) + +echo "Building shared docs" +doxygen ./Doxyfile diff --git a/luacs-docs/cs/scripts/serve.ps1 b/luacs-docs/cs/scripts/serve.ps1 new file mode 100644 index 000000000..4dcffcfa1 --- /dev/null +++ b/luacs-docs/cs/scripts/serve.ps1 @@ -0,0 +1,18 @@ +Import-Module $PSScriptRoot/../../scripts/location.ps1 + +try { + Change-Location $PSScriptRoot/.. + + if ((Get-Command "python3" -ErrorAction SilentlyContinue) -eq $null) { + echo "python3 not found" + exit 1 + } + + python3 ../scripts/http_server.py ./build ` + --port 8001 ` + --route /:html ` + --route /baro-client:baro-client ` + --route /baro-server:baro-server +} finally { + Restore-Location +} diff --git a/luacs-docs/cs/scripts/serve.sh b/luacs-docs/cs/scripts/serve.sh new file mode 100755 index 000000000..c320059e6 --- /dev/null +++ b/luacs-docs/cs/scripts/serve.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +cd "$DIR/.." + +if ! command -v "python3" &> /dev/null; then + echo "python3 not found" + exit 1 +fi + +python3 ../scripts/http_server.py ./build \ + --port 8001 \ + --route /:html \ + --route /baro-client:baro-client \ + --route /baro-server:baro-server diff --git a/doxygen/searchdata.xml b/luacs-docs/cs/searchdata.xml similarity index 100% rename from doxygen/searchdata.xml rename to luacs-docs/cs/searchdata.xml diff --git a/docs-landing-page/bg.jpg b/luacs-docs/landing-page/bg.jpg similarity index 100% rename from docs-landing-page/bg.jpg rename to luacs-docs/landing-page/bg.jpg diff --git a/docs-landing-page/cs_logo.png b/luacs-docs/landing-page/cs_logo.png similarity index 100% rename from docs-landing-page/cs_logo.png rename to luacs-docs/landing-page/cs_logo.png diff --git a/luacs-docs/landing-page/index.html b/luacs-docs/landing-page/index.html new file mode 100644 index 000000000..ab682ca7e --- /dev/null +++ b/luacs-docs/landing-page/index.html @@ -0,0 +1,25 @@ + + + + + LuaCs For Barotrauma + + + + +
+
+
+ +
+
+
+
+
+
+ +
+
+
+ + diff --git a/luacs-docs/landing-page/landing.css b/luacs-docs/landing-page/landing.css new file mode 100644 index 000000000..7ba88a55c --- /dev/null +++ b/luacs-docs/landing-page/landing.css @@ -0,0 +1,131 @@ +body { + overflow: hidden; + font-size: 100%; + background-color: #777; +} + +.common-docs { + z-index: 1; + text-justify: auto; + position: fixed; + top: 0; + bottom: 0; + transition-property: transform; + transition-duration: 0.5s; + transition-timing-function: ease-in-out; + overflow: hidden; +} +#lua-docs { + left: -10%; + right: 50%; +} +#cs-docs { + right: -10%; + left: 50%; +} + +#cs-docs::before, #lua-docs::before { + content: ""; + background: url(bg.jpg) repeat; + background-size: 80%; + background-blend-mode: luminosity; + filter: blur(2px); + position: absolute; + height: 200%; + width: 200%; +} +#lua-docs::before { + background-color: rgba(49, 49, 135, 1); +} +#cs-docs::before { + background-color: rgba(105, 44, 120, 1); +} + +.common-docs:hover { + z-index: 2; + font-size: 300%; + transform: scale(1.05); +} + +.inner-bg { + position: relative; + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + transition-duration: 0.5s; + transition-timing-function: ease-in-out; +} +.inner-bg:hover { + background-color: rgba(255, 255, 255, 0.35); +} + +.inner-docs { + height: 100%; + width: 100%; + display: flex; + align-items: center; + justify-content: center; + position: relative; + background: radial-gradient(circle, #222, rgba(0, 0, 0, 0)); +} + +@media (min-width: 80em) { + .inner-docs img { + height: 30%; + width: auto; + } + .common-docs { + transform: skewX(-11deg); + } + #cs-docs::before, #lua-docs::before { + transform: skewX(11deg); + } + .common-docs:hover { + transform: skewX(-11deg) scale(1.05); + } + .inner-docs { + transform: skewX(11deg); + } + .inner-docs img { + height: 30%; + width: auto; + } +} +@media (max-width: 80em) { + .common-docs { + transform: skewX(-9deg); + } + #cs-docs::before, #lua-docs::before { + transform: skewX(9deg); + } + .common-docs:hover { + transform: skewX(-9deg) scale(1.05); + } + .inner-docs { + transform: skewX(9deg); + } + .inner-docs img { + height: 30%; + width: auto; + } +} +@media (max-width: 70em) { + .common-docs { + transform: skewX(0deg); + } + #cs-docs::before, #lua-docs::before { + transform: skewX(0deg); + } + .common-docs:hover { + transform: skewX(0deg) scale(1.05); + } + .inner-docs { + transform: skewX(0deg); + } + .inner-docs img { + height: auto; + width: 50%; + } +} diff --git a/docs-landing-page/lua_logo.png b/luacs-docs/landing-page/lua_logo.png similarity index 100% rename from docs-landing-page/lua_logo.png rename to luacs-docs/landing-page/lua_logo.png diff --git a/luacs-docs/lua/.gitignore b/luacs-docs/lua/.gitignore new file mode 100644 index 000000000..efe03a551 --- /dev/null +++ b/luacs-docs/lua/.gitignore @@ -0,0 +1,3 @@ +build +lua_modules +lua/generated diff --git a/docs/baseluadocs/Affliction.lua b/luacs-docs/lua/baseluadocs/Affliction.lua similarity index 100% rename from docs/baseluadocs/Affliction.lua rename to luacs-docs/lua/baseluadocs/Affliction.lua diff --git a/docs/baseluadocs/AfflictionPrefab.lua b/luacs-docs/lua/baseluadocs/AfflictionPrefab.lua similarity index 100% rename from docs/baseluadocs/AfflictionPrefab.lua rename to luacs-docs/lua/baseluadocs/AfflictionPrefab.lua diff --git a/docs/baseluadocs/AnimController.lua b/luacs-docs/lua/baseluadocs/AnimController.lua similarity index 100% rename from docs/baseluadocs/AnimController.lua rename to luacs-docs/lua/baseluadocs/AnimController.lua diff --git a/docs/baseluadocs/Character.lua b/luacs-docs/lua/baseluadocs/Character.lua similarity index 88% rename from docs/baseluadocs/Character.lua rename to luacs-docs/lua/baseluadocs/Character.lua index b20ec5b22..f06a85fd6 100644 --- a/docs/baseluadocs/Character.lua +++ b/luacs-docs/lua/baseluadocs/Character.lua @@ -3,7 +3,7 @@ --[[-- Barotrauma Character class with some additional functions and fields -Barotrauma source code: [Character.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs) +Barotrauma source code: [Character.cs](https://github.com/evilfactory/LuaCsForBarotrauma/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs) ]] -- @code Character -- @pragma nostrip @@ -33,7 +33,7 @@ function Character.Create(characterInfo, position, seed, id, isRemotePlayer, has --- Teleports a character to a position. -- @realm server --- @tparam Vector2 position +-- @tparam Vector2 worldPos -- @usage -- Character.CharacterList[1].TeleportTo(Vector2(0, 0)) -- teleports first created characters to 0, 0 function TeleportTo(worldPos) end @@ -41,4 +41,4 @@ function TeleportTo(worldPos) end --- -- Character.CharacterList, Table containing all characters. -- @realm shared --- @table Character.CharacterList +-- @field Character.CharacterList diff --git a/docs/baseluadocs/CharacterHealth.lua b/luacs-docs/lua/baseluadocs/CharacterHealth.lua similarity index 100% rename from docs/baseluadocs/CharacterHealth.lua rename to luacs-docs/lua/baseluadocs/CharacterHealth.lua diff --git a/docs/baseluadocs/CharacterInfo.lua b/luacs-docs/lua/baseluadocs/CharacterInfo.lua similarity index 67% rename from docs/baseluadocs/CharacterInfo.lua rename to luacs-docs/lua/baseluadocs/CharacterInfo.lua index f0501c011..3391684e3 100644 --- a/docs/baseluadocs/CharacterInfo.lua +++ b/luacs-docs/lua/baseluadocs/CharacterInfo.lua @@ -3,7 +3,7 @@ --[[-- Barotrauma CharacterInfo class with some additional functions and fields -Barotrauma source code: [CharacterInfo.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/CharacterInfo.cs) +Barotrauma source code: [CharacterInfo.cs](https://github.com/evilfactory/LuaCsForBarotrauma/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/CharacterInfo.cs) ]] -- @code CharacterInfo -- @pragma nostrip diff --git a/docs/baseluadocs/CharacterInventory.lua b/luacs-docs/lua/baseluadocs/CharacterInventory.lua similarity index 100% rename from docs/baseluadocs/CharacterInventory.lua rename to luacs-docs/lua/baseluadocs/CharacterInventory.lua diff --git a/docs/baseluadocs/Client.lua b/luacs-docs/lua/baseluadocs/Client.lua similarity index 89% rename from docs/baseluadocs/Client.lua rename to luacs-docs/lua/baseluadocs/Client.lua index 2e53ec794..8b0faa9e6 100644 --- a/docs/baseluadocs/Client.lua +++ b/luacs-docs/lua/baseluadocs/Client.lua @@ -3,7 +3,7 @@ --[[-- Barotrauma Client class with some additional functions and fields -Barotrauma source code: [Client.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Networking/Client.cs) +Barotrauma source code: [Client.cs](https://github.com/evilfactory/LuaCsForBarotrauma/blob/master/Barotrauma/BarotraumaShared/SharedSource/Networking/Client.cs) ]] -- @code Client -- @pragma nostrip diff --git a/docs/baseluadocs/Entity.Spawner.lua b/luacs-docs/lua/baseluadocs/Entity.Spawner.lua similarity index 65% rename from docs/baseluadocs/Entity.Spawner.lua rename to luacs-docs/lua/baseluadocs/Entity.Spawner.lua index 8c789af5a..017c7f2ef 100644 --- a/docs/baseluadocs/Entity.Spawner.lua +++ b/luacs-docs/lua/baseluadocs/Entity.Spawner.lua @@ -3,7 +3,7 @@ --[[-- Barotrauma EntitySpawner class with some additional functions and fields -Barotrauma source code: [EntitySpawner.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Networking/EntitySpawner.cs) +Barotrauma source code: [EntitySpawner.cs](https://github.com/evilfactory/LuaCsForBarotrauma/blob/master/Barotrauma/BarotraumaShared/SharedSource/Networking/EntitySpawner.cs) ]] -- @code Entity.Spawner -- @pragma nostrip diff --git a/docs/baseluadocs/Entity.lua b/luacs-docs/lua/baseluadocs/Entity.lua similarity index 68% rename from docs/baseluadocs/Entity.lua rename to luacs-docs/lua/baseluadocs/Entity.lua index 46f508dce..e035482bb 100644 --- a/docs/baseluadocs/Entity.lua +++ b/luacs-docs/lua/baseluadocs/Entity.lua @@ -3,7 +3,7 @@ --[[-- Barotrauma Entity class with some additional functions and fields -Barotrauma source code: [Entity.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Map/Entity.cs) +Barotrauma source code: [Entity.cs](https://github.com/evilfactory/LuaCsForBarotrauma/blob/master/Barotrauma/BarotraumaShared/SharedSource/Map/Entity.cs) ]] -- @code Entity -- @pragma nostrip \ No newline at end of file diff --git a/docs/baseluadocs/GameScreen.lua b/luacs-docs/lua/baseluadocs/GameScreen.lua similarity index 100% rename from docs/baseluadocs/GameScreen.lua rename to luacs-docs/lua/baseluadocs/GameScreen.lua diff --git a/docs/baseluadocs/GameSession.lua b/luacs-docs/lua/baseluadocs/GameSession.lua similarity index 100% rename from docs/baseluadocs/GameSession.lua rename to luacs-docs/lua/baseluadocs/GameSession.lua diff --git a/docs/baseluadocs/GameSettings.lua b/luacs-docs/lua/baseluadocs/GameSettings.lua similarity index 100% rename from docs/baseluadocs/GameSettings.lua rename to luacs-docs/lua/baseluadocs/GameSettings.lua diff --git a/docs/baseluadocs/Hull.lua b/luacs-docs/lua/baseluadocs/Hull.lua similarity index 100% rename from docs/baseluadocs/Hull.lua rename to luacs-docs/lua/baseluadocs/Hull.lua diff --git a/docs/baseluadocs/Inventory.lua b/luacs-docs/lua/baseluadocs/Inventory.lua similarity index 100% rename from docs/baseluadocs/Inventory.lua rename to luacs-docs/lua/baseluadocs/Inventory.lua diff --git a/docs/baseluadocs/Item.lua b/luacs-docs/lua/baseluadocs/Item.lua similarity index 92% rename from docs/baseluadocs/Item.lua rename to luacs-docs/lua/baseluadocs/Item.lua index 52d0e110f..3fa51730b 100644 --- a/docs/baseluadocs/Item.lua +++ b/luacs-docs/lua/baseluadocs/Item.lua @@ -3,7 +3,7 @@ --[[-- Barotrauma Item class with some additional functions and fields -Barotrauma source code: [Item.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs) +Barotrauma source code: [Item.cs](https://github.com/evilfactory/LuaCsForBarotrauma/blob/master/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs) ]] -- @code Item -- @pragma nostrip diff --git a/docs/baseluadocs/ItemInventory.lua b/luacs-docs/lua/baseluadocs/ItemInventory.lua similarity index 100% rename from docs/baseluadocs/ItemInventory.lua rename to luacs-docs/lua/baseluadocs/ItemInventory.lua diff --git a/docs/baseluadocs/ItemPrefab.lua b/luacs-docs/lua/baseluadocs/ItemPrefab.lua similarity index 90% rename from docs/baseluadocs/ItemPrefab.lua rename to luacs-docs/lua/baseluadocs/ItemPrefab.lua index b4e175dfb..1e2b4aef2 100644 --- a/docs/baseluadocs/ItemPrefab.lua +++ b/luacs-docs/lua/baseluadocs/ItemPrefab.lua @@ -3,7 +3,7 @@ --[[-- Barotrauma ItemPrefab class with some additional functions and fields -Barotrauma source code: [ItemPrefab.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Items/ItemPrefab.cs) +Barotrauma source code: [ItemPrefab.cs](https://github.com/evilfactory/LuaCsForBarotrauma/blob/master/Barotrauma/BarotraumaShared/SharedSource/Items/ItemPrefab.cs) ]] -- @code ItemPrefab -- @pragma nostrip diff --git a/docs/baseluadocs/Job.lua b/luacs-docs/lua/baseluadocs/Job.lua similarity index 67% rename from docs/baseluadocs/Job.lua rename to luacs-docs/lua/baseluadocs/Job.lua index ff7a24d0d..e74948f97 100644 --- a/docs/baseluadocs/Job.lua +++ b/luacs-docs/lua/baseluadocs/Job.lua @@ -3,7 +3,7 @@ --[[-- Barotrauma Job class with some additional functions and fields -Barotrauma source code: [Job.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/Job.cs) +Barotrauma source code: [Job.cs](https://github.com/evilfactory/LuaCsForBarotrauma/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/Job.cs) ]] -- @code Job -- @pragma nostrip diff --git a/docs/baseluadocs/JobPrefab.lua b/luacs-docs/lua/baseluadocs/JobPrefab.lua similarity index 67% rename from docs/baseluadocs/JobPrefab.lua rename to luacs-docs/lua/baseluadocs/JobPrefab.lua index ef0b72b66..792667798 100644 --- a/docs/baseluadocs/JobPrefab.lua +++ b/luacs-docs/lua/baseluadocs/JobPrefab.lua @@ -3,7 +3,7 @@ --[[-- Barotrauma JobPrefab class with some additional functions and fields -Barotrauma source code: [JobPrefab.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/JobPrefab.cs) +Barotrauma source code: [JobPrefab.cs](https://github.com/evilfactory/LuaCsForBarotrauma/blob/master/Barotrauma/BarotraumaShared/SharedSource/Characters/Jobs/JobPrefab.cs) ]] -- @code JobPrefab -- @pragma nostrip diff --git a/docs/baseluadocs/Level.lua b/luacs-docs/lua/baseluadocs/Level.lua similarity index 100% rename from docs/baseluadocs/Level.lua rename to luacs-docs/lua/baseluadocs/Level.lua diff --git a/docs/baseluadocs/NetLobbyScreen.lua b/luacs-docs/lua/baseluadocs/NetLobbyScreen.lua similarity index 100% rename from docs/baseluadocs/NetLobbyScreen.lua rename to luacs-docs/lua/baseluadocs/NetLobbyScreen.lua diff --git a/docs/baseluadocs/ServerSettings.lua b/luacs-docs/lua/baseluadocs/ServerSettings.lua similarity index 100% rename from docs/baseluadocs/ServerSettings.lua rename to luacs-docs/lua/baseluadocs/ServerSettings.lua diff --git a/docs/baseluadocs/Submarine.lua b/luacs-docs/lua/baseluadocs/Submarine.lua similarity index 74% rename from docs/baseluadocs/Submarine.lua rename to luacs-docs/lua/baseluadocs/Submarine.lua index 039c193a6..060e5f62e 100644 --- a/docs/baseluadocs/Submarine.lua +++ b/luacs-docs/lua/baseluadocs/Submarine.lua @@ -3,7 +3,7 @@ --[[-- Barotrauma Submarine class with some additional functions and fields -Barotrauma source code: [Submarine.cs](https://github.com/evilfactory/Barotrauma-lua-attempt/blob/master/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs) +Barotrauma source code: [Submarine.cs](https://github.com/evilfactory/LuaCsForBarotrauma/blob/master/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs) Not all fields and methods will work, this doc was autogenerated. ]] diff --git a/docs/baseluadocs/SubmarineInfo.lua b/luacs-docs/lua/baseluadocs/SubmarineInfo.lua similarity index 100% rename from docs/baseluadocs/SubmarineInfo.lua rename to luacs-docs/lua/baseluadocs/SubmarineInfo.lua diff --git a/docs/baseluadocs/WayPoint.lua b/luacs-docs/lua/baseluadocs/WayPoint.lua similarity index 100% rename from docs/baseluadocs/WayPoint.lua rename to luacs-docs/lua/baseluadocs/WayPoint.lua diff --git a/docs/baseluadocs/World.lua b/luacs-docs/lua/baseluadocs/World.lua similarity index 100% rename from docs/baseluadocs/World.lua rename to luacs-docs/lua/baseluadocs/World.lua diff --git a/config.ld b/luacs-docs/lua/config.ld similarity index 73% rename from config.ld rename to luacs-docs/lua/config.ld index 79cc5cf19..545535ce6 100644 --- a/config.ld +++ b/luacs-docs/lua/config.ld @@ -1,24 +1,26 @@ +-- vim:ft=lua file = { - "docs/lua" + "lua" } -module_file = { +module_file = {} -} - -dir = "docs/html" +dir = "build" project = "LuaForBarotrauma" title = "LuaForBarotrauma Documentation" no_space_before_args = true -style = "docs/css" -template = "docs/templates" +style = "css" +template = "templates" format = "markdown" ignore = true -topics = "docs/manual" +topics = "manual" use_markdown_titles = true -kind_names = {topic = "Manual", module = "Classes"} +kind_names = { + topic = "Manual", + module = "Classes" +} merge = true sort = true sort_modules = true @@ -31,20 +33,21 @@ pretty_urls = true -- avoid showing .html in urls pretty_topic_names = true -- strips extension from manual filenames, this does not check filename collisions custom_tags = { - {"realm", hidden = true}, - {"internal", hidden = true} + {"realm", hidden = true}, + {"deprecated", hidden = true}, + {"internal", hidden = true} } custom_display_name_handler = function(item, default_handler) - if (item.type == "function" and item.module) then - if (item.module.type == "classmod" or item.module.type == "panel") then - return item.module.mod_name .. ":" .. default_handler(item) - elseif (item.module.type == "hooks") then - return item.module.mod_name:upper() .. ":" .. default_handler(item) - end - end + if (item.type == "function" and item.module) then + if (item.module.type == "classmod" or item.module.type == "panel") then + return item.module.mod_name .. ":" .. default_handler(item) + elseif (item.module.type == "hooks") then + return item.module.mod_name:upper() .. ":" .. default_handler(item) + end + end - return default_handler(item) + return default_handler(item) end new_type("code", "Code", true) diff --git a/docs/css/highlight.css b/luacs-docs/lua/css/highlight.css similarity index 99% rename from docs/css/highlight.css rename to luacs-docs/lua/css/highlight.css index 61447dba9..087149f5a 100644 --- a/docs/css/highlight.css +++ b/luacs-docs/lua/css/highlight.css @@ -10,7 +10,7 @@ * @author Zeno Rocha */ - .hljs { +.hljs { display: block; overflow-x: auto; padding: 0.5em; diff --git a/luacs-docs/lua/css/ldoc.css b/luacs-docs/lua/css/ldoc.css new file mode 100644 index 000000000..1f0152b8b --- /dev/null +++ b/luacs-docs/lua/css/ldoc.css @@ -0,0 +1,589 @@ + +:root { + --content-width: 100%; + --sidebar-width: 25%; + + --padding-big: 48px; + --padding-normal: 24px; + --padding-small: 16px; + --padding-tiny: 10px; + + --font-massive: 32px; + --font-huge: 24px; + --font-big: 18px; + --font-normal: 16px; + --font-tiny: 12px; + + --font-style-normal: Segoe UI, Helvetica, Arial, sans-serif; + --font-style-code: Consolas, monospace; + + --color-accent-1: rgb(47, 100, 74); + --color-accent-2: rgb(150, 206, 179); + --color-accent-3: rgb(104, 211, 225); + --color-accent-dark: rgb(33, 33, 33); + --color-white: rgb(255, 255, 255); + --color-offwhite: rgb(200, 200, 200); + --color-white-accent: rgb(203, 190, 209); + --color-black: rgb(0, 0, 0); + --color-lightgrey: rgb(160, 160, 160); + --color-background-light: rgb(245, 245, 245); + --color-background-dark: rgb(30, 30, 30); + --color-background-dark-ish: rgb(33, 36, 37); + --color-outline: rgb(149, 34, 160); + --color-good: #5190ff; +} + +* { + padding: 0; + margin: 0; + box-sizing: border-box; +} + +body { + background-color: var(--color-background-dark); + font-family: var(--font-style-normal); + + display: flex; + flex-direction: column; +} + +a { + color: inherit; + text-decoration: inherit; +} + +h1, h2, h3, h4 { + font-weight: 400; +} + +ul li { + margin-left: var(--padding-small); +} + +/* landing */ +.landing { + background-color: var(--color-accent-1); + color: var(--color-white); + + padding: 128px 0 128px 0; +} + +.landing h1 { + margin: 0; + padding: 0; + border: none; + + font-weight: 100; + font-size: var(--font-massive); + text-align: center; +} + +.wrapper { + padding: var(--padding-small); +} + +details { + user-select: none; +} + +details summary { + outline: none; +} + +code { + font-family: "Source Code Pro", monospace; + font-size: 85%; + white-space: pre; + tab-size: 4; + -moz-tab-size: 4; + padding: 1px 4px; + background-color: #282a36; + outline-style: solid; + outline-color: black; + outline-width: 2px; +} + +pre { + background-color: rgb(0, 0, 0, 1); + margin-top: var(--padding-small); + padding: 2px; + overflow: auto; +} + +pre code { + background-color: transparent; +} + +span.realm { + width: 14px; + height: 14px; + border-radius: 3px; + display: inline-block; + margin-right: 5px; +} + +span.realm.shared { + background: linear-gradient(45deg, #f80 0%, #f80 50%, #08f 51%, #08f 100%); +} + +span.realm.client { + background-color: #f80; +} + +span.realm.server { + background-color: #08f; +} + + +.colorful-label { + color: var(--color-accent-3); +} + +/* wrapper element for sidebar/content */ +main { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: flex-start; + + width: var(--content-width); + margin: auto; +} + +/* sidebar */ +nav { + color: var(--color-offwhite); + background-color: var(--color-background-dark); + + position: fixed; + display: flex; + flex-direction: column; + + width: var(--sidebar-width); + height: 100%; +} + +/* sidebar header */ +nav header { + color: var(--color-white); + background-color: var(--color-accent-1); + + padding: var(--padding-small); +} + +nav header h1 { + font-size: var(--font-huge); + font-weight: 100; + text-align: center; + + margin-bottom: var(--padding-small); +} + +#search { + background-color: var(--color-accent-dark); + color: var(--color-white); + + border: none; + font-size: var(--font-normal); + outline: none; + + width: 100%; + padding: 6px; +} + +#search::placeholder { + color: var(--color-white-accent); +} + +#search::-webkit-search-cancel-button { + display: none; +} + +/* sidebar contents */ +nav section { + padding: var(--padding-small); + overflow: auto; +} + +nav section ul { + list-style-type: none; +} + +nav section::-webkit-scrollbar, +pre::-webkit-scrollbar { + width: 8px; + height: 8px; +} + +nav section::-webkit-scrollbar-track, +pre::-webkit-scrollbar-track { + background: transparent; +} + +nav section::-webkit-scrollbar-thumb { + background-color: var(--color-lightgrey); +} + +pre::-webkit-scrollbar-thumb { + background-color: var(--color-lightgrey); +} + +/* sidebar contents category */ +nav section details.category { + padding-top: var(--padding-tiny); +} + +nav section details.category > ul > li { + margin: 0; + line-height: 1.5; +} + +nav section details.category > ul > li a { + display: inline-block; + width: 90%; +} + +nav section details.category:first-of-type { + padding-top: calc(var(--padding-tiny) * -1); +} + +nav section details.category summary::-webkit-details-marker { + opacity: 0.5; + cursor: pointer; +} + +nav section details.category summary h2 { + color: var(--color-accent-2); + + font-size: var(--font-big); + letter-spacing: 2px; + text-transform: uppercase; + cursor: pointer; + + padding-bottom: var(--padding-tiny); +} + +/* content */ +article { + background-color: var(--color-background-dark-ish); + color: white; + width: calc(100% - var(--sidebar-width)); + min-height: 100vh; + margin-left: var(--sidebar-width); +} + +article .wrapper > *:first-child { + margin-top: 0; +} + +/* header */ +article header { + color: rgb(255, 255, 255); + background-color: var(--color-accent-1); + padding: var(--padding-tiny); +} + +article header h1 { + border-bottom: 1px solid rgba(255, 255, 255, 0.25); + padding-bottom: 8px; + font-family: var(--font-style-code); + margin: 0; +} + +article header h2 { + padding-top: var(--padding-tiny); + margin: 0; + font-size: var(--font-normal); + font-weight: normal; +} + +article header.module a { + color: white !important; + text-decoration: underline; +} + +article header.section { + color: rgb(255, 255, 255); + background-color: var(--color-accent-1); + padding: var(--padding-tiny); + margin-top: var(--padding-small); + margin-bottom: 0; +} + +article header.section h1 { + padding: 0; + border: 0; + font-size: var(--font-big); + font-weight: 100; + letter-spacing: 2px; + text-transform: uppercase; +} + +article header.section h2 { + padding: 0; + margin: 0; + font-size: var(--font-normal); + font-weight: normal; +} + +article header.section .section-separator { + margin: var(--padding-tiny) 0; + border-bottom: 1px solid rgba(255, 255, 255, 0.25); +} + +details.category > summary { + list-style: none; +} + +details.category > summary::-webkit-details-marker { + display: none; +} + +article h1 { + font-size: 28px; + font-weight: 600; + border-bottom: 1px solid rgba(0, 0, 0, 0.25); + margin-top: 24px; + margin-bottom: 16px; + padding-bottom: 8px; +} + +article h2 { + font-size: 20px; + font-weight: 600; + margin-top: calc(var(--padding-tiny) + 2px); +} + +article h3 { + color: var(--color-accent-3); + margin-top: calc(var(--padding-tiny) + 2px); + text-transform: uppercase; +} + +article p { + line-height: calc(var(--font-normal) + 4px); +} + +article p + p, +article h2 + p, +article pre + p { + margin-top: var(--padding-small); +} + +article h3 + p, +article h4 + p { + margin-top: var(--padding-tiny); +} + +article p a, +article ul li a, +article h1 a, +article h2 a { + color: var(--color-good); + font-weight: 600; +} + +article h1.title { + color: rgb(255, 255, 255); + background-color: var(--color-accent-1); + margin-top: var(--padding-small); + margin-bottom: 0; + padding: var(--padding-tiny); + + font-size: var(--font-big); + font-weight: 100; + letter-spacing: 2px; + text-transform: uppercase; +} + +a.reference { + color: var(--color-good); + float: right; + margin-top: 8px; + padding-left: 8px; + font-size: 14px; + font-weight: 600; +} + +.notice { + --color-notice-background: var(--color-accent-1); + --color-notice-text: var(--color-notice-background); + + margin-top: var(--padding-tiny); + border: 2px solid var(--color-notice-background); +} + +.notice.error { + --color-notice-background: rgb(194, 52, 130); +} + +.notice.warning { + --color-notice-background: rgb(128, 79, 28); + --color-notice-text: rgb(220, 160, 96); +} + +.notice .title { + color: var(--color-white); + background-color: var(--color-notice-background); + + padding: var(--padding-tiny); + font-size: var(--font-normal); + + text-transform: uppercase; + letter-spacing: 2px; +} + +.notice .body { + color: var(--color-notice-text); + + margin: 0 !important; + padding: var(--padding-tiny); +} + +/* function/table */ +.method { + display: flex; + flex-flow: column; + padding: var(--padding-tiny); + margin-top: var(--padding-small); +} + +.method header { + color: white; + background-color: inherit; + padding: 0; + order: -1; +} + +.method header .anchor { + color: inherit; + text-decoration: inherit; +} + +.method:target { + background-color: var(--color-background-dark); + + outline: solid; + outline-width: 1px; + outline-color: var(--color-accent-1); +} + +.method header:target { + background-color: var(--color-accent-1); +} + +.method header h1 { + font-family: "Source Code Pro", monospace; + padding-bottom: var(--padding-tiny); + border-bottom: 1px solid var(--color-accent-1); + font-size: 20px; +} + +.method header p.description:first-of-type { + margin-top: var(--padding-tiny); +} + +.method h3 { + color: var(--color-accent-3); + font-size: var(--font-normal); + letter-spacing: 2px; + text-transform: uppercase; +} + +.method pre { + margin-top: var(--padding-tiny); +} + +@media only screen and (max-width: 1100px) { + main nav { + position: inherit; + } + + main article { + margin-left: 0; + } +} + +.method ul { + margin-top: var(--padding-tiny); + background-color: inherit; +} + +.method ul li { + list-style: none; + margin: 4px 0 0 var(--padding-normal); +} + +.method ul li:first-of-type { + margin-top: 0; +} + +.method ul li p { + margin: 4px 0 0 var(--padding-normal); +} + +.method ul li pre { + margin: 4px 0 0 var(--padding-normal); +} + +.method ul li a { + color: rgb(178, 118, 204); + font-weight: 600; +} + +.tag { + display: inline-block; + color: rgb(255, 255, 255) !important; + + padding: 4px; + font-size: 14px; + font-family: "Source Code Pro", monospace; +} + +.tag.parameter { + background-color: rgb(115, 53, 142); +} + +.tag.readonly { + background-color: rgb(47, 100, 74); +} + +.tag.type { + background-color: rgb(31, 141, 155); +} + +.tag.type a { + color: inherit; + font-weight: 300; + text-decoration: underline; +} + +.tag.default { + background-color: rgb(193, 114, 11); +} + +.tag.type a { + padding: 0; +} + +.or { + color: rgba(115, 53, 142, 0.5); + background-color: inherit; + + width: calc(100% - 32px); + height: 8px; + margin: 0 0 8px 32px; + + text-align: center; + font-weight: 600; + border-bottom: 1px solid rgba(115, 53, 142, 0.5); +} + +.or span { + background-color: inherit; + padding: 0 8px 0 8px; +} + +.strikethrough { + text-decoration: line-through; +} diff --git a/luacs-docs/lua/js/app.js b/luacs-docs/lua/js/app.js new file mode 100644 index 000000000..d5941fac8 --- /dev/null +++ b/luacs-docs/lua/js/app.js @@ -0,0 +1,138 @@ +const skippedCategories = ["manual"]; + +class Node { + constructor(name, element, expandable, noAutoCollapse, children = []) { + this.name = name; + this.element = element; + this.expandable = expandable; + this.noAutoCollapse = noAutoCollapse; + this.children = children; + } + + AddChild(name, element, expandable, noAutoCollapse, children) { + let newNode = new Node(name, element, expandable, noAutoCollapse, children); + this.children.push(newNode); + + return newNode; + } +} + +class SearchManager { + constructor(input, contents) { + this.input = input; + this.input.addEventListener("input", event => { + this.OnInputUpdated(this.input.value.toLowerCase().replace(/:/g, ".")); + }); + + // setup search tree + this.tree = new Node("", document.createElement("null"), true, true); + this.entries = {}; + + const categoryElements = contents.querySelectorAll(".category"); + + // iterate each kind (hooks/libraries/classes/etc) + for (const category of categoryElements) { + const nameElement = category.querySelector(":scope > summary > h2"); + + if (!nameElement) { + continue; + } + + const categoryName = nameElement.textContent.trim().toLowerCase(); + + if (skippedCategories.includes(categoryName)) { + continue; + } + + let categoryNode = this.tree.AddChild(categoryName, category, true, true); + const sectionElements = category.querySelectorAll(":scope > ul > li"); + + for (const section of sectionElements) { + const entryElements = section.querySelectorAll(":scope > details > ul > li > a"); + const sectionName = section.querySelector(":scope > details > summary > a") + .textContent + .trim() + .toLowerCase(); + + let sectionNode = categoryNode.AddChild(sectionName, section.querySelector(":scope > details"), true); + + for (let i = 0; i < entryElements.length; i++) { + const entryElement = entryElements[i]; + const entryName = entryElement.textContent.trim().toLowerCase(); + + sectionNode.AddChild(sectionName + "." + entryName, entryElement.parentElement); + } + } + } + } + + ResetVisibility(current) { + current.element.style.display = ""; + + if (current.noAutoCollapse) { + current.element.open = true; + } + else if (current.expandable) { + current.element.open = false; + } + + for (let node of current.children) { + this.ResetVisibility(node); + } + } + + Search(input, current) { + let matched = false; + + if (current.name.indexOf(input) != -1) { + matched = true; + } + + for (let node of current.children) { + let childMatched = this.Search(input, node); + matched = matched || childMatched; + } + + if (matched) { + current.element.style.display = ""; + + if (current.expandable) { + current.element.open = true; + } + } else { + current.element.style.display = "none"; + + if (current.expandable) { + current.element.open = false; + } + } + + return matched; + } + + OnInputUpdated(input) { + if (input.length <= 1) { + this.ResetVisibility(this.tree); + return; + } + + this.Search(input, this.tree); + } +} + +window.onload = function() { + const openDetails = document.querySelector(".category > ul > li > details[open]"); + + if (openDetails) { + openDetails.scrollIntoView(); + } +} + +document.addEventListener("DOMContentLoaded", function() { + const searchInput = document.getElementById("search"); + const contents = document.querySelector("body > main > nav > section"); + + if (searchInput && contents) { + new SearchManager(searchInput, contents); + } +}); diff --git a/docs/js/highlight.min.js b/luacs-docs/lua/js/highlight.min.js similarity index 100% rename from docs/js/highlight.min.js rename to luacs-docs/lua/js/highlight.min.js diff --git a/luacs-docs/lua/libs/ldoc b/luacs-docs/lua/libs/ldoc new file mode 160000 index 000000000..a98391f04 --- /dev/null +++ b/luacs-docs/lua/libs/ldoc @@ -0,0 +1 @@ +Subproject commit a98391f04ac2083a8fd6ba20bc1a0794de85bec2 diff --git a/docs/lua/File.lua b/luacs-docs/lua/lua/File.lua similarity index 100% rename from docs/lua/File.lua rename to luacs-docs/lua/lua/File.lua diff --git a/docs/lua/Game.lua b/luacs-docs/lua/lua/Game.lua similarity index 99% rename from docs/lua/Game.lua rename to luacs-docs/lua/lua/Game.lua index c75257a0a..686a80687 100644 --- a/docs/lua/Game.lua +++ b/luacs-docs/lua/lua/Game.lua @@ -25,7 +25,7 @@ Game.ServerSettings = true Game.Settings = true --- ChatBox. --- @realm ChatBox +-- @realm server Game.ChatBox = true --- Send chat message to every client. diff --git a/docs/lua/Hooks.lua b/luacs-docs/lua/lua/Hooks.lua similarity index 64% rename from docs/lua/Hooks.lua rename to luacs-docs/lua/lua/Hooks.lua index 27d369d8c..9c6f16e4e 100644 --- a/docs/lua/Hooks.lua +++ b/luacs-docs/lua/lua/Hooks.lua @@ -1,7 +1,7 @@ -- luacheck: ignore 111 --[[-- -Hooks are basically functions that get called when events happen in-game, like chat messages. +The Hook API allow you to listen to game events and modify the behavior/logic of the game. ]] -- @code Hook -- @pragma nostrip @@ -10,8 +10,8 @@ local Hook = {} --- Adds a hook. --- @tparam string eventname event name --- @tparam string hookname hook name +-- @tparam string eventName event name +-- @tparam string hookName hook name -- @tparam function func callback -- @realm shared -- @usage @@ -21,15 +21,15 @@ local Hook = {} function Hook.Add(eventName, hookName, func) end --- Removes a hook. --- @tparam string eventname event name --- @tparam string hookname hook name +-- @tparam string eventName event name +-- @tparam string hookName hook name -- @realm shared -- @usage -- Hook.Remove("character.death", "characterDeathExample") function Hook.Remove(eventName, hookName) end --- Calls a hook. --- @tparam string eventname event name +-- @tparam string eventName event name -- @tparam table parameters parameters to be passed in -- @realm shared -- @usage @@ -43,12 +43,91 @@ function Hook.Call(eventName, parameters) end -- @tparam string methodName -- @tparam function callback -- @realm shared +-- @deprecated Use `Hook.Patch` instead. -- @usage -- Hook.HookMethod("Barotrauma.CharacterInfo", "IncreaseSkillLevel", function (instance, ptable) -- print(string.format("%s gained % xp", instance.Character.Name, ptable.increase)) -- end, Hook.HookMethodType.After) function Hook.HookMethod(className, methodName, callback) end +--- Attaches a prefix/postfix to a method. Used for modifying the behavior of methods. +-- @tparam[opt] string identifier a string that identifies this patch (unique per patched method) +-- @tparam string className the fully-qualified name of the type to patch +-- @tparam string methodName the name of the method to patch +-- @tparam[opt] {string} parameterTypes the type of the parameters -- used for disambiguating between overloads +-- @tparam function callback function that is called before/after the patched method executes (see hookType parameter) +-- @tparam[opt=Hook.HookMethodType.Before] Hook.HookMethodType hookType determines whether this patch is to be called before or after the original method executes. `Hook.HookMethodType.Before` is a prefix and `Hook.HookMethodType.After` is a postfix. +-- @treturn string returns the identifier. If no identifier is supplied, a randomly generated one is returned instead. +-- @see ParameterTable +-- @realm shared +-- @usage +-- -- Postfix example: do some logging whenever CharacterInfo.IncreaseSkillLevel is called +-- Hook.Patch("Barotrauma.CharacterInfo", "IncreaseSkillLevel", function(instance, ptable) +-- print(string.format("%s gained % xp", instance.Character.Name, ptable["increase"])) +-- end, Hook.HookMethodType.After) +-- +-- -- More advanced example +-- Hook.Patch( +-- "Barotrauma.Character", +-- "CanInteractWith", +-- { +-- "Barotrauma.Item", +-- -- ref/out parameters are supported +-- "out System.Single", +-- "System.Boolean" +-- }, +-- function(instance, ptable) +-- -- This prevents the original method from executing, so we're +-- -- effectively replacing the method entirely. +-- ptable.PreventExecution = true +-- -- Modify the `out System.Single` parameter +-- ptable["distanceToItem"] = Single(50) +-- -- This changes the return value to "null" +-- return nil +-- end, Hook.HookMethodType.Before) +function Hook.Patch(identifier, className, methodName, parameterTypes, callback, hookType) end + +--- Removes a patch from a method. +-- @tparam string identifier the identifier of the patch to remove +-- @tparam string className the fully-qualified name of the type to unpatch +-- @tparam string methodName the name of the method to unpatch +-- @tparam[opt] {string} parameterTypes the type of the parameters -- used for disambiguating between overloads +-- @tparam Hook.HookMethodType hookType the patch type +-- @treturn boolean returns true if patch was successfully removed, otherwise false +-- @realm shared +-- @usage +-- -- Unpatch a method using a known identifier +-- Hook.Patch("mySuperCoolPatch", "Barotrauma.Character", "IsInteractable", function(instance, ptable) +-- -- ... +-- end, Hook.HookMethodType.After) +-- local success = Hook.RemovePatch("mySuperCoolPatch", "Barotrauma.Character", "IsInteractable", Hook.HookMethodType.After) +-- +-- -- Unpatch a method using a randomly generated identifier +-- local patchId = Hook.Patch("Barotrauma.Character", "IsInteractable", function(instance, ptable) +-- -- ... +-- end, Hook.HookMethodType.After) +-- local success = Hook.RemovePatch(patchId, "Barotrauma.Character", "IsInteractable", Hook.HookMethodType.After) +function Hook.RemovePatch(identifier, className, methodName, parameterTypes, hookType) end + +--- A table of the parameters that a C# method was called with. +-- +-- This is used in the `Hook.Patch` callback. +-- +-- In order to access or modify parameters, you have to use the array accessor syntax, e.g. `ptable["myParam"]` +-- @field PreventExecution if set to `true`, the original method and remaining postfix/prefixes will be skipped +-- @field ReturnValue the return value of the C# method +-- @field[readonly] OriginalParameters the parameters passed to the C# method, before any modifications by the patch(es) +-- @field[readonly] OriginalReturnValue the return value of the C# method, before any modifications by the patch(es) +-- @realm shared +-- @table ParameterTable + +--- Hooks +-- @summary +-- Hooks are functions that get called when events happen in-game, e.g. chat messages. +-- +-- These can be used with `Hook.Add` and `Hook.Call`. +-- @section hook + --- Game's fixed update rate, gets called normally 60 times a second. -- @realm shared function think() end @@ -247,4 +326,4 @@ function human.CPRSuccess(animController) end --- Called after the CPR skill check fails. -- @realm shared -function human.CPRFailed(animController) end \ No newline at end of file +function human.CPRFailed(animController) end diff --git a/docs/lua/Networking.lua b/luacs-docs/lua/lua/Networking.lua similarity index 100% rename from docs/lua/Networking.lua rename to luacs-docs/lua/lua/Networking.lua diff --git a/docs/lua/Signal.lua b/luacs-docs/lua/lua/Signal.lua similarity index 100% rename from docs/lua/Signal.lua rename to luacs-docs/lua/lua/Signal.lua diff --git a/docs/lua/Steam.lua b/luacs-docs/lua/lua/Steam.lua similarity index 92% rename from docs/lua/Steam.lua rename to luacs-docs/lua/lua/Steam.lua index 7de27caf2..e2f729b4d 100644 --- a/docs/lua/Steam.lua +++ b/luacs-docs/lua/lua/Steam.lua @@ -10,7 +10,7 @@ local Steam = {} --- Downloads an item from workshop and places it in a folder. --- @tparam string itemID +-- @tparam string id -- @tparam string destinationFolder -- @tparam function callback -- @realm shared @@ -23,13 +23,13 @@ local Steam = {} function Steam.DownloadWorkshopItem(id, destinationFolder, callback) end --- Gets information about a workshop item. --- @tparam string itemID +-- @tparam string id -- @tparam function callback -- @realm shared function Steam.GetWorkshopItem(id, callback) end --- Callback is called with the list of all workshop items inside the specified collection. --- @tparam string itemID +-- @tparam string id -- @tparam function callback -- @realm shared function Steam.GetWorkshopCollection(id, callback) end diff --git a/docs/lua/Timer.lua b/luacs-docs/lua/lua/Timer.lua similarity index 100% rename from docs/lua/Timer.lua rename to luacs-docs/lua/lua/Timer.lua diff --git a/docs/lua/Vectors.lua b/luacs-docs/lua/lua/Vectors.lua similarity index 100% rename from docs/lua/Vectors.lua rename to luacs-docs/lua/lua/Vectors.lua diff --git a/docs/lua/enums/CauseOfDeathType.lua b/luacs-docs/lua/lua/enums/CauseOfDeathType.lua similarity index 100% rename from docs/lua/enums/CauseOfDeathType.lua rename to luacs-docs/lua/lua/enums/CauseOfDeathType.lua diff --git a/docs/lua/enums/ChatMessageType.lua b/luacs-docs/lua/lua/enums/ChatMessageType.lua similarity index 100% rename from docs/lua/enums/ChatMessageType.lua rename to luacs-docs/lua/lua/enums/ChatMessageType.lua diff --git a/docs/lua/enums/ClientPermissions.lua b/luacs-docs/lua/lua/enums/ClientPermissions.lua similarity index 100% rename from docs/lua/enums/ClientPermissions.lua rename to luacs-docs/lua/lua/enums/ClientPermissions.lua diff --git a/docs/lua/enums/DisconnectReason.lua b/luacs-docs/lua/lua/enums/DisconnectReason.lua similarity index 100% rename from docs/lua/enums/DisconnectReason.lua rename to luacs-docs/lua/lua/enums/DisconnectReason.lua diff --git a/docs/lua/enums/Hook.HookMethodType.lua b/luacs-docs/lua/lua/enums/Hook.HookMethodType.lua similarity index 100% rename from docs/lua/enums/Hook.HookMethodType.lua rename to luacs-docs/lua/lua/enums/Hook.HookMethodType.lua diff --git a/docs/lua/enums/InvSlotType.lua b/luacs-docs/lua/lua/enums/InvSlotType.lua similarity index 100% rename from docs/lua/enums/InvSlotType.lua rename to luacs-docs/lua/lua/enums/InvSlotType.lua diff --git a/docs/lua/enums/LimbType.lua b/luacs-docs/lua/lua/enums/LimbType.lua similarity index 100% rename from docs/lua/enums/LimbType.lua rename to luacs-docs/lua/lua/enums/LimbType.lua diff --git a/docs/lua/enums/NetEntityEvent.Type.lua b/luacs-docs/lua/lua/enums/NetEntityEvent.Type.lua similarity index 100% rename from docs/lua/enums/NetEntityEvent.Type.lua rename to luacs-docs/lua/lua/enums/NetEntityEvent.Type.lua diff --git a/docs/lua/enums/RandSync.lua b/luacs-docs/lua/lua/enums/RandSync.lua similarity index 100% rename from docs/lua/enums/RandSync.lua rename to luacs-docs/lua/lua/enums/RandSync.lua diff --git a/docs/lua/enums/ServerLogMessageType.lua b/luacs-docs/lua/lua/enums/ServerLogMessageType.lua similarity index 100% rename from docs/lua/enums/ServerLogMessageType.lua rename to luacs-docs/lua/lua/enums/ServerLogMessageType.lua diff --git a/docs/lua/enums/SpawnType.lua b/luacs-docs/lua/lua/enums/SpawnType.lua similarity index 100% rename from docs/lua/enums/SpawnType.lua rename to luacs-docs/lua/lua/enums/SpawnType.lua diff --git a/docs/manual/common-questions.md b/luacs-docs/lua/manual/common-questions.md similarity index 100% rename from docs/manual/common-questions.md rename to luacs-docs/lua/manual/common-questions.md diff --git a/docs/manual/getting-started.md b/luacs-docs/lua/manual/getting-started.md similarity index 100% rename from docs/manual/getting-started.md rename to luacs-docs/lua/manual/getting-started.md diff --git a/luacs-docs/lua/manual/how-to-use-hooks.md b/luacs-docs/lua/manual/how-to-use-hooks.md new file mode 100644 index 000000000..b8d871a9f --- /dev/null +++ b/luacs-docs/lua/manual/how-to-use-hooks.md @@ -0,0 +1,84 @@ +# How to use hooks + +Hooks are basically functions that get called when events happen in-game, like chat messages. They can be triggered either by Lua itself or the game code. + +## Adding hooks + +Hooks can be added like this: + +``` +Hook.Add("chatMessage", "test", function(message, client) + print(client.Name .. " has sent " .. message) +end) +``` + +The event name (first argument), is case-insensitive, so you can call it chatMessage, cHaTmEsSaGe, chatmessage, etc. + +## Calling hooks + +You can also call hooks with the following code: + +``` +Hook.Call("myCustomEvent", {"some", "arguments", 123}) +``` + +## XML Status Effect Hooks + +With Lua, a new XML tags is added, it can be used to call Lua hooks inside status effects: + +``` + + + +``` + +``` +Hook.Add("doSomething", "something", function(effect, deltaTime, item, targets, worldPosition) + print(effect, ' ', item) +end) +``` + +## Patching + +Patching allows you to hook into existing methods in the game code. +Be aware that it can be a little unstable depending on the method that you are patching. + +If your lua function returns **any** value (including `nil`), it will replace +the return value of the original method. + +### Postfix + +Postfixes are functions that get called after the original method executes. + +``` +Hook.Patch("Barotrauma.CharacterInfo", "IncreaseSkillLevel", function(instance, ptable) + print(string.format("%s gained % xp", instance.Character.Name, ptable["increase"])) +end, Hook.HookMethodType.After) +``` + +### Prefix + +Prefixes are functions that get called before the original method executes. +For more advanced use cases, they can also be used to modify the incoming +parameters or prevent the original method from executing. + +``` +Hook.Patch( + "Barotrauma.Character", + "CanInteractWith", + { + "Barotrauma.Item", + -- ref/out parameters are supported + "out System.Single", + "System.Boolean" + }, + function(instance, ptable) + -- This prevents the original method from executing, so we're + -- effectively replacing the method entirely. + ptable.PreventExecution = true + -- Modify the `out System.Single` parameter + ptable["distanceToItem"] = Single(50) + -- This changes the return value to "null" + return nil + end, Hook.HookMethodType.Before) +``` diff --git a/docs/manual/installing-lua-for-barotrauma-manually.md b/luacs-docs/lua/manual/installing-lua-for-barotrauma-manually.md similarity index 99% rename from docs/manual/installing-lua-for-barotrauma-manually.md rename to luacs-docs/lua/manual/installing-lua-for-barotrauma-manually.md index 48cc30bc3..b63132e79 100644 --- a/docs/manual/installing-lua-for-barotrauma-manually.md +++ b/luacs-docs/lua/manual/installing-lua-for-barotrauma-manually.md @@ -13,6 +13,7 @@ - **DedicatedServer.dll** - **DedicatedServer.pdb** - **0Harmony.dll** +- **Sigil.dll** - **MoonSharp.Interpreter.dll** - **MonoMod.Common.dll** - **Mono.Cecil.dll** diff --git a/docs/manual/lua-examples.md b/luacs-docs/lua/manual/lua-examples.md similarity index 100% rename from docs/manual/lua-examples.md rename to luacs-docs/lua/manual/lua-examples.md diff --git a/luacs-docs/lua/scripts/LuaDocsGenerator/LuaDocsGenerator.csproj b/luacs-docs/lua/scripts/LuaDocsGenerator/LuaDocsGenerator.csproj new file mode 100644 index 000000000..5b397e13c --- /dev/null +++ b/luacs-docs/lua/scripts/LuaDocsGenerator/LuaDocsGenerator.csproj @@ -0,0 +1,13 @@ + + + Exe + net6.0 + enable + enable + + + + + + + diff --git a/luacs-docs/lua/scripts/LuaDocsGenerator/LuaDocsGenerator.sln b/luacs-docs/lua/scripts/LuaDocsGenerator/LuaDocsGenerator.sln new file mode 100644 index 000000000..30c0eed55 --- /dev/null +++ b/luacs-docs/lua/scripts/LuaDocsGenerator/LuaDocsGenerator.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30114.105 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LuaDocsGenerator", "LuaDocsGenerator.csproj", "{F1961973-E69E-41A7-BE13-4F931890BC70}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LinuxClient", "..\..\..\..\Barotrauma\BarotraumaClient\LinuxClient.csproj", "{426071C4-6668-4CF9-A44C-5FBEB72C469B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Farseer.NetStandard", "..\..\..\..\Libraries\Farseer Physics Engine 3.5\Farseer.NetStandard.csproj", "{F8F85D52-11B5-4177-914C-9AC75345D089}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F1961973-E69E-41A7-BE13-4F931890BC70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1961973-E69E-41A7-BE13-4F931890BC70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1961973-E69E-41A7-BE13-4F931890BC70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1961973-E69E-41A7-BE13-4F931890BC70}.Release|Any CPU.Build.0 = Release|Any CPU + {426071C4-6668-4CF9-A44C-5FBEB72C469B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {426071C4-6668-4CF9-A44C-5FBEB72C469B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {426071C4-6668-4CF9-A44C-5FBEB72C469B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {426071C4-6668-4CF9-A44C-5FBEB72C469B}.Release|Any CPU.Build.0 = Release|Any CPU + {F8F85D52-11B5-4177-914C-9AC75345D089}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8F85D52-11B5-4177-914C-9AC75345D089}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8F85D52-11B5-4177-914C-9AC75345D089}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8F85D52-11B5-4177-914C-9AC75345D089}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/luacs-docs/lua/scripts/LuaDocsGenerator/Program.cs b/luacs-docs/lua/scripts/LuaDocsGenerator/Program.cs new file mode 100644 index 000000000..0756aa954 --- /dev/null +++ b/luacs-docs/lua/scripts/LuaDocsGenerator/Program.cs @@ -0,0 +1,373 @@ +using System.Diagnostics; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using System.Text.RegularExpressions; +using Barotrauma; +using Barotrauma.Networking; + +string NormalizeGenericTypeName(string s) { + var idx = s.LastIndexOf('`'); + + if (idx != -1) { + return s[..idx]; + } + + return s; +} + +string TypeToString(Type type, bool useLuaTypes = true) { + // Return "T" for unresolved type params + if (type.IsGenericParameter) { + return type.Name; + } + + var genericType = type.IsGenericType + ? type.GetGenericTypeDefinition() + : null; + + if (type == typeof(bool)) { + return "bool"; + } + + if (type == typeof(string)) { + return "string"; + } + + if (useLuaTypes) { + if (type == typeof(sbyte) + || type == typeof(byte) + || type == typeof(short) + || type == typeof(ushort) + || type == typeof(int) + || type == typeof(uint) + || type == typeof(long) + || type == typeof(ulong) + || type == typeof(float) + || type == typeof(double)) { + return "number"; + } + + if (genericType == typeof(List<>) + || genericType == typeof(Dictionary<,>)) { + return "table"; + } + + if (genericType == typeof(Action<,>) + || genericType == typeof(Func<,>)) { + return "function"; + } + } + + var nsToRemove = new[] { + "Barotrauma", + "System", + "System.Collections", + "System.Collections.Generic", + }; + + string Namespaced(string typeName) { + if (type.Namespace == null) { + return typeName; + } + + // Full namespace match + if (nsToRemove.Contains(type.Namespace)) { + return typeName; + } + + // Partial namespace match + foreach (var ns in nsToRemove) { + if (ns == type.Namespace) { + return typeName; + } + + if (type.Namespace.StartsWith(ns + ".")) { + var shortNs = type.Namespace.Remove(0, ns.Length + 1); + return $"{shortNs}.{typeName}"; + } + } + + return $"{type.Namespace}.{typeName}"; + } + + string Impl(string? ns) { + if (type.IsGenericType) { + var genericTypeDef = type.GetGenericTypeDefinition(); + var genericTypeName = NormalizeGenericTypeName(genericTypeDef.Name); + + var genericArgs = type.GetGenericArguments(); + + // Use the `T?` notation instead of Nullable + if (genericTypeDef == typeof(Nullable<>)) { + // ldoc supports the "?string" notation, which expands to "?|nil|string" + if (useLuaTypes) { + return Namespaced("?" + TypeToString(genericArgs[0], useLuaTypes: false)); + } else { + return Namespaced(TypeToString(genericArgs[0], useLuaTypes: false) + "?"); + } + } + + var sb = new StringBuilder(); + sb.Append(genericTypeName); + sb.Append("<"); + foreach (var genericArgType in genericArgs) { + sb.Append(TypeToString(genericArgType, useLuaTypes: false)); + sb.Append(","); + } + // Remove the last separator + sb.Length--; + sb.Append(">"); + + return Namespaced(sb.ToString()); + } + + return Namespaced(type.Name); + } + + return Impl(type.Namespace); +} + +static (bool Success, string Output, string Error) TryRunGitCommand(string args) { + static string? GetGitBinary() { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { + return Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process) + ?.Split(';') + .Select(x => Path.Join(x, "git.exe")) + .FirstOrDefault(File.Exists); + } else { + return Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process) + ?.Split(':') + .Select(x => Path.Join(x, "git")) + .FirstOrDefault(File.Exists); + } + } + + var gitBinary = GetGitBinary(); + if (gitBinary == null) { + throw new InvalidOperationException("Failed to find git binary in PATH"); + } + + using var process = Process.Start(new ProcessStartInfo(gitBinary, args) { + WindowStyle = ProcessWindowStyle.Hidden, + CreateNoWindow = true, + UseShellExecute = false, + RedirectStandardInput = true, + RedirectStandardError = true, + RedirectStandardOutput = true, + }); + + if (process == null) + throw new InvalidOperationException($"Failed to run git command: {args}"); + + process.Start(); + + var stdOut = process.StandardOutput.ReadToEndAsync(); + var stdErr = process.StandardError.ReadToEndAsync(); + Task.WhenAll(stdOut, stdErr).GetAwaiter().GetResult(); + process.WaitForExit(); + + return (process.ExitCode == 0, stdOut.Result.TrimEnd('\r', '\n'), stdErr.Result); +} + +var gitDir = (new Func(() => { + var (success, gitDir, error) = TryRunGitCommand("rev-parse --show-toplevel"); + if (!success) { + throw new InvalidDataException($"Failed to determine the root of the git repo: {error}"); + } + + return gitDir; +}))(); + +void GenerateDocsImpl(Type type, string baseFile, string outFile, string? categoryName = null) { + categoryName ??= type.Name; + var sb = new StringBuilder(); + + Console.WriteLine($"Generating docs for {type}"); + + string baseLuaText; + try { + baseLuaText = File.ReadAllText(baseFile); + } catch (FileNotFoundException) { + baseLuaText = @$"-- luacheck: ignore 111 + +--[[-- +{type.FullName} +]] +-- @code {categoryName} +-- @pragma nostrip +local {type.Name} = {{}}".ReplaceLineEndings("\n"); + + File.WriteAllText(baseFile, baseLuaText); + } + + var removeTagPattern = new Regex("^-- @remove (.*)$", RegexOptions.Multiline); + var removed = new HashSet(); + var matches = removeTagPattern.Matches(baseLuaText); + + foreach (var match in matches.Cast()) { + removed.Add(match.Value); + } + + sb.Append(baseLuaText); + sb.AppendLine(); + sb.AppendLine(); + + var members = type.GetMembers(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance); + foreach (var member in members) { + static string EscapeName(string n) { + return n switch { + "end" => "endparam", + _ => n + }; + } + + switch (member.MemberType) { + case MemberTypes.Method: { + var method = (MethodInfo)member; + + // Exclude property getters/setters + if (method.IsSpecialName) { + continue; + } + + var paramNames = new StringBuilder(); + foreach (var parameter in method.GetParameters()) { + paramNames.Append(EscapeName(parameter.Name!)); + paramNames.Append(", "); + } + if (paramNames.Length > 0) { + // Remove the last separator + paramNames.Length -= 2; + } + + string functionDecoration; + if (method.IsStatic) { + functionDecoration = $"function {type.Name}.{method.Name}({paramNames}) end"; + } else { + functionDecoration = $"function {method.Name}({paramNames}) end"; + } + + if (removed.Contains(functionDecoration)) { + continue; + } + + Console.WriteLine($" - METHOD: {method}"); + + sb.AppendLine($"--- {method.Name}"); + sb.AppendLine("-- @realm shared"); + + foreach (var parameter in method.GetParameters()) { + sb.AppendLine($"-- @tparam {TypeToString(parameter.ParameterType)} {EscapeName(parameter.Name!)}"); + } + + if (method.ReturnType != typeof(void)) { + sb.AppendLine($"-- @treturn {TypeToString(method.ReturnType)}"); + } + + sb.AppendLine(functionDecoration); + sb.AppendLine(); + break; + } + + case MemberTypes.Field: { + var field = (FieldInfo)member; + + var name = EscapeName(field.Name); + var returnName = TypeToString(field.FieldType); + + if (field.IsStatic) { + name = type.Name + "." + field.Name; + } + + if (removed.Contains(name)) { + continue; + } + + Console.WriteLine($" - FIELD: {name}"); + + sb.AppendLine("---"); + sb.Append("-- "); + sb.Append(name); + sb.AppendLine($", field of type {returnName}"); + sb.AppendLine("-- @realm shared"); + sb.AppendLine($"-- @field {name}"); + + sb.AppendLine(); + break; + } + + case MemberTypes.Property: { + var property = (PropertyInfo)member; + + var name = EscapeName(property.Name); + var returnName = TypeToString(property.PropertyType); + + if (property.GetGetMethod()?.IsStatic == true || property.GetSetMethod()?.IsStatic == true) { + name = type.Name + "." + property.Name; + } + + if (removed.Contains(name)) { + continue; + } + + Console.WriteLine($" - PROPERTY: {name}"); + + sb.AppendLine("---"); + sb.Append("-- "); + sb.Append(name); + sb.AppendLine($", field of type {returnName}"); + sb.AppendLine("-- @realm shared"); + sb.AppendLine($"-- @field {name}"); + + sb.AppendLine(); + break; + } + } + } + + new FileInfo(outFile).Directory.Create(); + File.WriteAllText(outFile, sb.ToString()); +} + +var basePath = $"{gitDir}/luacs-docs/lua"; +var generatedDir = $"{basePath}/lua/generated"; +var baseLuaDir = $"{basePath}/baseluadocs"; +void GenerateDocs(Type type, string file, string? categoryName = null) { + GenerateDocsImpl(type, $"{baseLuaDir}/{file}", $"{generatedDir}/{file}", categoryName); +} + +try { + Directory.Delete(generatedDir, true); +} catch (DirectoryNotFoundException) { } + +Directory.CreateDirectory(generatedDir); +Directory.CreateDirectory(baseLuaDir); + +GenerateDocs(typeof(Character), "Character.lua"); +GenerateDocs(typeof(CharacterInfo), "CharacterInfo.lua"); +GenerateDocs(typeof(CharacterHealth), "CharacterHealth.lua"); +GenerateDocs(typeof(AnimController), "AnimController.lua"); +GenerateDocs(typeof(Client), "Client.lua"); +GenerateDocs(typeof(Entity), "Entity.lua"); +GenerateDocs(typeof(EntitySpawner), "Entity.Spawner.lua", "Entity.Spawner"); +GenerateDocs(typeof(Item), "Item.lua"); +GenerateDocs(typeof(ItemPrefab), "ItemPrefab.lua"); +GenerateDocs(typeof(Submarine), "Submarine.lua"); +GenerateDocs(typeof(SubmarineInfo), "SubmarineInfo.lua"); +GenerateDocs(typeof(Job), "Job.lua"); +GenerateDocs(typeof(JobPrefab), "JobPrefab.lua"); +GenerateDocs(typeof(GameSession), "GameSession.lua", "Game.GameSession"); +GenerateDocs(typeof(NetLobbyScreen), "NetLobbyScreen.lua", "Game.NetLobbyScreen"); +GenerateDocs(typeof(GameScreen), "GameScreen.lua", "Game.GameScreen"); +GenerateDocs(typeof(FarseerPhysics.Dynamics.World), "World.lua", "Game.World"); +GenerateDocs(typeof(Inventory), "Inventory.lua", "Inventory"); +GenerateDocs(typeof(ItemInventory), "ItemInventory.lua", "ItemInventory"); +GenerateDocs(typeof(CharacterInventory), "CharacterInventory.lua", "CharacterInventory"); +GenerateDocs(typeof(Hull), "Hull.lua", "Hull"); +GenerateDocs(typeof(Level), "Level.lua", "Level"); +GenerateDocs(typeof(Affliction), "Affliction.lua", "Affliction"); +GenerateDocs(typeof(AfflictionPrefab), "AfflictionPrefab.lua", "AfflictionPrefab"); +GenerateDocs(typeof(WayPoint), "WayPoint.lua", "WayPoint"); +GenerateDocs(typeof(ServerSettings), "ServerSettings.lua", "Game.ServerSettings"); +GenerateDocs(typeof(GameSettings), "GameSettings.lua", "Game.Settings"); diff --git a/luacs-docs/lua/scripts/build.ps1 b/luacs-docs/lua/scripts/build.ps1 new file mode 100644 index 000000000..71b286024 --- /dev/null +++ b/luacs-docs/lua/scripts/build.ps1 @@ -0,0 +1,19 @@ +Import-Module $PSScriptRoot/../../scripts/location.ps1 + +try { + Change-Location $PSScriptRoot/.. + + Remove-Item -Force -Recurse ./build | Out-Null + New-Item -ItemType Directory ./build | Out-Null + Copy-Item -Path ./css/. -Destination ./build -Recurse -Force | Out-Null + Copy-Item -Path ./js/. -Destination ./build -Recurse -Force | Out-Null + + if ((Get-Command "lua_modules/bin/ldoc" -ErrorAction SilentlyContinue) -eq $null) { + echo "ldoc not found; please run docs/scripts/install.ps1" + exit 1 + } + + lua_modules/bin/ldoc . +} finally { + Restore-Location +} diff --git a/luacs-docs/lua/scripts/build.sh b/luacs-docs/lua/scripts/build.sh new file mode 100755 index 000000000..a08f0df88 --- /dev/null +++ b/luacs-docs/lua/scripts/build.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +cd "$DIR/.." + +ldoc_path=./lua_modules/bin/ldoc + +if [[ ! -x "$ldoc_path" ]]; then + echo "ldoc not found; please run docs/scripts/install.sh" + exit 1 +fi + +rm -rf ./build +mkdir ./build + +cp -r ./js/. ./build +cp -r ./css/. ./build + +"$ldoc_path" . diff --git a/luacs-docs/lua/scripts/generate_docs.ps1 b/luacs-docs/lua/scripts/generate_docs.ps1 new file mode 100644 index 000000000..1016df576 --- /dev/null +++ b/luacs-docs/lua/scripts/generate_docs.ps1 @@ -0,0 +1,15 @@ +Import-Module $PSScriptRoot/../../scripts/location.ps1 + +try { + Change-Location $PSScriptRoot/LuaDocsGenerator + + if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -eq $null) { + echo "dotnet not found" + exit 1 + } + + dotnet build -clp:"ErrorsOnly;Summary" + dotnet run --no-build +} finally { + Restore-Location +} diff --git a/luacs-docs/lua/scripts/generate_docs.sh b/luacs-docs/lua/scripts/generate_docs.sh new file mode 100755 index 000000000..da438e69c --- /dev/null +++ b/luacs-docs/lua/scripts/generate_docs.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +cd "$DIR/LuaDocsGenerator" + +if ! command -v "dotnet" &> /dev/null; then + if [[ -z "dotnet" ]]; then + echo "dotnet not found" + fi + exit 1 +fi + +dotnet build -clp:"ErrorsOnly;Summary" +dotnet run --no-build diff --git a/luacs-docs/lua/scripts/install.ps1 b/luacs-docs/lua/scripts/install.ps1 new file mode 100644 index 000000000..c028d722f --- /dev/null +++ b/luacs-docs/lua/scripts/install.ps1 @@ -0,0 +1,43 @@ +Import-Module $PSScriptRoot/../../scripts/location.ps1 + +try { + Change-Location $PSScriptRoot/.. + + $lua_binary = $env:LUA_BINARY + if ($lua_binary -eq $null) { + $lua_binary = "lua" + } + + if ((Get-Command "$lua_binary" -ErrorAction SilentlyContinue) -eq $null) { + if ($env:LUA_BINARY -eq $null) { + echo "lua binary not found; please set `$LUA_BINARY manually." + } else { + echo "lua binary not found: $lua_binary" + } + exit 1 + } + + if ((Get-Command "luarocks" -ErrorAction SilentlyContinue) -eq $null) { + echo "luarocks not found" + exit 1 + } + + $lua_version = (Invoke-Expression -Command "& $lua_binary -v 2>&1") -Replace '^Lua (\d+)\.(\d+).*$','$1.$2' + echo "Detected lua version $lua_version" + + $luarocks_args=@( + "--tree", + "$(Get-Location)/lua_modules", + "--lua-version", + "$lua_version" + ) + + try { + Change-Location ./libs/ldoc + luarocks @luarocks_args make + } finally { + Restore-Location + } +} finally { + Restore-Location +} diff --git a/luacs-docs/lua/scripts/install.sh b/luacs-docs/lua/scripts/install.sh new file mode 100755 index 000000000..a1b868bb5 --- /dev/null +++ b/luacs-docs/lua/scripts/install.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +cd "$DIR/.." + +lua_binary="${LUA_BINARY:-lua}" + +if ! command -v "$lua_binary" &> /dev/null; then + if [[ -z "${LUA_BINARY+x}" ]]; then + echo "lua binary not found; please set \$LUA_BINARY manually." + else + echo "lua binary not found: $lua_binary" + fi + exit 1 +fi + +if ! command -v "$lua_binary" &> /dev/null; then + echo "luarocks not found" + exit 1 +fi + +lua_version="$("$lua_binary" -v | grep -Po '^Lua \K(\d+)\.(\d+)')" +echo "Detected lua version $lua_version" + +# Install dependencies (npm style) +# NOTE: you need to have lua header files installed. +# On debian-based distros: apt install libluaX.X-dev + +luarocks_args=( + "--tree" + "$PWD/lua_modules" + "--lua-version" + "$lua_version" +) + +( + cd libs/ldoc + luarocks ${luarocks_args[@]} make +) diff --git a/luacs-docs/lua/scripts/serve.ps1 b/luacs-docs/lua/scripts/serve.ps1 new file mode 100644 index 000000000..07b40bc67 --- /dev/null +++ b/luacs-docs/lua/scripts/serve.ps1 @@ -0,0 +1,14 @@ +Import-Module $PSScriptRoot/../../scripts/location.ps1 + +try { + Change-Location $PSScriptRoot/.. + + if ((Get-Command "python3" -ErrorAction SilentlyContinue) -eq $null) { + echo "python3 not found" + exit 1 + } + + python3 ../scripts/http_server.py ./build --port 8000 +} finally { + Restore-Location +} diff --git a/luacs-docs/lua/scripts/serve.sh b/luacs-docs/lua/scripts/serve.sh new file mode 100755 index 000000000..1c62a7171 --- /dev/null +++ b/luacs-docs/lua/scripts/serve.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +cd "$DIR/.." + +if ! command -v "python3" &> /dev/null; then + echo "python3 not found" + exit 1 +fi + +python3 ../scripts/http_server.py ./build --port 8000 diff --git a/luacs-docs/lua/templates/landing.ltp b/luacs-docs/lua/templates/landing.ltp new file mode 100644 index 000000000..8080a8eec --- /dev/null +++ b/luacs-docs/lua/templates/landing.ltp @@ -0,0 +1,24 @@ + +
+

Lua For Barotrauma Documentation

+
+ +
+

+

Welcome to the Lua For Barotrauma documentation!

+

This is a work in progress documentation, not everything is documented here, but because Barotrauma classes are exposed to Lua, you can check the Barotrauma source code for functions and fields that you can access.

+ +

Installing Lua For Barotrauma

+

Downloading and using the Core Content Package from Workshop should be enough to have it installed, but if you want to install it manually, you can check out this guide. +

+ +

Getting Started

+

If you want to get started with Lua For Barotrauma modding, check out this guide. +

+ +

Links

+

+ Github
+ Discord Server +

+
diff --git a/luacs-docs/lua/templates/ldoc.ltp b/luacs-docs/lua/templates/ldoc.ltp new file mode 100644 index 000000000..fb0491e73 --- /dev/null +++ b/luacs-docs/lua/templates/ldoc.ltp @@ -0,0 +1,156 @@ + +{% +math.randomseed(os.time()) + +local baseUrl = ldoc.css:gsub("ldoc.css", "") +local repo = "https://github.com/evilfactory/LuaCsForBarotrauma" +local pageTitle = mod and (ldoc.display_name(mod) .. " - " .. ldoc.title) or ldoc.title + +local oldmarkup = ldoc.markup +function ldoc.markup(text, item) + return oldmarkup(text, item, ldoc.plain) +end + +function ldoc.url(path) + return baseUrl .. path +end + +function ldoc.asset_url(path) + local uuid = string.gsub("xxxxxxx", "x", function(c) + return string.format("%x", math.random(0, 0xf)) + end) + return baseUrl .. path .. "?v=" .. uuid +end + +function ldoc.realm_icon(realm) + assert( + realm == "server" or realm == "client" or realm == "shared", + string.format("WARNING: invalid realm '%s'", realm)) + return "" +end + +function ldoc.realm_icon_from_item(item) + local realm = item.tags.realm + assert(type(realm) == "table" and #realm > 0, "missing @realm tag") + return ldoc.realm_icon(realm[1]) +end + +function ldoc.sidebar_item(item, module) + local text = "" + + text = text .. ldoc.realm_icon_from_item(item) + text = text .. "" + + local deprecated = item.tags.deprecated + if deprecated then + text = text .. "" + else + text = text .. "" + end + + if ldoc.is_kind_classmethod(module.kind) then + text = text .. item.name:gsub(".+:", "") + else + text = text .. item.name:gsub(module.name .. ".", "") + end + + text = text + .. "" + .. "" + return text +end + +function ldoc.item_header(item) + local text = "" + + text = text .. "" + + local deprecated = item.tags.deprecated + if deprecated then + text = text .. "

" + else + text = text .. "

" + end + + text = text + .. ldoc.realm_icon_from_item(item) + .. ldoc.display_name(item) + .. "

" + .. "
" + + return text +end + +function ldoc.is_kind_classmethod(kind) + return kind ~= "libraries" +end + +function ldoc.repo_reference(item) + return repo .. "tree/master" .. item.file.filename:gsub(item.file.base, "/gamemode") .. "#L" .. item.lineno +end + +local function moduleDescription(mod) + if (mod.type == "topic") then + return mod.body:gsub(mod.display_name, ""):gsub("#", ""):sub(1, 256) .. "..." + end + + return mod.summary +end +%} + + + + {{pageTitle}} + + + + + + {% if (mod) then %} + + {% else %} + + {% end %} + + + + + + + +
+ {(templates/sidebar.ltp)} + +
+ {% if (ldoc.root) then -- we're rendering the landing page (index.html) %} + {(templates/landing.ltp)} + {% elseif (ldoc.body) then -- we're rendering non-code elements %} +
+ {* ldoc.body *} +
+ {% elseif (module) then -- we're rendering libary contents %} +
+ {(templates/module.ltp)} +
+ {% end %} +
+
+ + + + + + diff --git a/luacs-docs/lua/templates/module.ltp b/luacs-docs/lua/templates/module.ltp new file mode 100644 index 000000000..ff921a910 --- /dev/null +++ b/luacs-docs/lua/templates/module.ltp @@ -0,0 +1,148 @@ + +
+

{{mod.name}}

+

{* ldoc.markup(mod.summary) *}

+
+ +

{* ldoc.markup(mod.description) *}

+ +{% for kind, items, _, summary in mod.kinds() do %} +
+

{{kind}}

+ {% if summary ~= nil then %} +
+

{* ldoc.markup(summary) *}

+ {% end %} +
+ + {% for item in items() do %} +
+
+ {* ldoc.item_header(item) *} + + {% if item.tags.deprecated then %} +
+
Deprecated
+
+

This API is deprecated and shouldn't be used anymore.

+ {% for _, m in ipairs(item.tags.deprecated) do %} + {% if m ~= "" then %} +

{* ldoc.markup(m) *}

+ {% end %} + {% end %} +
+
+ {% end %} + + {% if (item.tags.internal) then %} +
+
Internal
+
+

This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.

+
+
+ {% end %} + + {% if (ldoc.descript(item):len() == 0) then %} +
+
Incomplete
+
+

Documentation for this section is incomplete and needs expanding.

+
+
+ {% else %} +

{* ldoc.markup(ldoc.descript(item)) *}

+ {% end %} +
+ + {# function arguments #} + {% if (item.params and #item.params > 0) then %} + {% local subnames = mod.kinds:type_of(item).subnames %} + + {% if (subnames) then %} +

{{subnames}}

+ {% end %} + + {% for argument in ldoc.modules.iter(item.params) do %} + {% local argument, sublist = item:subparam(argument) %} + +
    + {% for argumentName in ldoc.modules.iter(argument) do %} + {% local displayName = item:display_name_of(argumentName) %} + {% local type = ldoc.typename(item:type_of_param(argumentName)) %} + {% local default = item:default_of_param(argumentName) %} + {% local readonly = item:readonly(argumentName) %} + +
  • + {{displayName}} + + {% if (type ~= "") then %} + {* type *} + {% end %} + + {% if (default and default ~= true) then %} + default: {{default}} + {% elseif (default) then %} + optional + {% end %} + + {% if (readonly) then %} + read-only + {% end %} + +

    {* ldoc.markup(item.params.map[argumentName]) *}

    +
  • + {% end %} +
+ {% end %} + {% end %} + + {# function returns #} + {% if ((not ldoc.no_return_or_parms) and item.retgroups) then %} + {% local groups = item.retgroups %} + +

Returns

+
    + {% for i, group in ldoc.ipairs(groups) do %} + {% for returnValue in group:iter() do %} + {% local type, ctypes = item:return_type(returnValue) %} + {% type = ldoc.typename(type) %} + +
  • + + {% if (type ~= "") then %} + {* type *} + {% else -- we'll assume that it will return a variable type if none is set %} + any + {% end %} + + +

    {* ldoc.markup(returnValue.text) *}

    +
  • + {% end %} + + {% if (i ~= #groups) then %} +
    OR
    + {% end %} + {% end %} +
+ {% end %} + + {% if (item.usage) then -- function usage %} +

Example Usage

+ {% for usage in ldoc.modules.iter(item.usage) do %} +
{* usage *}
+ {% end %} + {% end %} + + {% if (item.see) then %} +

See Also

+
    + {% for see in ldoc.modules.iter(item.see) do %} +
  • {{see.label}}
  • + {% end %} +
+ {% end %} +
+ {% end %} +{% end %} diff --git a/luacs-docs/lua/templates/sidebar.ltp b/luacs-docs/lua/templates/sidebar.ltp new file mode 100644 index 000000000..aec7570c7 --- /dev/null +++ b/luacs-docs/lua/templates/sidebar.ltp @@ -0,0 +1,130 @@ + +{% +local function isKindExpandable(kind) + return kind ~= "Manual" +end + +local function isSectionEmpty(mod, sections) + if type(sections) == "table" then + for _, v in pairs(mod.items) do + for _, section in pairs(sections) do + if v.section_id == section then + return false + end + end + end + else + local section = sections + for _, v in pairs(mod.items) do + if v.section_id == section then + return false + end + end + end + return true +end +%} + + diff --git a/luacs-docs/scripts/http_server.py b/luacs-docs/scripts/http_server.py new file mode 100644 index 000000000..107939423 --- /dev/null +++ b/luacs-docs/scripts/http_server.py @@ -0,0 +1,76 @@ +import os +import http.server +from http.server import SimpleHTTPRequestHandler +import argparse + +def Route(s): + try: + prefix, root = s.split(":", 1) + except: + raise argparse.ArgumentTypeError("Route mapping must be in the : format: " + s) + return (prefix, root) + +parser = argparse.ArgumentParser() +parser.add_argument("root", type=str) +parser.add_argument("--port", type=int, default=8000) +parser.add_argument("--route", type=Route, dest="routes", action="extend", nargs="*") + +class RequestHandler(SimpleHTTPRequestHandler): + base_dir = None + routes = [] + + def end_headers(self): + self.send_header("Cache-Control", "no-cache, no-store, must-revalidate") + self.send_header("Pragma", "no-cache") + self.send_header("Expires", "0") + SimpleHTTPRequestHandler.end_headers(self) + + def do_GET(self): + if '?' in self.path: + self.path = self.path.split('?')[0] + SimpleHTTPRequestHandler.do_GET(self) + + def translate_path(self, path): + path.lstrip() + for prefix, rootDir in self.routes: + if path.startswith(prefix): + # print("matched route: " + prefix) + path = path[len(prefix):] + root = rootDir + break + + path.lstrip() + if root == None: + raise Exception("No route matches path: " + path) + + # Make sure we don't have a path that starts with /, otherwise + # os.path.join() would resolve it to the root of the filesystem. + if path.startswith("/"): + path = "." + path + + resolved_path = os.path.join(self.base_dir, root, path) + + # print("base_dir: " + self.base_dir) + # print("root: " + root) + # print("path: " + path) + # print("resolved_path: " + resolved_path) + + return resolved_path + +if __name__ == "__main__": + args = parser.parse_args() + + # Make sure we have at least one route + if not args.routes: + args.routes = [("/", "")] + + # Routes listed first should have precedence over the rest + args.routes.reverse() + + RequestHandler.base_dir = args.root + RequestHandler.routes = args.routes + port = args.port + + httpd = http.server.HTTPServer(("127.0.0.1", port), RequestHandler) + print(f"Listening on port {port} (http://127.0.0.1:{port})") + httpd.serve_forever() diff --git a/luacs-docs/scripts/location.ps1 b/luacs-docs/scripts/location.ps1 new file mode 100644 index 000000000..d265e213f --- /dev/null +++ b/luacs-docs/scripts/location.ps1 @@ -0,0 +1,14 @@ +[System.Collections.ArrayList]$Locations = @() + +function Change-Location($path) { + $loc = Get-Location + $Locations.Add($loc) + Set-Location $path +} + +function Restore-Location { + $idx = $Locations.Count - 1 + $loc = $Locations[$idx] + $Locations.RemoveAt($idx) + Set-Location $loc +}