Skip to content

Commit a9c9f92

Browse files
committed
fix: Resolved issues w/ addition of BepInEx
1 parent 88bf048 commit a9c9f92

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

S1API/Dialogues/DialogueInjector.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
using System.Collections.Generic;
2-
32
using UnityEngine;
4-
using MelonLoader;
53
using S1API.Dialogues;
4+
#if (IL2CPPMELON || MONOMELON)
5+
using MelonLoader;
6+
#endif
7+
68
#if IL2CPPMELON || IL2CPPBEPINEX
79
using Il2CppScheduleOne.Dialogue;
810
using Il2CppScheduleOne.NPCs;
911
using Il2CppScheduleOne.NPCs.Schedules;
12+
using Il2CppFishNet;
1013
#else
1114
using ScheduleOne.Dialogue;
1215
using ScheduleOne.NPCs;
1316
using ScheduleOne.NPCs.Schedules;
17+
using FishNet;
1418
#endif
1519
/// <summary>
1620
/// The DialogueInjector class is a static utility that facilitates the injection of custom dialogue entries
@@ -54,8 +58,12 @@ private static void HookUpdateLoop()
5458
{
5559
if (isHooked) return;
5660
isHooked = true;
57-
61+
62+
#if (IL2CPPMELON || MONOMELON)
5863
MelonCoroutines.Start(WaitForNPCsAndInject());
64+
#elif (IL2CPPBEPINEX || MONOBEPINEX)
65+
InstanceFinder.TimeManager.StartCoroutine(WaitForNPCsAndInject());
66+
#endif
5967
}
6068

6169
/// <summary>
@@ -117,7 +125,7 @@ private static void TryInject(DialogueInjection injection, NPC npc)
117125
DialogueNodeData node = null;
118126
for (int i = 0; i < container.DialogueNodeData.Count; i++)
119127
{
120-
var n = container.DialogueNodeData[i];
128+
var n = container.DialogueNodeData.ToArray()[i];
121129
if (n != null && n.Guid == injection.FromNodeGuid)
122130
{
123131
node = n;
@@ -158,6 +166,7 @@ private static void TryInject(DialogueInjection injection, NPC npc)
158166

159167
DialogueChoiceListener.Register(handler, injection.ChoiceLabel, injection.OnConfirmed);
160168

161-
MelonLogger.Msg($"[DialogueInjector] Injected '{injection.ChoiceLabel}' into NPC '{npc.name}'");
169+
// TODO (@omar-akermi): Can you convert this to the new logger pls?
170+
// MelonLogger.Msg($"[DialogueInjector] Injected '{injection.ChoiceLabel}' into NPC '{npc.name}'");
162171
}
163172
}

S1API/Internal/Utils/CrossType.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#if (MONOMELON || MONOBEPINEX)
1+
#if (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
22
using System;
3-
# elif (IL2CPPMELON || IL2CPPBEPINEX)
3+
# elif (IL2CPPMELON)
44
using Il2CppSystem;
55
using Il2CppInterop.Runtime;
66
using Il2CppInterop.Runtime.InteropTypes;
@@ -21,9 +21,9 @@ internal static class CrossType
2121
/// <returns>The type of the class.</returns>
2222
internal static Type Of<T>()
2323
{
24-
#if (MONOMELON || MONOBEPINEX)
24+
#if (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
2525
return typeof(T);
26-
# elif (IL2CPPMELON || IL2CPPBEPINEX)
26+
# elif (IL2CPPMELON)
2727
return Il2CppType.Of<T>();
2828
#endif
2929
}
@@ -36,13 +36,13 @@ internal static Type Of<T>()
3636
/// <typeparam name="T">The class we're checking against.</typeparam>
3737
/// <returns>Whether obj is of class T or not.</returns>
3838
internal static bool Is<T>(object obj, out T result)
39-
#if (IL2CPPMELON || IL2CPPBEPINEX)
39+
#if (IL2CPPMELON)
4040
where T : Il2CppObjectBase
41-
#elif (MONOMELON || MONOBEPINEX)
41+
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
4242
where T : class
4343
#endif
4444
{
45-
#if (IL2CPPMELON || IL2CPPBEPINEX)
45+
#if (IL2CPPMELON)
4646
if (obj is Object il2CppObj)
4747
{
4848
Type il2CppType = Il2CppType.Of<T>();
@@ -52,7 +52,7 @@ internal static bool Is<T>(object obj, out T result)
5252
return true;
5353
}
5454
}
55-
#elif (MONOMELON || MONOBEPINEX)
55+
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
5656
if (obj is T t)
5757
{
5858
result = t;
@@ -71,15 +71,15 @@ internal static bool Is<T>(object obj, out T result)
7171
/// <typeparam name="T">The type to cast to.</typeparam>
7272
/// <returns>The object cast to the specified type.</returns>
7373
internal static T As<T>(object obj)
74-
#if (IL2CPPMELON || IL2CPPBEPINEX)
74+
#if (IL2CPPMELON)
7575
where T : Il2CppObjectBase
76-
#elif (MONOMELON || MONOBEPINEX)
76+
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
7777
where T : class
7878
#endif
7979
=>
80-
#if (IL2CPPMELON || IL2CPPBEPINEX)
80+
#if (IL2CPPMELON)
8181
obj is Object il2CppObj ? il2CppObj.Cast<T>() : null!;
82-
#elif (MONOMELON || MONOBEPINEX)
82+
#elif (MONOMELON || MONOBEPINEX || IL2CPPBEPINEX)
8383
(T)obj;
8484
#endif
8585
}

0 commit comments

Comments
 (0)