fix csprojs of mod examples

This commit is contained in:
CWX
2025-02-10 15:50:51 +00:00
parent 5e698d0809
commit 339c873161
17 changed files with 268 additions and 0 deletions
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
+9
View File
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>_14AfterDBLoadHook</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<!-- TODO: Change to Nuget Package -->
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
@@ -0,0 +1,61 @@
using Core.Models.Eft.Common.Tables;
using Core.Models.External;
using Core.Models.Logging;
using Core.Models.Utils;
using Core.Servers;
using SptCommon.Annotations;
namespace _14AfterDBLoadHook;
[Injectable]
public class AfterDBLoadHook : IPostDBLoadMod, IPostSptLoadMod
{
private readonly ConfigServer _configServer;
private readonly DatabaseServer _databaseServer;
private readonly ISptLogger<AfterDBLoadHook> _logger;
private Dictionary<string, TemplateItem>? _itemsDb;
public AfterDBLoadHook(
ConfigServer configServer,
DatabaseServer databaseServer,
ISptLogger<AfterDBLoadHook> logger
)
{
_configServer = configServer;
_databaseServer = databaseServer;
_logger = logger;
}
public void PostDBLoad()
{
_itemsDb = _databaseServer.GetTables().Templates.Items;
// Database will be loaded, this is the fresh state of the DB so NOTHING from the SPT
// logic has modified anything yet. This is the DB loaded straight from the JSON files
_logger.LogWithColor($"Database item size: {_itemsDb.Count}", LogTextColor.Red, LogBackgroundColor.Yellow);
// lets do a quick modification and see how this reflect later on, on the postSptLoad()
// find the nvgs item by its Id
// this also checks if the item exists before giving you the item
// if it doesn't, this if check will fail
if (_itemsDb.TryGetValue("5c0558060db834001b735271", out var nvgs))
{
// Lets log the state before the modification
_logger.LogWithColor($"NVGs default CanSellOnRagfair: {nvgs.Properties.CanSellOnRagfair}", LogTextColor.Red, LogBackgroundColor.Yellow);
// Update one of its properties to be true
nvgs.Properties.CanSellOnRagfair = true;
}
}
public void PostSptLoad()
{
// The modification we made above would have been processed by now by SPT, so any values we changed had
// already been passed through the initial lifecycles (OnLoad) of SPT.
if (_itemsDb.TryGetValue("5c0558060db834001b735271", out var nvgs))
{
// Lets log the state after the modification
_logger.LogWithColor($"NVGs default CanSellOnRagfair: {nvgs.Properties.CanSellOnRagfair}", LogTextColor.Red, LogBackgroundColor.Yellow);
}
}
}
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<RootNamespace>_15HttpListenerExample</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<!-- TODO: Change to Nuget Package -->
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
</ItemGroup>
</Project>
@@ -0,0 +1,22 @@
using System.Text;
using Core.Servers.Http;
using Microsoft.AspNetCore.Http;
using SptCommon.Annotations;
namespace _15HttpListenerExample;
[Injectable]
public class HttpListenerExample : IHttpListener
{
public bool CanHandle(string sessionId, HttpRequest req)
{
return req.Method == "GET" && req.Method.Contains("/type-custom-url");
}
public void Handle(string sessionId, HttpRequest req, HttpResponse resp)
{
resp.StatusCode = 200;
resp.Body.WriteAsync(Encoding.UTF8.GetBytes("[1] This is the first example of a mod hooking into the HttpServer")).AsTask().Wait();
resp.
}
}
+9
View File
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
+9
View File
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
+9
View File
@@ -11,12 +11,21 @@
<ItemGroup>
<Reference Include="Core">
<HintPath>..\TempReferences\Core.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptCommon">
<HintPath>..\TempReferences\SptCommon.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
<Reference Include="SptDependencyInjection">
<HintPath>..\TempReferences\SptDependencyInjection.dll</HintPath>
<Private>false</Private>
<CopyLocal>false</CopyLocal>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
</Project>
+12
View File
@@ -29,6 +29,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "12Bundle", "12Bundle\12Bund
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "13AddTraderWithAssortJson", "13AddTraderWithAssortJson\13AddTraderWithAssortJson\13AddTraderWithAssortJson.csproj", "{636D5797-E37F-425A-B8DB-E3FBE4573F71}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "14AfterDBLoadHook", "14AfterDBLoadHook\14AfterDBLoadHook.csproj", "{B4DDC0E8-99D1-405E-9E01-823523FE642B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15HttpListenerExample", "15HttpListenerExample\15HttpListenerExample.csproj", "{15F2B434-439E-498E-9B85-B7BBC2F4AFA4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -90,5 +94,13 @@ Global
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
{B4DDC0E8-99D1-405E-9E01-823523FE642B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4DDC0E8-99D1-405E-9E01-823523FE642B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4DDC0E8-99D1-405E-9E01-823523FE642B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4DDC0E8-99D1-405E-9E01-823523FE642B}.Release|Any CPU.Build.0 = Release|Any CPU
{15F2B434-439E-498E-9B85-B7BBC2F4AFA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15F2B434-439E-498E-9B85-B7BBC2F4AFA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15F2B434-439E-498E-9B85-B7BBC2F4AFA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15F2B434-439E-498E-9B85-B7BBC2F4AFA4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal