Added getLocation()
to databaseService
and made use of it across various classes
This commit is contained in:
parent
c710169e3d
commit
584eade530
@ -357,7 +357,7 @@ export class GameController
|
||||
continue;
|
||||
}
|
||||
|
||||
const mapLooseLoot: ILooseLoot = this.databaseService.getLocations()[mapId]?.looseLoot;
|
||||
const mapLooseLoot: ILooseLoot = this.databaseService.getLocation(mapId).looseLoot;
|
||||
if (!mapLooseLoot)
|
||||
{
|
||||
this.logger.warning(this.localisationService.getText("location-map_has_no_loose_loot_data", mapId));
|
||||
@ -392,7 +392,7 @@ export class GameController
|
||||
const adjustments = this.lootConfig.looseLootSpawnPointAdjustments;
|
||||
for (const mapId in adjustments)
|
||||
{
|
||||
const mapLooseLootData: ILooseLoot = this.databaseService.getLocations()[mapId]?.looseLoot;
|
||||
const mapLooseLootData: ILooseLoot = this.databaseService.getLocation(mapId).looseLoot;
|
||||
if (!mapLooseLootData)
|
||||
{
|
||||
this.logger.warning(this.localisationService.getText("location-map_has_no_loose_loot_data", mapId));
|
||||
|
@ -153,7 +153,7 @@ export class InraidController
|
||||
|
||||
const locationName = serverProfile.inraid.location.toLowerCase();
|
||||
|
||||
const map: ILocationBase = this.databaseService.getLocations()[locationName].base;
|
||||
const map: ILocationBase = this.databaseService.getLocation(locationName).base;
|
||||
|
||||
const serverPmcProfile = serverProfile.characters.pmc;
|
||||
const serverScavProfile = serverProfile.characters.scav;
|
||||
|
@ -591,7 +591,7 @@ export class InsuranceController
|
||||
// Map is labs + insurance is disabled in base.json
|
||||
if (
|
||||
insurance.systemData?.location?.toLowerCase() === labsId
|
||||
&& !(this.databaseServer.getLocations()[labsId].base.Insurance)
|
||||
&& !(this.databaseServer.getLocation(labsId).base.Insurance)
|
||||
)
|
||||
{
|
||||
// Trader has labs-specific messages
|
||||
|
@ -78,7 +78,7 @@ export class LocationController
|
||||
*/
|
||||
protected generate(name: string): ILocationBase
|
||||
{
|
||||
const location: ILocation = this.databaseService.getLocations()[name];
|
||||
const location: ILocation = this.databaseService.getLocation(name);
|
||||
const locationBaseClone: ILocationBase = this.cloner.clone(location.base);
|
||||
|
||||
// Update datetime property to now
|
||||
|
@ -394,7 +394,7 @@ export class RepeatableQuestController
|
||||
return true;
|
||||
}
|
||||
|
||||
const locationBase: ILocationBase = this.databaseService.getLocations()[location.toLowerCase()]?.base;
|
||||
const locationBase: ILocationBase = this.databaseService.getLocation(location.toLowerCase()).base;
|
||||
if (!locationBase)
|
||||
{
|
||||
return true;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { inject, injectable } from "tsyringe";
|
||||
import { IGlobals } from "@spt/models/eft/common/IGlobals";
|
||||
import { ILocation } from "@spt/models/eft/common/ILocation";
|
||||
import { IAchievement } from "@spt/models/eft/common/tables/IAchievement";
|
||||
import { ICustomizationItem } from "@spt/models/eft/common/tables/ICustomizationItem";
|
||||
import { IHandbookBase } from "@spt/models/eft/common/tables/IHandbookBase";
|
||||
@ -107,6 +108,23 @@ export class DatabaseService
|
||||
return this.databaseServer.getTables().locations!;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific location by its Id
|
||||
* @param locationId Desired trader id
|
||||
* @returns assets/database/locations/
|
||||
*/
|
||||
public getLocation(locationId: string): ILocation
|
||||
{
|
||||
const locations = this.getLocations();
|
||||
const desiredLocation = locations[locationId];
|
||||
if (!desiredLocation)
|
||||
{
|
||||
throw new Error(this.localisationService.getText("database-no_location_found_with_id", locationId));
|
||||
}
|
||||
|
||||
return desiredLocation!;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns assets/database/match/
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user