Update Mods to be foldered/ own csproj/ ref dll

This commit is contained in:
CWX
2025-02-10 15:04:40 +00:00
parent ed54312f35
commit 7cd8ef9179
49 changed files with 361 additions and 121 deletions
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>_10CustomRoute</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<!-- TODO: Change to Nuget Package -->
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
@@ -0,0 +1,46 @@
using Core.DI;
using Core.Models.Utils;
using Core.Utils;
using SptCommon.Annotations;
namespace _10CustomRoute;
// Flag our mod as a type of static router
[Injectable(InjectableTypeOverride = typeof(StaticRouter))]
public class CustomStaticRouter : StaticRouter
{
public CustomStaticRouter(
JsonUtil jsonUtil) : base(
jsonUtil,
// Add an array of routes we want to add
GetCustomRoutes()
)
{
}
private static List<RouteAction> GetCustomRoutes()
{
return
[
new RouteAction(
"/example/route/static",
(
url,
info,
sessionId,
output
) => HandleRoute(url, info as ExampleStaticRequestData, sessionId)
)
];
}
private static string HandleRoute(string url, ExampleStaticRequestData info, string sessionId)
{
// Stuff goes here
return string.Empty;
}
}
public class ExampleStaticRequestData : IRequestData
{
}
+13
View File
@@ -0,0 +1,13 @@
{
"Name": "10CustomStaticRouter",
"Version": "1.0.0",
"SptVersion": "~4.0",
"LoadBefore": [],
"LoadAfter": [],
"IncompatibileMods": [],
"Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods",
"IsBundleMod": false,
"Author": "SPT",
"Contributors": [],
"Licence": "MIT"
}