Skip to content

Commit

Permalink
0.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniMacaroni committed Oct 21, 2023
1 parent 6810715 commit b0e1bb5
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- Added `gotopickup` command to quickly go to a pickup location (useful for finding story items)
- Added `dump` command to dump various data (like `dump items` for a list of all items)
- Added `dump` command to dump various data. See https://tonimacaroni.github.io/RedLoader/articles/loader-features.html
- Fix settings getting combined when exiting via escape key
- Fix boot.txt not being able to execute custom registered commands
- Added easier control over generated settings screens
Expand Down
4 changes: 2 additions & 2 deletions Dependencies/SupportModules/Il2Cpp/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ private static ISupportModule_To Initialize(ISupportModule_From interface_from)
if (LaunchOptions.Console.CleanUnityLogs)
ConsoleCleaner();

HarmonyExceptionFix.Install();

SceneHandler.Init();

MonoEnumeratorWrapper.Register();
Expand All @@ -51,6 +49,8 @@ private static ISupportModule_To Initialize(ISupportModule_From interface_from)
Interface.SetInteropSupportInterface(Interop);
//HarmonyLib.Public.Patching.PatchManager.ResolvePatcher += HarmonyMethodPatcher.TryResolve;
runtime.Start();

HarmonyExceptionFix.Install();

return new SupportModule_To();
}
Expand Down
Binary file modified Resources/redlogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 17 additions & 1 deletion SonsGameManager/DebugCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
using Sons.Characters;
using Sons.Construction.GRABS;
using Sons.Gameplay;
using Sons.Gameplay.GameSetup;
using Sons.Items.Core;
using Sons.Lodding;
using Sons.PostProcessing;
using Sons.Prefabs;
using Sons.Save;
using SonsSdk;
using SonsSdk.Attributes;
using TheForest;
Expand Down Expand Up @@ -125,7 +128,7 @@ private void GoToPickup(string args)
}

/// <summary>
/// Dump various data from the game. dump [items, characters]
/// Dump various data from the game. dump [items, characters, prefabs]
/// </summary>
/// <param name="args"></param>
/// <command>dump</command>
Expand Down Expand Up @@ -153,11 +156,24 @@ private void DumpCommand(string args)
}
}

break;
case "prefabs":
foreach (var def in PrefabManager._instance._definitions)
{
writer.AppendLine($"{def._id}");
}

break;
}

File.WriteAllText($"{args}.txt", writer.ToString());
}

[DebugCommand("getsaveid")]
private void GetSaveIdCommand(string args)
{
RLog.Msg(SysColor.Orange, $"{GameSetupManager.GetSelectedSaveId()}");
}

/// <summary>
/// Toggles the shadow rendering (Shadows, Contact Shadows, Micro Shadowing)
Expand Down
2 changes: 1 addition & 1 deletion SonsGameManager/SonsGameManager.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions SonsSdk/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ namespace SonsSdk;
public static class GameState
{
public static ConstructionManager ConstructionManager => RepositioningUtils.Manager;

public static uint LastLoadedSaveId { get; internal set; }
}
2 changes: 1 addition & 1 deletion SonsSdk/SUI/SUI.AssetBundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static void InitBundleContent()
if (TMP_Settings.fallbackFontAssets == null)
TMP_Settings.fallbackFontAssets = new();
TMP_Settings.fallbackFontAssets.Add(new TMP_FontAsset(asset.Pointer));
RLog.Msg(Color.Orange, $"Loaded additional fallback font: {asset.name}");
RLog.Debug($"Loaded additional fallback font: {asset.name}");
continue;
}

Expand Down
2 changes: 2 additions & 0 deletions SonsSdk/SdkEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using RedLoader;
using Sons.Cutscenes;
using Sons.Events;
using Sons.Gameplay.GameSetup;
using Sons.Gui.Options;
using Sons.Inventory;
using Sons.Loading;
Expand Down Expand Up @@ -213,6 +214,7 @@ private static void OnBeforeLoadSave()
{
RLog.Debug($"ON_BEFORE_LOAD_SAVE");
BeforeLoadSave.Invoke();
GameState.LastLoadedSaveId = GameSetupManager.GetSelectedSaveId();
}

private static void OnAfterLoadSave()
Expand Down
3 changes: 3 additions & 0 deletions SonsSdk/SonsSdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
<Reference Include="Sons.FMOD">
<HintPath>$(GamePath)\$(ProjectAlias)\Game\Sons.FMOD.dll</HintPath>
</Reference>
<Reference Include="Sons.Gameplay.GameSetup">
<HintPath>F:\SteamLibrary\steamapps\common\Sons Of The Forest\_RedLoader\Game\Sons.Gameplay.GameSetup.dll</HintPath>
</Reference>
<Reference Include="Sons.Gui">
<HintPath>$(GamePath)\$(ProjectAlias)\Game\Sons.Gui.dll</HintPath>
</Reference>
Expand Down
55 changes: 55 additions & 0 deletions SonsSdk/SonsTools.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Endnight.Types;
using FMOD;
using RedLoader;
using Sons.Gui;
using Sons.Input;
using Sons.Save;
using SonsSdk.Exceptions;
using TheForest.Utils;
using UnityEngine;
Expand Down Expand Up @@ -61,6 +63,59 @@ public static Vector3 GetPositionInFrontOfPlayer(float distance, float height)
return t.position + t.forward * distance + t.up * height;
}

/// <summary>
/// Get all savegame ids for a specific savegame type
/// </summary>
/// <param name="saveIds"></param>
/// <param name="saveGameType"></param>
/// <returns></returns>
public static bool TryGetSaveGameIds(out List<uint> saveIds, SaveGameType saveGameType = SaveGameType.SinglePlayer)
{
saveIds = new List<uint>();
if (!SingletonBehaviour<SaveGameManager>.TryGetInstance(out var _))
{
RLog.Error("SaveGameManager not initialized, aborting get.");
return false;
}
var saveGameFolder = SaveGameManager.GetSaveGameFolder(saveGameType) ?? "";
var length = saveGameFolder.Length;
if (!Directory.Exists(saveGameFolder))
{
RLog.Error("[SaveGameManager] No save folder found " + saveGameFolder);
return false;
}
string[] directories = Directory.GetDirectories(saveGameFolder);
foreach (string dir in directories)
{
if (File.Exists(dir + "/SaveData.json") && uint.TryParse(dir.Substring(length + 1), out var result))
{
saveIds.Add(result);
}
}
return saveIds.Count > 0;
}

public static uint GetLatestSaveGameId(SaveGameType saveGameType = SaveGameType.SinglePlayer)
{
if (!TryGetSaveGameIds(out var saveIds, saveGameType))
return 0;

var latest = DateTime.MinValue;
uint latestId = 0;

foreach (var saveId in saveIds)
{
var file = new FileInfo(SaveGameManager.GetSaveGameFolder(saveGameType) + "/" + saveId + "/SaveData.json");
if (file.LastWriteTime > latest)
{
latest = file.LastWriteTime;
latestId = saveId;
}
}

return latestId;
}

public static void ShowMessageBox(string title, string message)
{
GenericModalDialog.ShowDialog(title, message);
Expand Down
11 changes: 10 additions & 1 deletion docfx_project/articles/loader-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,13 @@ You can directly load into a save game with the `--savegame <id>` launch option.
You can find the ids of your save games in the `C:\Users\<user>\AppData\LocalLow\Endnight\SonsOfTheForest\Saves\<userid>\SinglePlayer` directory.

## Boot.txt
You can create a `boot.txt` in your game directory with a command on each line to be executed on game start.
You can create a `boot.txt` in your game directory with a command on each line to be executed on game start.

## Debug commands
### Dump info
There are several things the loader allows you to dump from the game. To do so you can use the `dump` console command.
The dump will be written to the game folder in a file called `<type>.txt` (do for `dump items` it will be `items.txt`).
The following thing can be dumped currently:
- `dump items`: Lists all items
- `dump characters`: Lists all characters and their variations
- `dump prefabs` Lists all prefabs

0 comments on commit b0e1bb5

Please sign in to comment.