Add season handling
This commit is contained in:
parent
0a0cfa39db
commit
61dbc2b1d0
@ -1,6 +1,5 @@
|
||||
{
|
||||
"acceleration": 7,
|
||||
"forceWinterEvent": false,
|
||||
"weather": {
|
||||
"clouds": {
|
||||
"values": [
|
||||
@ -100,5 +99,48 @@
|
||||
"min": 760,
|
||||
"max": 764
|
||||
}
|
||||
}
|
||||
},
|
||||
"seasonDates": [
|
||||
{
|
||||
"seasonType": 0,
|
||||
"name": "SUMMER",
|
||||
"startDay": "2",
|
||||
"startMonth": "5",
|
||||
"endDay": "1",
|
||||
"endMonth": "8"
|
||||
},
|
||||
{
|
||||
"seasonType": 1,
|
||||
"name": "AUTUMN",
|
||||
"startDay": "2",
|
||||
"startMonth": "8",
|
||||
"endDay": "1",
|
||||
"endMonth": "11"
|
||||
},
|
||||
{
|
||||
"seasonType": 2,
|
||||
"name": "WINTER",
|
||||
"startDay": "2",
|
||||
"startMonth": "11",
|
||||
"endDay": "1",
|
||||
"endMonth": "3"
|
||||
},
|
||||
{
|
||||
"seasonType": 3,
|
||||
"name": "SPRING",
|
||||
"startDay": "2",
|
||||
"startMonth": "3",
|
||||
"endDay": "1",
|
||||
"endMonth": "5"
|
||||
},
|
||||
{
|
||||
"seasonType": 4,
|
||||
"name": "STORM",
|
||||
"startDay": "24",
|
||||
"startMonth": "10",
|
||||
"endDay": "4",
|
||||
"endMonth": "11"
|
||||
},
|
||||
],
|
||||
"overrideSeason": null
|
||||
}
|
@ -5,10 +5,12 @@ import { ContextVariableType } from "@spt-aki/context/ContextVariableType";
|
||||
import { WeightedRandomHelper } from "@spt-aki/helpers/WeightedRandomHelper";
|
||||
import { IWeather, IWeatherData } from "@spt-aki/models/eft/weather/IWeatherData";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { Season } from "@spt-aki/models/enums/Season";
|
||||
import { WindDirection } from "@spt-aki/models/enums/WindDirection";
|
||||
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";
|
||||
import { SeasonalEventService } from "@spt-aki/services/SeasonalEventService";
|
||||
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
|
||||
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
||||
|
||||
@ -26,6 +28,7 @@ export class WeatherGenerator
|
||||
@inject("WinstonLogger") protected logger: ILogger,
|
||||
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
||||
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
||||
@inject("SeasonalEventService") protected seasonalEventService: SeasonalEventService,
|
||||
@inject("ApplicationContext") protected applicationContext: ApplicationContext,
|
||||
@inject("ConfigServer") protected configServer: ConfigServer,
|
||||
)
|
||||
@ -47,6 +50,10 @@ export class WeatherGenerator
|
||||
data.time = this.getBsgFormattedInRaidTime();
|
||||
data.acceleration = this.weatherConfig.acceleration;
|
||||
|
||||
data.season = this.weatherConfig.overrideSeason
|
||||
? this.weatherConfig.overrideSeason
|
||||
: this.seasonalEventService.getActiveWeatherSeason();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ export class SptDialogueChatBot implements IDialogueChatBot
|
||||
|
||||
if (request.text.toLowerCase() === "itsonlysnowalan")
|
||||
{
|
||||
this.weatherConfig.season = Season.WINTER;
|
||||
this.weatherConfig.overrideSeason = Season.WINTER;
|
||||
|
||||
this.mailSendService.sendUserMessageToPlayer(
|
||||
sessionId,
|
||||
|
@ -6,8 +6,8 @@ export interface IWeatherData
|
||||
acceleration: number;
|
||||
time: string;
|
||||
date: string;
|
||||
weather?: IWeather;
|
||||
season?: Season;
|
||||
weather: IWeather;
|
||||
season: Season;
|
||||
}
|
||||
|
||||
export interface IWeather
|
||||
|
@ -8,7 +8,18 @@ export interface IWeatherConfig extends IBaseConfig
|
||||
kind: "aki-weather";
|
||||
acceleration: number;
|
||||
weather: Weather;
|
||||
season: Season;
|
||||
seasonDates: ISeasonDateTimes[];
|
||||
overrideSeason?: Season;
|
||||
}
|
||||
|
||||
export interface ISeasonDateTimes
|
||||
{
|
||||
seasonType: Season;
|
||||
name: string;
|
||||
startDay: number;
|
||||
startMonth: number;
|
||||
endDay: number;
|
||||
endMonth: number;
|
||||
}
|
||||
|
||||
export interface Weather
|
||||
|
@ -259,6 +259,31 @@ export class SeasonalEventService
|
||||
}
|
||||
}
|
||||
|
||||
public getActiveWeatherSeason(): Season
|
||||
{
|
||||
const currentDate = new Date();
|
||||
for (const seasonRange of this.weatherConfig.seasonDates)
|
||||
{
|
||||
// Figure out start and end dates to get range of season
|
||||
const eventStartDate = new Date(
|
||||
currentDate.getFullYear(),
|
||||
seasonRange.startMonth - 1, // Month value starts at 0
|
||||
seasonRange.startDay,
|
||||
);
|
||||
const eventEndDate = new Date(currentDate.getFullYear(), seasonRange.endMonth - 1, seasonRange.endDay);
|
||||
|
||||
// Does todays date fit inside the above range
|
||||
if (currentDate >= eventStartDate && currentDate <= eventEndDate)
|
||||
{
|
||||
return seasonRange.seasonType;
|
||||
}
|
||||
}
|
||||
|
||||
this.logger.warning("Unable to find a season using current date, defaulting to Summer");
|
||||
|
||||
return Season.SUMMER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through bots inventory and loot to find and remove christmas items (as defined in SeasonalEventService)
|
||||
* @param botInventory Bots inventory to iterate over
|
||||
@ -598,6 +623,6 @@ export class SeasonalEventService
|
||||
|
||||
public enableSnow(): void
|
||||
{
|
||||
this.weatherConfig.season = Season.WINTER;
|
||||
this.weatherConfig.overrideSeason = Season.WINTER;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user