Server/project/src/controllers/WeatherController.ts
TheSparta 418d9f2a8f Import path alias on the whole project (!157)
- Ability to use @spt-aki path alias on the whole project.
- Swapped all imports from relative paths, for imports using the path alias.

Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/157
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
2023-10-19 17:21:17 +00:00

48 lines
1.5 KiB
TypeScript

import { inject, injectable } from "tsyringe";
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";
@injectable()
export class WeatherController
{
protected weatherConfig: IWeatherConfig;
constructor(
@inject("WeatherGenerator") protected weatherGenerator: WeatherGenerator,
@inject("WinstonLogger") protected logger: ILogger,
@inject("ConfigServer") protected configServer: ConfigServer
)
{
this.weatherConfig = this.configServer.getConfig(ConfigTypes.WEATHER);
}
/** Handle client/weather */
public generate(): IWeatherData
{
let result: IWeatherData = {
acceleration: 0,
time: "",
date: "",
weather: null
};
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());
}
}