implement localweather for pve mode
This commit is contained in:
parent
79612a6c85
commit
83a35cbc8c
@ -4,6 +4,7 @@ import { IEmptyRequestData } from "@spt/models/eft/common/IEmptyRequestData";
|
||||
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
|
||||
import { IWeatherData } from "@spt/models/eft/weather/IWeatherData";
|
||||
import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
|
||||
import { IGetLocalWeatherResponseData } from "@spt/models/spt/weather/IGetLocalWeatherResponseData";
|
||||
|
||||
@injectable()
|
||||
export class WeatherCallbacks
|
||||
@ -22,4 +23,9 @@ export class WeatherCallbacks
|
||||
{
|
||||
return this.httpResponse.getBody(this.weatherController.generate());
|
||||
}
|
||||
|
||||
public getLocalWeather(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IGetLocalWeatherResponseData>
|
||||
{
|
||||
return this.httpResponse.getBody(this.weatherController.generateLocal(sessionID));
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||
import { IWeatherConfig } from "@spt/models/spt/config/IWeatherConfig";
|
||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||
import { IGetLocalWeatherResponseData } from "@spt/models/spt/weather/IGetLocalWeatherResponseData";
|
||||
import { SeasonalEventService } from "@spt/services/SeasonalEventService";
|
||||
|
||||
@injectable()
|
||||
export class WeatherController
|
||||
@ -15,6 +17,7 @@ export class WeatherController
|
||||
@inject("WeatherGenerator") protected weatherGenerator: WeatherGenerator,
|
||||
@inject("PrimaryLogger") protected logger: ILogger,
|
||||
@inject("ConfigServer") protected configServer: ConfigServer,
|
||||
@inject("SeasonalEventService") protected seasonalEventService: SeasonalEventService,
|
||||
)
|
||||
{
|
||||
this.weatherConfig = this.configServer.getConfig(ConfigTypes.WEATHER);
|
||||
@ -39,4 +42,13 @@ export class WeatherController
|
||||
{
|
||||
return this.weatherGenerator.getInRaidTime();
|
||||
}
|
||||
|
||||
public generateLocal(sesssionID: string): IGetLocalWeatherResponseData
|
||||
{
|
||||
let result: IGetLocalWeatherResponseData = { season: this.seasonalEventService.getActiveWeatherSeason(), weather: [] };
|
||||
|
||||
result.weather.push(this.weatherGenerator.generateWeather());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
import { IWeather } from "@spt/models/eft/weather/IWeatherData";
|
||||
|
||||
export interface IGetLocalWeatherResponseData
|
||||
{
|
||||
season: number;
|
||||
weather: IWeather[];
|
||||
}
|
@ -3,6 +3,7 @@ import { WeatherCallbacks } from "@spt/callbacks/WeatherCallbacks";
|
||||
import { RouteAction, StaticRouter } from "@spt/di/Router";
|
||||
import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData";
|
||||
import { IWeatherData } from "@spt/models/eft/weather/IWeatherData";
|
||||
import { IGetLocalWeatherResponseData } from "@spt/models/spt/weather/IGetLocalWeatherResponseData";
|
||||
|
||||
@injectable()
|
||||
export class WeatherStaticRouter extends StaticRouter
|
||||
@ -22,6 +23,19 @@ export class WeatherStaticRouter extends StaticRouter
|
||||
return this.weatherCallbacks.getWeather(url, info, sessionID);
|
||||
},
|
||||
),
|
||||
|
||||
new RouteAction(
|
||||
"/client/localGame/weather",
|
||||
async (
|
||||
url: string,
|
||||
info: any,
|
||||
sessionID: string,
|
||||
_output: string
|
||||
): Promise<IGetBodyResponseData<IGetLocalWeatherResponseData>> =>
|
||||
{
|
||||
return this.weatherCallbacks.getLocalWeather(url, info, sessionID);
|
||||
},
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user