-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at custom pmc wave service - basic waves for factory day only
- Loading branch information
Chomp
committed
Feb 16, 2025
1 parent
2a54cbe
commit a358e3b
Showing
5 changed files
with
151 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { IBossLocationSpawn, ILocationBase, IWave } from "@spt/models/eft/common/ILocationBase"; | ||
import { ConfigTypes } from "@spt/models/enums/ConfigTypes"; | ||
import { ILocationConfig } from "@spt/models/spt/config/ILocationConfig"; | ||
import { IPmcConfig } from "@spt/models/spt/config/IPmcConfig"; | ||
import type { ILogger } from "@spt/models/spt/utils/ILogger"; | ||
import { ConfigServer } from "@spt/servers/ConfigServer"; | ||
import { DatabaseService } from "@spt/services/DatabaseService"; | ||
import { RandomUtil } from "@spt/utils/RandomUtil"; | ||
import { inject, injectable } from "tsyringe"; | ||
|
||
@injectable() | ||
export class PmcWaveGenerator { | ||
protected pmcConfig: IPmcConfig; | ||
|
||
constructor( | ||
@inject("PrimaryLogger") protected logger: ILogger, | ||
@inject("RandomUtil") protected randomUtil: RandomUtil, | ||
@inject("DatabaseService") protected databaseService: DatabaseService, | ||
@inject("ConfigServer") protected configServer: ConfigServer, | ||
) { | ||
this.pmcConfig = this.configServer.getConfig(ConfigTypes.PMC); | ||
} | ||
|
||
/** | ||
* Add a pmc wave to a map | ||
* @param locationId e.g. factory4_day, bigmap | ||
* @param waveToAdd Boss wave to add to map | ||
*/ | ||
public AddPmcWaveToLocation(locationId: string, waveToAdd: IBossLocationSpawn): void { | ||
this.pmcConfig.customPmcWaves[locationId].push(waveToAdd); | ||
} | ||
|
||
/** | ||
* Add custom boss and normal waves to maps found in config/location.json to db | ||
*/ | ||
public applyWaveChangesToAllMaps(): void { | ||
for (const location of Object.keys(this.pmcConfig.customPmcWaves)) { | ||
const data = this.pmcConfig.customPmcWaves[location]; | ||
|
||
this.applyWaveChangesToMapByName(location); | ||
} | ||
} | ||
|
||
public applyWaveChangesToMapByName(name: string): void { | ||
const pmcWavesToAdd = this.pmcConfig.customPmcWaves[name]; | ||
if (!pmcWavesToAdd) { | ||
return; | ||
} | ||
|
||
const location = this.databaseService.getLocation(name); | ||
if (!location) { | ||
return; | ||
} | ||
|
||
location.base.BossLocationSpawn.push(...pmcWavesToAdd); | ||
} | ||
|
||
public applyWaveChangesToMap(location: ILocationBase): void { | ||
const pmcWavesToAdd = this.pmcConfig.customPmcWaves[location.Id.toLowerCase()]; | ||
if (!pmcWavesToAdd) { | ||
return; | ||
} | ||
|
||
location.BossLocationSpawn.push(...pmcWavesToAdd); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters