using SPTarkov.DI.Annotations; using SPTarkov.Server.Core.Models.Eft.Common; using SPTarkov.Server.Core.Models.Spt.Config; using SPTarkov.Server.Core.Servers; using SPTarkov.Server.Core.Services; namespace SPTarkov.Server.Core.Generators; [Injectable] public class PmcWaveGenerator(DatabaseService databaseService, ConfigServer configServer) { protected readonly PmcConfig _pmcConfig = configServer.GetConfig(); /// /// Add a pmc wave to a map /// /// e.g. factory4_day, bigmap /// Boss wave to add to map public void AddPmcWaveToLocation(string locationId, BossLocationSpawn waveToAdd) { _pmcConfig.CustomPmcWaves[locationId].Add(waveToAdd); } /// /// Add custom boss and normal waves to all maps found in config/location.json to db /// public void ApplyWaveChangesToAllMaps() { foreach (var location in _pmcConfig.CustomPmcWaves) { ApplyWaveChangesToMapByName(location.Key); } } /// /// Add custom boss and normal waves to a map found in config/location.json to db by name /// /// e.g. factory4_day, bigmap public void ApplyWaveChangesToMapByName(string name) { if (!_pmcConfig.CustomPmcWaves.TryGetValue(name, out var pmcWavesToAdd)) { return; } var location = databaseService.GetLocation(name); location?.Base.BossLocationSpawn.AddRange(pmcWavesToAdd); } /// /// Add custom boss and normal waves to a map found in config/location.json to db by LocationBase /// /// Location Object public void ApplyWaveChangesToMap(LocationBase location) { if (!_pmcConfig.CustomPmcWaves.TryGetValue(location.Id.ToLowerInvariant(), out var pmcWavesToAdd)) { return; } location.BossLocationSpawn.AddRange(pmcWavesToAdd); } }