From 09d5776f32ae321d57ee7b6df8f75d75052fc860 Mon Sep 17 00:00:00 2001 From: Chomp Date: Fri, 28 Mar 2025 17:35:00 +0000 Subject: [PATCH] Added christmas tree to hideout areas on server start via custom area system --- .../Assets/database/hideout/customAreas.json | 66 +++++++++++++++++++ .../Models/Spt/Hideout/Hideout.cs | 6 ++ .../Services/PostDbLoadService.cs | 20 +++++- 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 Libraries/SPTarkov.Server.Assets/Assets/database/hideout/customAreas.json diff --git a/Libraries/SPTarkov.Server.Assets/Assets/database/hideout/customAreas.json b/Libraries/SPTarkov.Server.Assets/Assets/database/hideout/customAreas.json new file mode 100644 index 00000000..29230a2e --- /dev/null +++ b/Libraries/SPTarkov.Server.Assets/Assets/database/hideout/customAreas.json @@ -0,0 +1,66 @@ +[{ + "_id": "5df8a81f8f77747fcf5f5702", + "type": 21, + "enabled": true, + "needsFuel": true, + "takeFromSlotLocked": false, + "craftGivesExp": true, + "displayLevel": true, + "requirements": [], + "stages": { + "0": { + "requirements": [], + "bonuses": [], + "slots": 0, + "constructionTime": 0.0, + "description": "", + "container": "", + "autoUpgrade": false, + "displayInterface": true, + "improvements": [] + }, + "1": { + "requirements": [{ + "areaType": 4, + "requiredLevel": 1, + "type": "Area" + }, { + "templateId": "5449016a4bdc2d6f028b456f", + "count": 10000, + "isFunctional": false, + "isEncoded": false, + "type": "Item" + }, { + "templateId": "5df8a77486f77412672a1e3f", + "count": 1, + "isFunctional": false, + "isEncoded": false, + "type": "Item" + }, { + "templateId": "5df8a72c86f77412640e2e83", + "count": 1, + "isFunctional": false, + "isEncoded": false, + "type": "Item" + }, { + "templateId": "5df8a6a186f77412640e2e80", + "count": 1, + "isFunctional": false, + "isEncoded": false, + "type": "Item" + } + ], + "bonuses": [], + "slots": 0, + "constructionTime": 0.0, + "description": "", + "container": "", + "autoUpgrade": false, + "displayInterface": true, + "improvements": [] + } + }, + "enableAreaRequirements": false, + "parentArea": null + } +] diff --git a/Libraries/SPTarkov.Server.Core/Models/Spt/Hideout/Hideout.cs b/Libraries/SPTarkov.Server.Core/Models/Spt/Hideout/Hideout.cs index d7face28..8a9c8870 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Spt/Hideout/Hideout.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Spt/Hideout/Hideout.cs @@ -11,6 +11,12 @@ public record Hideout get; set; } + [JsonPropertyName("customAreas")] + public List? CustomAreas + { + get; + set; + } [JsonPropertyName("customisation")] public HideoutCustomisation? Customisation diff --git a/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs b/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs index 5fad7bde..8db6c1c2 100644 --- a/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/PostDbLoadService.cs @@ -6,7 +6,6 @@ using SPTarkov.Server.Core.Servers; using SPTarkov.Server.Core.Utils; using SPTarkov.Server.Core.Utils.Cloners; using SPTarkov.Common.Annotations; -using SPTarkov.Server.Core.Models.Eft.Common.Tables; namespace SPTarkov.Server.Core.Services; @@ -84,6 +83,8 @@ public class PostDbLoadService( AdjustLocationBotValues(); + MergeCustomHideoutAreas(); + if (_locationConfig.RogueLighthouseSpawnTimeSettings.Enabled) { FixRoguesSpawningInstantlyOnLighthouse(); @@ -126,6 +127,23 @@ public class PostDbLoadService( _raidWeatherService.GenerateWeather(currentSeason); } + private void MergeCustomHideoutAreas() + { + var hideout = _databaseService.GetHideout(); + foreach (var customArea in hideout.CustomAreas) + { + // Check if exists + if (hideout.Areas!.Exists(area => area.Id == customArea.Id)) + { + _logger.Warning($"Unable to add new hideout area with Id: {customArea.Id} as ID is already in use, skipping"); + + continue; + } + + hideout.Areas.Add(customArea); + } + } + /// /// Merge custom achievements into achievement db table ///