From 731d9f3f0b07effcb681c41bc4534343e78762a2 Mon Sep 17 00:00:00 2001 From: Dev Date: Fri, 25 Oct 2024 11:53:18 +0100 Subject: [PATCH] Added `enabled` property to events config + wire up --- project/assets/configs/seasonalevents.json | 4 ++++ .../src/models/spt/config/ISeasonalEventConfig.ts | 1 + project/src/services/SeasonalEventService.ts | 12 +++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/project/assets/configs/seasonalevents.json b/project/assets/configs/seasonalevents.json index d93d2df4..57c907c3 100644 --- a/project/assets/configs/seasonalevents.json +++ b/project/assets/configs/seasonalevents.json @@ -689,6 +689,7 @@ ], "events": [ { + "enabled": true, "name": "halloween", "type": "HALLOWEEN", "startDay": "24", @@ -697,6 +698,7 @@ "endMonth": "11" }, { + "enabled": true, "name": "christmas", "type": "CHRISTMAS", "startDay": "7", @@ -705,6 +707,7 @@ "endMonth": "12" }, { + "enabled": true, "name": "newyears", "type": "NEW_YEARS", "startDay": "1", @@ -713,6 +716,7 @@ "endMonth": "1" }, { + "enabled": true, "name": "snow", "type": "SNOW", "startDay": "8", diff --git a/project/src/models/spt/config/ISeasonalEventConfig.ts b/project/src/models/spt/config/ISeasonalEventConfig.ts index 10903d5a..2af89972 100644 --- a/project/src/models/spt/config/ISeasonalEventConfig.ts +++ b/project/src/models/spt/config/ISeasonalEventConfig.ts @@ -14,6 +14,7 @@ export interface ISeasonalEventConfig extends IBaseConfig { } export interface ISeasonalEvent { + enabled: boolean; name: string; type: SeasonalEventType; startDay: number; diff --git a/project/src/services/SeasonalEventService.ts b/project/src/services/SeasonalEventService.ts index 34395a9e..405e36af 100644 --- a/project/src/services/SeasonalEventService.ts +++ b/project/src/services/SeasonalEventService.ts @@ -196,7 +196,7 @@ export class SeasonalEventService { } /** - * Handle seasonal events + * Handle activating seasonal events */ public enableSeasonalEvents(): void { if (this.currentlyActiveEvents) { @@ -207,6 +207,9 @@ export class SeasonalEventService { } } + /** + * Store active events inside class array property `currentlyActiveEvents` + set class properties: christmasEventActive/halloweenEventActive + */ protected cacheActiveEvents(): void { const currentDate = new Date(); const seasonalEvents = this.getEventDetails(); @@ -217,6 +220,9 @@ export class SeasonalEventService { // Current date is between start/end dates if (currentDate >= eventStartDate && currentDate <= eventEndDate) { + if (!event.enabled) { + continue; + } this.currentlyActiveEvents.push(SeasonalEventType[event.type]); if (SeasonalEventType[event.type] === SeasonalEventType.CHRISTMAS) { @@ -230,6 +236,10 @@ export class SeasonalEventService { } } + /** + * Get the currently active weather season e.g. SUMMER/AUTUMN/WINTER + * @returns Season enum value + */ public getActiveWeatherSeason(): Season { if (this.weatherConfig.overrideSeason !== null) { return this.weatherConfig.overrideSeason;