added in-game logger

This commit is contained in:
Sebastian Bularca
2026-04-05 12:32:42 +02:00
parent 1ec734d033
commit fa15608f3a
43 changed files with 3019 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ using Nox.Game.UI;
using Nox.Input;
using Nox.Platform;
using Jovian.SaveSystem;
using Jovian.InGameLogging;
using Nox.EditorCode;
using Unity.Profiling;
using UnityEngine;
@@ -24,6 +25,7 @@ namespace Nox.Core {
private ProfilerMarker createApplicationStateMarker = new ProfilerMarker("createApplicationState");
private ISceneTransition sceneTransition;
private ISaveSystem saveSystem;
private IGameLogStore gameLogStore;
private InitializerSettingsFile initializerSettings;
private BootstrapReferences bootstrapReferences;
@@ -98,6 +100,8 @@ namespace Nox.Core {
ISaveSlotManager saveSlotManager = new SaveSlotManager(saveStorage, saveSettings);
saveSystem = new SaveSystem(saveSerializer, saveStorage, saveSlotManager, saveSettings);
gameLogStore = new GameLogStore(500);
var adventureData = new AdventureData();
var characterBaseSettings = Addressables.LoadAssetAsync<StarterCharacterSettings>("CharacterBaseSettings").WaitForCompletion();
@@ -111,8 +115,8 @@ namespace Nox.Core {
applicationStates = new Dictionary<GameState, IGameState> {
[GameState.BootState] = new SplashGameState(bootstrapReferences, gameDataState),
[GameState.MainMenu] = new MainMenuGameState(gameDataState, menuGameStateData, bootstrapReferences, saveSystem, partyCreatorModel, adventureData),
[GameState.GameMode] = new GameModeGameState(gameDataState, bootstrapReferences, platform.PlatformSettings, saveSystem, sceneTransition, adventureData),
[GameState.MainMenu] = new MainMenuGameState(gameDataState, menuGameStateData, bootstrapReferences, saveSystem, partyCreatorModel, adventureData, gameLogStore),
[GameState.GameMode] = new GameModeGameState(gameDataState, bootstrapReferences, platform.PlatformSettings, saveSystem, sceneTransition, adventureData, gameLogStore),
};
createApplicationStateMarker.End();
}

View File

@@ -3,6 +3,7 @@ using Nox.Game;
using Nox.Platform;
using Nox.Game.UI;
using Jovian.SaveSystem;
using Jovian.InGameLogging;
using System.Collections.Generic;
using ZLinq;
using UnityEngine;
@@ -21,6 +22,7 @@ namespace Nox.Core {
private readonly ISaveSystem saveSystem;
private readonly ISceneTransition sceneTransition;
private readonly AdventureData adventuredata;
private readonly IGameLogStore gameLogStore;
private readonly Dictionary<PlayMode, IPlayMode?> playModeCache = new();
@@ -43,12 +45,14 @@ namespace Nox.Core {
PlatformSettings platformSettings,
ISaveSystem saveSystem,
ISceneTransition sceneTransition,
AdventureData adventuredata) {
AdventureData adventuredata,
IGameLogStore gameLogStore) {
this.gameDataState = gameDataState;
this.platformSettings = platformSettings;
this.saveSystem = saveSystem;
this.sceneTransition = sceneTransition;
this.adventuredata = adventuredata;
this.gameLogStore = gameLogStore;
bootstrapSettings = Addressables.LoadAssetAsync<PlayModeSettings>(bootstrapReferences.playModeSettings).WaitForCompletion();
}
@@ -75,7 +79,11 @@ namespace Nox.Core {
private NoxSavedDataSet? CaptureNoxSaveData() {
var adventure = FindAdventurePlayMode();
return adventure?.CaptureNoxSaveData();
var saveData = adventure?.CaptureNoxSaveData();
if(saveData != null) {
saveData.gameLogData = gameLogStore.GetSaveData();
}
return saveData;
}
private AdventurePlayMode? FindAdventurePlayMode() {

View File

@@ -1,5 +1,6 @@
using Nox.Game;
using Jovian.SaveSystem;
using Jovian.InGameLogging;
using Nox.UI;
using System;
using System.Threading.Tasks;
@@ -21,6 +22,7 @@ namespace Nox.Core {
private readonly BootstrapReferences bootstrapReferences;
private readonly ISaveSystem saveSystem;
private readonly PartyCreatorModel partyCreatorModel;
private readonly IGameLogStore gameLogStore;
private AdventureData adventureData;
private Action<PlayMode> onStartGameRequested;
private Action onContinueRequested;
@@ -33,13 +35,15 @@ namespace Nox.Core {
BootstrapReferences bootstrapReferences,
ISaveSystem saveSystem,
PartyCreatorModel partyCreatorModel,
AdventureData adventureData) {
AdventureData adventureData,
IGameLogStore gameLogStore) {
this.gameDataState = gameDataState;
this.menuGameStateData = menuGameStateData;
this.bootstrapReferences = bootstrapReferences;
this.saveSystem = saveSystem;
this.partyCreatorModel = partyCreatorModel;
this.adventureData = adventureData;
this.gameLogStore = gameLogStore;
}
public void EnterGameState() {
@@ -56,7 +60,7 @@ namespace Nox.Core {
gameDataState.ChangePlayMode(mode);
};
onContinueRequested = () => {
var saveData = NoxSaveData.RestoreSavedData(saveSystem, gameDataState, ref adventureData);
var saveData = NoxSaveData.RestoreSavedData(saveSystem, gameDataState, ref adventureData, gameLogStore);
if(saveData == null) {
return;
}

View File

@@ -1,4 +1,5 @@
using Jovian.SaveSystem;
using Jovian.InGameLogging;
using Nox.Core;
using System;
using ZLinq;
@@ -11,7 +12,8 @@ namespace Nox.Game {
public static NoxSavedDataSet RestoreSavedData(
ISaveSystem saveSystem,
GameDataState gameDataState,
ref AdventureData adventureData) {
ref AdventureData adventureData,
IGameLogStore gameLogStore = null) {
var sessions = saveSystem.GetAllSessions().AsValueEnumerable().OrderByDescending(s => s.lastSaveDateUtc).ToList();
if(sessions.Count == 0) {
return null;
@@ -36,6 +38,10 @@ namespace Nox.Game {
gameDataState.ActiveParty = saveData.partyDefinition;
adventureData = saveData.adventureData;
if(gameLogStore != null && saveData.gameLogData != null) {
gameLogStore.RestoreFromSaveData(saveData.gameLogData);
}
return saveData;
}
}
@@ -55,6 +61,9 @@ namespace Nox.Game {
// Party
public PartyDefinition partyDefinition;
public SerializableVector3 partyPosition;
// In-game log
public GameLogSaveData gameLogData;
}
/// <summary>