Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Move marsyfier into own class, remove references to Marsey.Serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
misandrie committed May 18, 2024
1 parent 3edf4e4 commit bba9111
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 56 deletions.
2 changes: 0 additions & 2 deletions Marsey/Game/Resources/ResMan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using Marsey.Game.Resources.Dumper;
using Marsey.Game.Resources.Reflection;
using Marsey.Misc;
using Marsey.Serializer;
using Marsey.Stealthsey;

namespace Marsey.Game.Resources;

Expand Down
2 changes: 0 additions & 2 deletions Marsey/Misc/FileHandler.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System.Reflection;
using Marsey.Config;
using Marsey.Game.Patches;
using Marsey.Game.Resources;
using Marsey.Game.Resources.Dumper.Resource;
using Marsey.PatchAssembly;
using Marsey.Patches;
using Marsey.Serializer;
using Marsey.Stealthsey;
using Marsey.Subversion;

Expand Down
43 changes: 0 additions & 43 deletions Marsey/Patches/MarseyPatch.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,7 @@
using System.Reflection;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Marsey.Config;
using Marsey.Game;
using Marsey.PatchAssembly;
using Marsey.Serializer;
using Marsey.Stealthsey;
using Marsey.Misc;
using Marsey.Stealthsey.Reflection;

namespace Marsey.Patches;

/// <summary>
/// Manages MarseyPatch instances
/// </summary>
public static class Marsyfier
{
public static List<MarseyPatch> GetMarseyPatches() => PatchListManager.GetPatchList<MarseyPatch>();

/// <summary>
/// Start preload of marseypatches that are flagged as such
/// </summary>
public static void Preload(string[]? path = null)
{
List<string> preloads = FileHandler.GetFilesFromPipe("PreloadMarseyPatchesPipe");

if (preloads.Count == 0) return;

MarseyLogger.Log(MarseyLogger.LogType.INFO, "Preloader", $"Preloading {preloads.Count} patches.");

foreach (string patch in preloads)
{
MarseyLogger.Log(MarseyLogger.LogType.DEBG, "Preloader", $"Preloading {patch}");
FileHandler.LoadExactAssembly(patch);
}

List<MarseyPatch> preloadedPatches = GetMarseyPatches();

AssemblyFieldHandler.InitHelpers(preloadedPatches);

if (preloadedPatches.Count != 0) Patcher.Patch(preloadedPatches);

PatchListManager.ResetList();
}
}

/// <summary>
/// This class contains the data about a patch (called a Marsey), that is later used the loader to alter the game's functionality.
/// </summary>
Expand Down
39 changes: 39 additions & 0 deletions Marsey/Patches/Marsyfier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Marsey.Game;
using Marsey.Misc;
using Marsey.PatchAssembly;

namespace Marsey.Patches;

/// <summary>
/// Manages MarseyPatch instances
/// </summary>
public static class Marsyfier
{
public static List<MarseyPatch> GetMarseyPatches() => PatchListManager.GetPatchList<MarseyPatch>();

/// <summary>
/// Start preload of marseypatches that are flagged as such
/// </summary>
public static void Preload(string[]? path = null)
{
List<string> preloads = FileHandler.GetFilesFromPipe("PreloadMarseyPatchesPipe");

if (preloads.Count == 0) return;

MarseyLogger.Log(MarseyLogger.LogType.INFO, "Preloader", $"Preloading {preloads.Count} patches.");

foreach (string patch in preloads)
{
MarseyLogger.Log(MarseyLogger.LogType.DEBG, "Preloader", $"Preloading {patch}");
FileHandler.LoadExactAssembly(patch);
}

List<MarseyPatch> preloadedPatches = GetMarseyPatches();

AssemblyFieldHandler.InitHelpers(preloadedPatches);

if (preloadedPatches.Count != 0) Patcher.Patch(preloadedPatches);

PatchListManager.ResetList();
}
}
9 changes: 0 additions & 9 deletions Marsey/Subversion/Subverse.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using HarmonyLib;
using Marsey.Config;
using Marsey.Game;
using Marsey.Game.Misc;
using Marsey.Handbreak;
using Marsey.Stealthsey;
using Marsey.Misc;
using Marsey.PatchAssembly;
using Marsey.Serializer;
using Marsey.Stealthsey.Reflection;

namespace Marsey.Subversion;

Expand Down

0 comments on commit bba9111

Please sign in to comment.