2023-03-03 16:23:46 +01:00
|
|
|
import { inject, injectable } from "tsyringe";
|
|
|
|
|
2023-10-19 19:21:17 +02:00
|
|
|
import { WeatherGenerator } from "@spt-aki/generators/WeatherGenerator";
|
|
|
|
import { IWeatherData } from "@spt-aki/models/eft/weather/IWeatherData";
|
|
|
|
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
|
|
|
import { IWeatherConfig } from "@spt-aki/models/spt/config/IWeatherConfig";
|
|
|
|
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
|
|
|
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
@injectable()
|
|
|
|
export class WeatherController
|
|
|
|
{
|
|
|
|
protected weatherConfig: IWeatherConfig;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
@inject("WeatherGenerator") protected weatherGenerator: WeatherGenerator,
|
|
|
|
@inject("WinstonLogger") protected logger: ILogger,
|
2023-11-16 22:42:06 +01:00
|
|
|
@inject("ConfigServer") protected configServer: ConfigServer,
|
2023-03-03 16:23:46 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
this.weatherConfig = this.configServer.getConfig(ConfigTypes.WEATHER);
|
|
|
|
}
|
|
|
|
|
2023-07-15 15:49:25 +02:00
|
|
|
/** Handle client/weather */
|
2023-03-03 16:23:46 +01:00
|
|
|
public generate(): IWeatherData
|
|
|
|
{
|
2023-11-16 22:42:06 +01:00
|
|
|
let result: IWeatherData = { acceleration: 0, time: "", date: "", weather: null };
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
result = this.weatherGenerator.calculateGameTime(result);
|
|
|
|
result.weather = this.weatherGenerator.generateWeather();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current in-raid time (MUST HAVE PLAYER LOGGED INTO CLIENT TO WORK)
|
|
|
|
* @returns Date object
|
|
|
|
*/
|
|
|
|
public getCurrentInRaidTime(): Date
|
|
|
|
{
|
|
|
|
return this.weatherGenerator.getInRaidTime(new Date());
|
|
|
|
}
|
2023-11-16 22:42:06 +01:00
|
|
|
}
|