forked from Shardstone/trail-into-darkness
minor fixes
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user