Implemented CloneExistingCraftsAndAddNew
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Json.Serialization;
|
||||
using Core.Models.Common;
|
||||
using Core.Models.Eft.Hideout;
|
||||
|
||||
namespace Core.Models.Spt.Config;
|
||||
|
||||
@@ -40,6 +41,22 @@ public record HideoutConfig : BaseConfig
|
||||
|
||||
[JsonPropertyName("cultistCircle")]
|
||||
public CultistCircleSettings CultistCircle { get; set; }
|
||||
|
||||
[JsonPropertyName("hideoutCraftsToAdd")]
|
||||
public List<HideoutCraftToAdd> HideoutCraftsToAdd { get; set; }
|
||||
}
|
||||
|
||||
public record HideoutCraftToAdd
|
||||
{
|
||||
[JsonPropertyName("requirements")]
|
||||
public List<Requirement> Requirements { get; set; }
|
||||
|
||||
[JsonPropertyName("craftIdToCopy")]
|
||||
public string CraftIdToCopy { get; set; }
|
||||
|
||||
[JsonPropertyName("craftOutputTpl")]
|
||||
public string CraftOutputTpl { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public record CultistCircleSettings
|
||||
|
||||
@@ -1,15 +1,42 @@
|
||||
using SptCommon.Annotations;
|
||||
using Core.Models.Spt.Config;
|
||||
using Core.Models.Utils;
|
||||
using Core.Servers;
|
||||
using Core.Utils;
|
||||
using Core.Utils.Cloners;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Services;
|
||||
|
||||
[Injectable(InjectionType.Singleton)]
|
||||
public class PostDbLoadService
|
||||
public class PostDbLoadService(
|
||||
ISptLogger<PostDbLoadService> _logger,
|
||||
HashUtil _hashUtil,
|
||||
DatabaseService _databaseService,
|
||||
ConfigServer _configServer,
|
||||
ICloner _cloner)
|
||||
{
|
||||
protected HideoutConfig _hideoutConfig = _configServer.GetConfig<HideoutConfig>();
|
||||
|
||||
public void PerformPostDbLoadActions()
|
||||
{
|
||||
// TODO:
|
||||
}
|
||||
|
||||
protected void CloneExistingCraftsAndAddNew()
|
||||
{
|
||||
var hideoutCraftDb = _databaseService.GetHideout().Production;
|
||||
var craftsToAdd = _hideoutConfig.HideoutCraftsToAdd;
|
||||
foreach (var craftToAdd in craftsToAdd) {
|
||||
var clonedCraft = _cloner.Clone(
|
||||
hideoutCraftDb.Recipes.FirstOrDefault((x) => x.Id == craftToAdd.CraftIdToCopy));
|
||||
clonedCraft.Id = _hashUtil.Generate();
|
||||
clonedCraft.Requirements = craftToAdd.Requirements;
|
||||
clonedCraft.EndProduct = craftToAdd.CraftOutputTpl;
|
||||
|
||||
hideoutCraftDb.Recipes.Add(clonedCraft);
|
||||
}
|
||||
}
|
||||
|
||||
protected void AdjustMinReserveRaiderSpawnChance()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
Reference in New Issue
Block a user