forked from zombieb/undead-universal-patch-il2cpp
INTERNAL REWRITE! server configs
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using undead_universal_patch_il2cpp.Core;
|
||||
using undead_universal_patch_il2cpp.Core.Config;
|
||||
using undead_universal_patch_il2cpp.Core.UndeadGameManager;
|
||||
|
||||
namespace undead_universal_patch_il2cpp.Patches.UndeadGameManager;
|
||||
@@ -12,44 +13,35 @@ public class FreeSpawnsPatch_Array
|
||||
{
|
||||
public static List<string> config = GameFreeSpawns.config.Get();
|
||||
|
||||
public static string TargetTypeName = "GamePlayerSpawnPoint";
|
||||
public static string TargetMethodName = "Awake";
|
||||
public static string Description = "FreeSpawns event patch";
|
||||
public static Type targetType = AccessTools.TypeByName(TargetTypeName);
|
||||
static PatchTypesResult patchResult = Util.ConfigPreparePatchTypes(
|
||||
GameManagerConfig.AnyGameFreeSpawn,
|
||||
"FreeSpawns event patch",
|
||||
"GamePlayerSpawnPoint",
|
||||
"Awake"
|
||||
);
|
||||
|
||||
public static bool Prepare()
|
||||
{
|
||||
if (!GameManagerConfig.AnyGameFreeSpawn.Value) return false;
|
||||
if (AccessTools.Method(targetType, TargetMethodName) == null)
|
||||
{
|
||||
Plugin.Log.LogWarning($"'{Description}' disabled. The method for this patch was not found.");
|
||||
return false;
|
||||
}
|
||||
public static bool Prepare() => patchResult.Success;
|
||||
|
||||
Plugin.Log.LogInfo($"'{Description}' succeeded validation.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static MethodBase TargetMethod() => AccessTools.Method(targetType, TargetMethodName);
|
||||
public static MethodBase TargetMethod() => patchResult.Method;
|
||||
|
||||
public static void Postfix(ref GamePlayerSpawnPoint __instance)
|
||||
{
|
||||
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug("Attempting FreeSpawns patch");
|
||||
Util.ConditionalDebug("Attempting FreeSpawns patch");
|
||||
GameManager man = NetworkedSingletonMonoBehaviour<GameManager>.instance;
|
||||
|
||||
if (man.CurrentGameConfiguration == null)
|
||||
{
|
||||
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug("CurrentGameConfiguration was null");
|
||||
Util.ConditionalDebug("CurrentGameConfiguration was null");
|
||||
return;
|
||||
}
|
||||
if (man.CurrentGameConfiguration.configurationData == null)
|
||||
{
|
||||
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug("CurrentGameConfiguration.configurationData was null");
|
||||
Util.ConditionalDebug("CurrentGameConfiguration.configurationData was null");
|
||||
return;
|
||||
}
|
||||
if (!config.Contains(man.CurrentGameConfiguration.configurationData.Name))
|
||||
{
|
||||
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug($"Game '{man.CurrentGameConfiguration.configurationData.Name}' is not specified by GameFreeSpawns");
|
||||
Util.ConditionalDebug($"Game '{man.CurrentGameConfiguration.configurationData.Name}' is not specified by GameFreeSpawns");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using Mapster;
|
||||
using RecRoom.Core.GameManagement;
|
||||
using RecRoom.Protobuf;
|
||||
using undead_universal_patch_il2cpp.Core.Config;
|
||||
using undead_universal_patch_il2cpp.Core;
|
||||
using undead_universal_patch_il2cpp.Core.UndeadGameManager;
|
||||
|
||||
@@ -15,29 +15,16 @@ public class GameConfiguratorPatch
|
||||
{
|
||||
static Dictionary<string, GameConfigurationAssetDTO> gameConfig = GameConfigurator.config.Get();
|
||||
|
||||
static string TargetTypeName = "GameConfigurationTool";
|
||||
static string TargetMethodName = "SetGameConfiguration";
|
||||
static string Description = "GameConfigurator event patch";
|
||||
static PatchTypesResult patchResult = Util.ConfigPreparePatchTypes(
|
||||
GameManagerConfig.StaticGameConfig,
|
||||
"GameConfigurator event patch",
|
||||
"GameConfigurationTool",
|
||||
"SetGameConfiguration"
|
||||
);
|
||||
|
||||
static Type targetType = AccessTools.TypeByName(TargetTypeName);
|
||||
static MethodInfo targetMethod = AccessTools.Method(targetType, TargetMethodName);
|
||||
static bool Prepare() => patchResult.Success;
|
||||
|
||||
public static bool Prepare()
|
||||
{
|
||||
if (!GameManagerConfig.StaticGameConfig.Value) return false;
|
||||
if (targetMethod == null)
|
||||
{
|
||||
Plugin.Log.LogWarning($"'{Description}' disabled. The method for this patch was not found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Plugin.Log.LogInfo($"'{Description}' succeeded validation.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static MethodBase TargetMethod() => targetMethod;
|
||||
|
||||
public static GameConfigurationData res;
|
||||
static MethodBase TargetMethod() => patchResult.Method;
|
||||
|
||||
public static void Prefix(ref GameConfigurationAsset config, ref bool showNotification)
|
||||
{
|
||||
@@ -47,14 +34,14 @@ public class GameConfiguratorPatch
|
||||
var gameConf = gameConfig.GetValueOrDefault(conf.Name, null);
|
||||
if (gameConf == null)
|
||||
{
|
||||
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug($"Game '{conf.Name}' does not have external configuration");
|
||||
if (GenericConfig.PatchDebug.Value) UniversalPatchPlugin.Log.LogDebug($"Game '{conf.Name}' does not have external configuration");
|
||||
return;
|
||||
}
|
||||
|
||||
gameConf.Adapt(conf);
|
||||
|
||||
config = conf;
|
||||
if (GenericConfig.PatchDebug.Value) Plugin.Log.LogDebug($"Applied external game configuration for '{config.Name}'");
|
||||
if (GenericConfig.PatchDebug.Value) UniversalPatchPlugin.Log.LogDebug($"Applied external game configuration for '{config.Name}'");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user