diff --git a/Assets/Code/GameState/PlayModes/AdventurePlayMode.cs b/Assets/Code/GameState/PlayModes/AdventurePlayMode.cs index 5512628..d87d99d 100644 --- a/Assets/Code/GameState/PlayModes/AdventurePlayMode.cs +++ b/Assets/Code/GameState/PlayModes/AdventurePlayMode.cs @@ -26,9 +26,9 @@ namespace Nox.Game { public int suppliesAvailable = -1; public float currentTime = -1f; public DayPhase currentDayPhase = DayPhase.Morning; - public List completedEncounterIds = new (); - public List abandonedEncounterIds = new (); - public List questLogEntries = new (); + public List completedEncounterIds = new(); + public List abandonedEncounterIds = new(); + public List questLogEntries = new(); } public class AdventurePlayMode : IPlayMode { @@ -137,13 +137,9 @@ namespace Nox.Game { partyInventoryHandler ??= new PartyInventoryHandler(adventureData, adventureSettings); partyInventoryHandler.Initialize(); - var calendarSettings = Addressables.LoadAssetAsync("CalendarSettings").WaitForCompletion(); + var calendarSettings = Addressables.LoadAssetAsync("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); + timeHandler ??= new TimeHandler(adventureSettings, adventureData, worldClock, calendarSettings); zoneSystem ??= new ZoneSystem(mapRef.zonesObjectHolder); encounterHandler = new EncounterHandler(zoneSystem, encounterRegistry, encounterPrefabs, adventureData, questProgress); @@ -169,7 +165,7 @@ namespace Nox.Game { var popupViewPrefab = Addressables.LoadAssetAsync("PopupReferencePrefab").WaitForCompletion().GetComponent(); var guiCanvas = guiReferences.GetComponentInParent().transform; popupSystem = new PopupSystem(popupSettings, popupViewPrefab, guiCanvas); - popupSystem.RegisterCategory(PopupCategory.Character, priority: 10); + popupSystem.RegisterCategory(PopupCategory.Character, 10); } partyGuiView = new PartyGuiView(guiReferences.portraitsContainer, guiReferences.partyMemberSlotPrefab, portraitsHolder, popupSystem); @@ -207,7 +203,7 @@ namespace Nox.Game { activePlayMode = PlayMode.Adventure, activeParty = partyDefinition, partyPosition = partyRef ? SerializableVector3.FromVector3(partyRef.transform.position) : SerializableVector3.Zero, - adventureData = this.adventureData, + adventureData = adventureData, questLogEntries = questLog?.CreateSnapshot() ?? new List() }; } diff --git a/Assets/Code/GameState/PlayModes/TimeHandler.cs b/Assets/Code/GameState/PlayModes/TimeHandler.cs index 9f3e535..b6fb87f 100644 --- a/Assets/Code/GameState/PlayModes/TimeHandler.cs +++ b/Assets/Code/GameState/PlayModes/TimeHandler.cs @@ -28,10 +28,14 @@ namespace Nox.Game { (0.90f, DayPhase.Night) }; - public TimeHandler(AdventureSettings adventureSettings, AdventureData adventureData, WorldClock worldClock) { + public TimeHandler(AdventureSettings adventureSettings, AdventureData adventureData, WorldClock worldClock, CalendarSettings calendarSettings) { this.adventureSettings = adventureSettings; this.adventureData = adventureData; this.worldClock = worldClock; + // restore time from saved data + var totalMinutes = (adventureData.currentDay * calendarSettings.MinutesPerDay) + + (int)(adventureData.currentTime * calendarSettings.MinutesPerDay); + worldClock.AdvanceMinutes(totalMinutes); localTime = adventureData.currentTime * adventureSettings.dayLength; }