Skip to content

Commit 3250a5f

Browse files
author
Balint66
committed
Fix hicup with while loop
1 parent 82491ca commit 3250a5f

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System.Reflection;
2+
using HarmonyLib;
3+
using NSMedieval.Construction;
4+
using NSMedieval.Pool;
5+
using UnityEngine;
6+
7+
namespace GoingMedievalModLauncher.Engine
8+
{
9+
public static class DebbugingPatches
10+
{
11+
12+
private static void SpawnBlueprintPre(BuildingsManager __instance, BuildableBase model, Vector3 worldPosition,
13+
Transform transform)
14+
{
15+
Launcher.LOGGER.Info($"{model}");
16+
Launcher.LOGGER.Info($"{worldPosition}");
17+
Launcher.LOGGER.Info($"{transform}");
18+
var mat = transform.gameObject.GetComponentInChildren<MeshRenderer>().material;
19+
Launcher.LOGGER.Info($"{mat.shader.name}");
20+
var poolf = typeof(BuildingsManager).GetField("pool", BindingFlags.NonPublic | BindingFlags.Instance);
21+
var pool = poolf.GetValue(__instance) as ObjectPool;
22+
var baseBuildableView = (BaseBuildableView<BuildingInstance>) pool.Take(model.GetID());
23+
Launcher.LOGGER.Info($"{baseBuildableView}");
24+
}
25+
26+
private static void AddBuildablePre(BuildingInstance instance, BaseBuildableView<BuildingInstance> view)
27+
{
28+
Launcher.LOGGER.Info($"{instance}");
29+
Launcher.LOGGER.Info($"{view}");
30+
var m = view.GetComponentsInChildren<MeshRenderer>();
31+
foreach ( var renderer in m )
32+
{
33+
Launcher.LOGGER.Info($"{renderer.material.shader.name}");
34+
}
35+
}
36+
37+
public static void ApplyPatches(Harmony harmony)
38+
{
39+
var orig = typeof(BuildingsManager).GetMethod(
40+
"SpawnBlueprint", BindingFlags.Public | BindingFlags.Instance);
41+
var pre = typeof(DebbugingPatches).GetMethod(
42+
"SpawnBlueprintPre", BindingFlags.NonPublic | BindingFlags.Static);
43+
var origA = typeof(BuildingsManager).GetMethod(
44+
"AddBuildable", BindingFlags.Public | BindingFlags.Instance);
45+
var preA = typeof(DebbugingPatches).GetMethod(
46+
"AddBuildablePre", BindingFlags.NonPublic | BindingFlags.Static);
47+
harmony.Patch(orig, new HarmonyMethod(pre));
48+
//harmony.Patch(origA, new HarmonyMethod(preA));
49+
Launcher.LOGGER.Info("Debug patches were applied.");
50+
}
51+
52+
}
53+
}

GoingMedievalModLauncher/src/plugins/PluginContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ private InvalidPluginContainer(){}
692692
public sealed class ModLoaderPluginContainer : Singleton<ModLoaderPluginContainer>, IPluginContainer
693693
{
694694

695-
public string Version => "v0.0.2";
695+
public string Version => "v0.3.5";
696696
public string Requirement => "";
697697
public string[] Dependencies => null;
698698
public bool ActiveState { get=> true; set{} }

GoingMedievalModLauncher/src/plugins/PluginManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private void ValidateRequirements()
7171
pc.Remove(container);
7272
}
7373
}
74-
} while ( !leaves.Equals(tree.leaves));
74+
} while ( leaves.Equals(tree.leaves));
7575

7676
foreach ( PluginContainer container in pc )
7777
{

0 commit comments

Comments
 (0)