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>_7UseMultipleClasses</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,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _7UseMultipleClasses
{
public class SecondClass
{
public string GetText()
{
return "test text";
}
}
}
@@ -0,0 +1,31 @@
using Core.Models.External;
using Core.Models.Utils;
namespace _7UseMultipleClasses
{
/// <summary>
/// Having multiple classes can make keeping your code maintainable easier, you can split related code into their own class
/// </summary>
public class UseMultipleClasses : IPostDBLoadMod
{
private readonly ISptLogger<UseMultipleClasses> _logger;
public UseMultipleClasses(
ISptLogger<UseMultipleClasses> logger)
{
this._logger = logger;
}
public void PostDBLoad()
{
// We create an instance of the other class
var otherClass = new SecondClass();
// We call the "GetText" method that exists in the other class
var text = otherClass.GetText();
// Log the result to the server console
_logger.Info($"The SecondClass returned the text: {text}");
}
}
}
@@ -0,0 +1,13 @@
{
"Name": "7UseMultipleClasses",
"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"
}