made some improvements on how the encounters trigger
This commit is contained in:
@@ -10,6 +10,7 @@ using Nox.Platform;
|
||||
using Nox.Game.UI;
|
||||
using Nox.UI;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using ZLinq;
|
||||
@@ -25,7 +26,9 @@ namespace Nox.Game {
|
||||
public int suppliesAvailable = -1;
|
||||
public float currentTime = -1f;
|
||||
public DayPhase currentDayPhase = DayPhase.Morning;
|
||||
public List<string> completedEncounterIds = new List<string>();
|
||||
public List<string> completedEncounterIds = new ();
|
||||
public List<string> abandonedEncounterIds = new ();
|
||||
public List<QuestLogEntry> questLogEntries = new ();
|
||||
}
|
||||
|
||||
public class AdventurePlayMode : IPlayMode {
|
||||
@@ -85,6 +88,9 @@ namespace Nox.Game {
|
||||
.WaitForCompletion().ActivateAsync().completed += InitializeGameMode;
|
||||
}
|
||||
|
||||
private QuestProgress questProgress;
|
||||
private QuestLog questLog;
|
||||
|
||||
private void InitializeGameMode(AsyncOperation obj) {
|
||||
inputActions.Player.Enable();
|
||||
inputActions.UI.PauseMenu.Enable();
|
||||
@@ -118,18 +124,29 @@ namespace Nox.Game {
|
||||
adventureData.currentTime = 0.25f;
|
||||
}
|
||||
|
||||
var collection = encounterRegistry.encounterCollections?.FirstOrDefault(c => c?.encounterTables != null);
|
||||
if(collection != null) {
|
||||
questProgress = new QuestProgress(collection);
|
||||
questLog = new QuestLog(questProgress);
|
||||
if(adventureData.questLogEntries.Count > 0) {
|
||||
questLog.Restore(adventureData.questLogEntries);
|
||||
questProgress.LoadResolvedIds(questLog.ResolvedEncounterIds());
|
||||
}
|
||||
}
|
||||
|
||||
partyInventoryHandler ??= new PartyInventoryHandler(adventureData, adventureSettings);
|
||||
partyInventoryHandler.Initialize();
|
||||
|
||||
var calendarSettings = Addressables.LoadAssetAsync<CalendarSettings>("CalendarSettings").WaitForCompletion();
|
||||
var calendarSettings = Addressables.LoadAssetAsync<CalendarSettings>("CalendarSettings").WaitForCompletion();
|
||||
var worldClock = new WorldClock(calendarSettings);
|
||||
var totalMinutes = adventureData.currentDay * calendarSettings.MinutesPerDay
|
||||
+ (int)(adventureData.currentTime * calendarSettings.MinutesPerDay);
|
||||
worldClock.AdvanceMinutes(totalMinutes);
|
||||
worldClock.Tick(adventureData.currentTime);
|
||||
timeHandler ??= new TimeHandler(adventureSettings, adventureData, worldClock);
|
||||
|
||||
zoneSystem ??= new ZoneSystem(mapRef.zonesObjectHolder);
|
||||
encounterHandler = new EncounterHandler(zoneSystem, encounterRegistry, encounterPrefabs, adventureData);
|
||||
encounterHandler = new EncounterHandler(zoneSystem, encounterRegistry, encounterPrefabs, adventureData, questProgress);
|
||||
partyMovementHandler ??= new PartyMovementHandler(
|
||||
partyRef,
|
||||
cameraController,
|
||||
@@ -190,7 +207,8 @@ namespace Nox.Game {
|
||||
activePlayMode = PlayMode.Adventure,
|
||||
activeParty = partyDefinition,
|
||||
partyPosition = partyRef ? SerializableVector3.FromVector3(partyRef.transform.position) : SerializableVector3.Zero,
|
||||
adventureData = this.adventureData
|
||||
adventureData = this.adventureData,
|
||||
questLogEntries = questLog?.CreateSnapshot() ?? new List<QuestLogEntry>()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user