feat: apply things learned in better autocasting mod

This commit is contained in:
Tobias Berger 2024-04-04 21:36:32 +02:00
parent 472afff0a2
commit 98ea411011
Signed by: toby
GPG key ID: 2D05EFAB764D6A88
16 changed files with 143 additions and 52 deletions

12
.config/dotnet-tools.json Normal file
View file

@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"roslynator.dotnet.cli": {
"version": "0.8.4",
"commands": [
"roslynator"
]
}
}
}

4
.vscode/build.sh vendored
View file

@ -4,9 +4,11 @@ script_dir=$(dirname $(readlink -f $0))
mod_dir=$(dirname $script_dir) mod_dir=$(dirname $script_dir)
pushd $script_dir pushd $script_dir
configuration=${1:-Debug}
# build dll # build dll
rm -f ../1.4/Assemblies/* rm -f ../1.4/Assemblies/*
dotnet build mod.csproj dotnet build mod.csproj -c ${configuration}
# generate About.xml # generate About.xml
rm -f ../About/About.xml rm -f ../About/About.xml

0
.vscode/fmt.sh vendored Normal file → Executable file
View file

2
.vscode/launch.sh vendored
View file

@ -4,6 +4,6 @@ script_dir=$(dirname $(readlink -f $0))
mod_dir=$(dirname $script_dir) mod_dir=$(dirname $script_dir)
pushd $script_dir pushd $script_dir
LC_ALL=C steam-run ~/.steam/steam/steamapps/common/RimWorld/RimWorldLinux -logfile $mod_dir/log/rimworld.log -popupwindow $@ SDL_VIDEODRIVER=X11 LC_ALL=C steam-run ~/.local/share/Steam/steamapps/common/RimWorld/RimWorldLinux -logfile $mod_dir/log/rimworld.log -popupwindow $@
popd popd

17
.vscode/mod.csproj vendored
View file

@ -13,6 +13,7 @@
<DebugType>none</DebugType> <DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Nullable>enable</Nullable>
<!-- Contents of About.xml <!-- Contents of About.xml
See https://rimworldwiki.com/wiki/Modding_Tutorials/About.xml --> See https://rimworldwiki.com/wiki/Modding_Tutorials/About.xml -->
<ModMetaData> <ModMetaData>
@ -28,7 +29,7 @@
<modVersion IgnoreIfNoMatchingField="True"> <modVersion IgnoreIfNoMatchingField="True">
<!-- Gets automatically populated with VersionPrefix (see above) --> <!-- Gets automatically populated with VersionPrefix (see above) -->
</modVersion> </modVersion>
<url /> <url>https://git.tobot.dev/toby/rimworld-mod-template</url>
<modDependencies /> <modDependencies />
<modDependenciesByVersion> <modDependenciesByVersion>
<!-- <v1.4> <!-- <v1.4>
@ -52,12 +53,20 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<!-- Mod --> <!-- Mod -->
<Compile Include="../Source/*" /> <Compile Include="../Source/**/*" />
<PackageReference Include="Krafs.Rimworld.Ref" <PackageReference Include="Krafs.Rimworld.Ref"
Version="1.4.3901" /> Version="1.4.3901" />
<!-- Set IncludeAssets to 'compile' to enable Harmony --> <!-- Set IncludeAssets to 'compile' to enable Harmony -->
<PackageReference Include="Lib.Harmony" <PackageReference Include="Lib.Harmony.Thin"
Version="2.2.2" Version="2.3.3"
IncludeAssets="none" /> IncludeAssets="none" />
<PackageReference Include="roslynator.analyzers"
Version="4.12.0"
IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"
PrivateAssets="all" />
<PackageReference Include="roslynator.formatting.analyzers"
Version="4.12.0"
IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"
PrivateAssets="all" />
</ItemGroup> </ItemGroup>
</Project> </Project>

9
.vscode/roslynator.sh vendored Executable file
View file

@ -0,0 +1,9 @@
set -e
script_dir=$(dirname $(readlink -f $0))
mod_dir=$(dirname $script_dir)
pushd $mod_dir
dotnet roslynator analyze $script_dir/mod.csproj
popd

31
.vscode/settings.json vendored
View file

@ -3,22 +3,25 @@
"files.exclude": { "files.exclude": {
".direnv": true, ".direnv": true,
".vscode/obj": true, ".vscode/obj": true,
"1.4/Assemblies/": true, "*/Assemblies/": true,
"About/": true,
}, },
"files.readonlyInclude": { "files.readonlyInclude": {
"log/rimworld.log": true, "log/rimworld.log": true,
"About/About.xml": true,
}, },
"csharp.inlayHints.parameters.enabled": true, "omnisharp.organizeImportsOnFormat": true,
"csharp.inlayHints.parameters.forIndexerParameters": true, "dotnet.inlayHints.enableInlayHintsForParameters": true,
"csharp.inlayHints.parameters.forLiteralParameters": true, "dotnet.inlayHints.enableInlayHintsForLiteralParameters": true,
"csharp.inlayHints.parameters.forObjectCreationParameters": true, "dotnet.inlayHints.enableInlayHintsForIndexerParameters": true,
"csharp.inlayHints.parameters.forOtherParameters": true, "dotnet.inlayHints.enableInlayHintsForObjectCreationParameters": true,
"csharp.inlayHints.parameters.suppressForParametersThatDifferOnlyBySuffix": true, "dotnet.inlayHints.enableInlayHintsForOtherParameters": true,
"csharp.inlayHints.parameters.suppressForParametersThatMatchArgumentName": true, "dotnet.inlayHints.suppressInlayHintsForParametersThatDifferOnlyBySuffix": true,
"csharp.inlayHints.parameters.suppressForParametersThatMatchMethodIntent": true, "dotnet.inlayHints.suppressInlayHintsForParametersThatMatchMethodIntent": true,
"csharp.inlayHints.types.enabled": true, "dotnet.inlayHints.suppressInlayHintsForParametersThatMatchArgumentName": true,
"csharp.inlayHints.types.forImplicitObjectCreation": true, "csharp.inlayHints.enableInlayHintsForTypes": true,
"csharp.inlayHints.types.forImplicitVariableTypes": true, "csharp.inlayHints.enableInlayHintsForImplicitVariableTypes": true,
"csharp.inlayHints.types.forLambdaParameterTypes": true "csharp.inlayHints.enableInlayHintsForLambdaParameterTypes": true,
"csharp.inlayHints.enableInlayHintsForImplicitObjectCreation": true,
"dotnet.server.useOmnisharp": true,
"omnisharp.enableLspDriver": false
} }

12
.vscode/setup.sh vendored
View file

@ -1,12 +1,20 @@
set -e set -e
set -x
script_dir=$(dirname $(readlink -f $0)) script_dir=$(dirname $(readlink -f $0))
mod_dir=$(dirname $script_dir) mod_dir=$(dirname $script_dir)
pushd $script_dir pushd $script_dir
mod_name="${mod_dir##*/}" mod_name="${mod_dir##*/}"
target_dir=$(readlink -f ~/.local/share/Steam/steamapps/common/RimWorld/Mods/)/$mod_name
# Try to create symlink in RimWorld mod directory dotnet tool restore
ln -s $mod_dir -t "$(readlink -f ~/.steam/steam/steamapps/common/RimWorld/Mods)" -v || echo "Target directory already exists. This is expected on re-runs"
if [ "$target_dir" = "$mod_dir" ]; then
echo "Target directory is the same as the mod directory. Cloned in RimWorld/Mods. Skipping setup"
else
mkdir -p $target_dir
rsync -av --exclude '$mod_dir/*' --delete $mod_dir/1.4 $mod_dir/About $mod_dir/README $mod_dir/LICENSE $target_dir
fi
popd popd

56
.vscode/tasks.json vendored
View file

@ -1,6 +1,13 @@
{ {
"version": "2.0.0", "version": "2.0.0",
"tasks": [ "tasks": [
{
"label": "analyze",
"type": "shell",
"group": "none",
"command": ".vscode/roslynator.sh",
"problemMatcher": []
},
{ {
"label": "format", "label": "format",
"type": "shell", "type": "shell",
@ -9,7 +16,7 @@
"problemMatcher": [] "problemMatcher": []
}, },
{ {
"label": "build mod", "label": "build mod (Debug)",
"type": "shell", "type": "shell",
"group": { "group": {
"kind": "build", "kind": "build",
@ -18,10 +25,24 @@
"command": ".vscode/build.sh", "command": ".vscode/build.sh",
"problemMatcher": [ "problemMatcher": [
"$msCompile" "$msCompile"
] ],
"dependsOn": []
}, },
{ {
"label": "run game", "label": "build mod (Release)",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"command": ".vscode/build.sh Release",
"problemMatcher": [
"$msCompile"
],
"dependsOn": []
},
{
"label": "run game (Debug)",
"type": "shell", "type": "shell",
"group": { "group": {
"kind": "none", "kind": "none",
@ -29,13 +50,29 @@
}, },
"command": ".vscode/launch.sh", "command": ".vscode/launch.sh",
"problemMatcher": [], "problemMatcher": [],
"dependsOrder": "sequence",
"dependsOn": [ "dependsOn": [
"link mod directory", "build mod (Debug)",
"build mod" "set up mod directory"
] ]
}, },
{ {
"label": "run game (quicktest)", "label": "run game (Release)",
"type": "shell",
"group": {
"kind": "none",
"isDefault": true
},
"command": ".vscode/launch.sh",
"problemMatcher": [],
"dependsOrder": "sequence",
"dependsOn": [
"build mod (Release)",
"set up mod directory"
]
},
{
"label": "run game (Debug + quicktest)",
"type": "shell", "type": "shell",
"group": { "group": {
"kind": "none", "kind": "none",
@ -43,13 +80,14 @@
}, },
"command": ".vscode/launch.sh -quicktest", "command": ".vscode/launch.sh -quicktest",
"problemMatcher": [], "problemMatcher": [],
"dependsOrder": "sequence",
"dependsOn": [ "dependsOn": [
"link mod directory", "build mod (Debug)",
"build mod" "set up mod directory"
] ]
}, },
{ {
"label": "link mod directory", "label": "set up mod directory",
"type": "shell", "type": "shell",
"group": { "group": {
"kind": "none" "kind": "none"

Binary file not shown.

View file

@ -10,7 +10,7 @@
<li>1.4</li> <li>1.4</li>
</supportedVersions> </supportedVersions>
<modVersion IgnoreIfNoMatchingField="True">0.1.0.0</modVersion> <modVersion IgnoreIfNoMatchingField="True">0.1.0.0</modVersion>
<url/> <url>https://git.tobot.dev/toby/rimworld-mod-template</url>
<modDependencies/> <modDependencies/>
<modDependenciesByVersion> <modDependenciesByVersion>
<!-- <v1.4> <!-- <v1.4>

View file

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2024 Tobias Berger Copyright (c) 2024 Toby (Tobias Berger)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

11
README Normal file
View file

@ -0,0 +1,11 @@
Template for RimWorld Mods in nix
Expects the following VSCode extensions
- ms-dotnettools.vscode-dotnet-runtime
- ms-dotnettools.csharp
Expects the following VSCode settings:
- dotnet.dotnetPath should point at the .NET SDK
- omnisharp.monoPath should point at the mono install dir
- omnisharp.path should point at the omnisharp binary
- dotnet.server.path should point at the omnisharp binary?

View file

@ -6,7 +6,7 @@ using Verse;
namespace Template; namespace Template;
[DefOf] [DefOf]
public class TemplateDefOf public static class TemplateDefOf
{ {
public static LetterDef success_letter; public static LetterDef success_letter;
} }

View file

@ -5,11 +5,11 @@
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1706830856, "lastModified": 1712014858,
"narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=", "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f", "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -20,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1707546158, "lastModified": 1712163089,
"narHash": "sha256-nYYJTpzfPMDxI8mzhQsYjIUX+grorqjKEU9Np6Xwy/0=", "narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "d934204a0f8d9198e1e4515dd6fec76a139c87f0", "rev": "fd281bd6b7d3e32ddfa399853946f782553163b5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -37,11 +37,11 @@
"nixpkgs-lib": { "nixpkgs-lib": {
"locked": { "locked": {
"dir": "lib", "dir": "lib",
"lastModified": 1706550542, "lastModified": 1711703276,
"narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=", "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "97b17f32362e475016f942bbdfda4a4a72a8a652", "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -54,11 +54,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1705856552, "lastModified": 1708475490,
"narHash": "sha256-JXfnuEf5Yd6bhMs/uvM67/joxYKoysyE3M2k6T3eWbg=", "narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "612f97239e2cc474c13c9dafa0df378058c5ad8d", "rev": "0e74ca98a74bc7270d28838369593635a5db3260",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -96,11 +96,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1707300477, "lastModified": 1711963903,
"narHash": "sha256-qQF0fEkHlnxHcrKIMRzOETnRBksUK048MXkX0SOmxvA=", "narHash": "sha256-N3QDhoaX+paWXHbEXZapqd1r95mdshxToGowtjtYkGI=",
"owner": "numtide", "owner": "numtide",
"repo": "treefmt-nix", "repo": "treefmt-nix",
"rev": "ac599dab59a66304eb511af07b3883114f061b9d", "rev": "49dc4a92b02b8e68798abd99184f228243b6e3ac",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -29,7 +29,6 @@
nixpkgs-fmt.enable = true; nixpkgs-fmt.enable = true;
csharpier.enable = true; csharpier.enable = true;
prettier.enable = true; prettier.enable = true;
nixfmt.enable = true;
}; };
}; };
}; };