minor fixes

This commit is contained in:
Sebastian Bularca
2026-05-08 01:13:30 +02:00
parent 0ab806d281
commit e7f7da985b
2 changed files with 96 additions and 23 deletions

View File

@@ -8,9 +8,9 @@ using Nox.Core;
using Nox.Platform;
using Nox.Game.UI;
using Nox.UI;
using ZLinq;
using UnityEngine;
using UnityEngine.AddressableAssets;
using ZLinq;
using PlayMode = Nox.Core.PlayMode;
namespace Nox.Game {
@@ -84,27 +84,10 @@ namespace Nox.Game {
inputActions.UI.PauseMenu.Enable();
Debug.Log("Entering Adventure Play Mode");
if(partyDefinition == null) {
var sessions = saveSystem.GetAllSessions().AsValueEnumerable().OrderByDescending(s => s.lastSaveDateUtc).ToList();
if(sessions.Count == 0) {
return;
var restoreResult = NoxSaveData.RestoreSavedData(saveSystem, gameDataState, ref adventureData);
if(restoreResult == null) {
Debug.LogError("AdventurePlayMode: no save data found for auto-recovery. Party will be null.");
}
var latestSession = sessions[0];
var slots = saveSystem.GetSlots(latestSession.sessionId).AsValueEnumerable().OrderByDescending(s => s.timestampUtc).ToList();
if(slots.Count == 0) {
return;
}
var latestSlot = slots[0];
var saveData = saveSystem.Load<NoxSaveData>(latestSlot);
Debug.Log($"Loaded save {latestSlot.DisplayLabel}");
if(saveData == null) {
Debug.LogError("Failed to load save data");
return;
}
NoxSaveData.RestoreSavedData(saveSystem, gameDataState, ref adventureData);
Debug.LogWarning("AdventurePlayMode started from the Adventure Scene. Loading the last Autosave");
}
encounterRegistry ??= Addressables.LoadAssetAsync<EncounterRegistry>("EncounterRegistry").WaitForCompletion();
@@ -171,7 +154,7 @@ namespace Nox.Game {
}
public void Tick() {
if(!IsGameModeInitialized) {
if(!IsGameModeInitialized || gameDataState.ActiveParty == null) {
return;
}
@@ -197,7 +180,8 @@ namespace Nox.Game {
return new NoxSavedDataSet {
activePlayMode = PlayMode.Adventure,
activeParty = partyDefinition,
partyPosition = partyRef ? SerializableVector3.FromVector3(partyRef.transform.position) : SerializableVector3.Zero
partyPosition = partyRef ? SerializableVector3.FromVector3(partyRef.transform.position) : SerializableVector3.Zero,
adventureData = this.adventureData
};
}
@@ -205,7 +189,15 @@ namespace Nox.Game {
inputActions.Player.Disable();
inputActions.UI.PauseMenu.Disable();
}
public void Dispose() {
encounterRegistry = null;
scenePrefabs = null;
mapRef = null;
partyRef = null;
mapLocationsReference = null;
guiReferences = null;
partyGuiView?.Dispose();
popupSystem?.Dispose();