Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
obj/
bin/
*.user
.vs/

# Build props
local.*
Expand Down
30 changes: 20 additions & 10 deletions S1API.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,27 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "S1APILoader", "S1APILoader\
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Mono|Any CPU = Mono|Any CPU
Il2Cpp|Any CPU = Il2Cpp|Any CPU
MonoBepInEx|Any CPU = MonoBepInEx|Any CPU
Il2CppMelon|Any CPU = Il2CppMelon|Any CPU
MonoMelon|Any CPU = MonoMelon|Any CPU
Il2CppBepInEx|Any CPU = Il2CppBepInEx|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.Mono|Any CPU.ActiveCfg = Mono|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.Mono|Any CPU.Build.0 = Mono|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.Il2Cpp|Any CPU.ActiveCfg = Il2Cpp|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.Il2Cpp|Any CPU.Build.0 = Il2Cpp|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.Mono|Any CPU.ActiveCfg = Mono|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.Mono|Any CPU.Build.0 = Mono|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.Il2Cpp|Any CPU.ActiveCfg = Il2Cpp|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.Il2Cpp|Any CPU.Build.0 = Il2Cpp|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.MonoBepInEx|Any CPU.ActiveCfg = MonoBepInEx|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.MonoBepInEx|Any CPU.Build.0 = MonoBepInEx|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.Il2CppMelon|Any CPU.ActiveCfg = Il2CppMelon|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.Il2CppMelon|Any CPU.Build.0 = Il2CppMelon|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.MonoMelon|Any CPU.ActiveCfg = MonoMelon|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.MonoMelon|Any CPU.Build.0 = MonoMelon|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.Il2CppBepInEx|Any CPU.ActiveCfg = Il2CppBepInEx|Any CPU
{D2C9A6B1-B9E0-4E6D-AE65-B5264C2A4E04}.Il2CppBepInEx|Any CPU.Build.0 = Il2CppBepInEx|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.MonoBepInEx|Any CPU.ActiveCfg = MonoBepInEx|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.MonoBepInEx|Any CPU.Build.0 = MonoBepInEx|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.Il2CppMelon|Any CPU.ActiveCfg = Il2CppMelon|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.Il2CppMelon|Any CPU.Build.0 = Il2CppMelon|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.MonoMelon|Any CPU.ActiveCfg = MonoMelon|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.MonoMelon|Any CPU.Build.0 = MonoMelon|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.Il2CppBepInEx|Any CPU.ActiveCfg = Il2CppBepInEx|Any CPU
{B97277C2-27FE-4BB9-AB5A-D479C8DF6827}.Il2CppBepInEx|Any CPU.Build.0 = Il2CppBepInEx|Any CPU
EndGlobalSection
EndGlobal
6 changes: 3 additions & 3 deletions S1API/Console/ConsoleHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;

#if IL2CPP
#if IL2CPPMELON || IL2CPPBEPINEX
using Il2CppSystem.Collections.Generic;
using static Il2CppScheduleOne.Console;

Expand All @@ -19,7 +19,7 @@ public static class ConsoleHelper
/// <param name="amount">The cash amount to add or remove.</param>
public static void RunCashCommand(int amount)
{
#if IL2CPP
#if IL2CPPMELON || IL2CPPBEPINEX
var command = new ChangeCashCommand();
var args = new Il2CppSystem.Collections.Generic.List<string>();
#else
Expand All @@ -30,4 +30,4 @@ public static void RunCashCommand(int amount)
command.Execute(args);
}
}
}
}
6 changes: 3 additions & 3 deletions S1API/DeadDrops/DeadDropInstance.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1Economy = Il2CppScheduleOne.Economy;
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
using S1Economy = ScheduleOne.Economy;
#endif

Expand Down Expand Up @@ -59,4 +59,4 @@ internal DeadDropInstance(S1Economy.DeadDrop deadDrop) =>
public Vector3 Position =>
S1DeadDrop.transform.position;
}
}
}
6 changes: 3 additions & 3 deletions S1API/DeadDrops/DeadDropManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1Economy = Il2CppScheduleOne.Economy;
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
using S1Economy = ScheduleOne.Economy;
#endif

Expand All @@ -19,4 +19,4 @@ public class DeadDropManager
public static DeadDropInstance[] All =>
S1Economy.DeadDrop.DeadDrops.ToArray()
.Select(deadDrop => new DeadDropInstance(deadDrop)).ToArray(); }
}
}
6 changes: 3 additions & 3 deletions S1API/GameTime/GameDateTime.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// TODO: Implement GameDateTime wrapper
// #if (IL2CPP)
// #if (IL2CPPMELON || IL2CPPBEPINEX)
// using S1GameTime = Il2CppScheduleOne.GameTime;
// #elif (MONO)
// #elif (MONOMELON || MONOBEPINEX)
// using S1GameTime = ScheduleOne.GameTime;
// #endif
//
Expand All @@ -19,4 +19,4 @@
//
// public void Ad
// }
// }
// }
6 changes: 3 additions & 3 deletions S1API/GameTime/TimeManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1GameTime = Il2CppScheduleOne.GameTime;
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
using S1GameTime = ScheduleOne.GameTime;
#endif

Expand All @@ -24,4 +24,4 @@ public static class TimeManager
public static Day CurrentDay =>
(Day)S1GameTime.TimeManager.Instance.CurrentDay;
}
}
}
4 changes: 2 additions & 2 deletions S1API/Internal/Abstraction/ISaveable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if (MONO)
#if (MONOMELON || MONOBEPINEX)
using System.Collections.Generic;
#elif (IL2CPP)
using Il2CppSystem.Collections.Generic;
Expand Down Expand Up @@ -46,4 +46,4 @@ internal interface ISaveable : IRegisterable
Converters = new System.Collections.Generic.List<JsonConverter>() { new GUIDReferenceConverter() }
};
}
}
}
4 changes: 2 additions & 2 deletions S1API/Internal/Abstraction/Saveable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if (MONO)
#if (MONOMELON || MONOBEPINEX)
using System.Collections.Generic;
#elif (IL2CPP)
using Il2CppSystem.Collections.Generic;
Expand Down Expand Up @@ -119,4 +119,4 @@ void ISaveable.OnSaved() =>
/// </summary>
protected virtual void OnSaved() { }
}
}
}
6 changes: 3 additions & 3 deletions S1API/Internal/Patches/NPCPatches.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1Loaders = Il2CppScheduleOne.Persistence.Loaders;
using S1NPCs = Il2CppScheduleOne.NPCs;
using Il2CppSystem.Collections.Generic;
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
using S1Loaders = ScheduleOne.Persistence.Loaders;
using S1NPCs = ScheduleOne.NPCs;
using System.Collections.Generic;
Expand Down Expand Up @@ -84,4 +84,4 @@ private static void NPCOnDestroy(S1NPCs.NPC __instance)
NPCs.Remove(npc);
}
}
}
}
11 changes: 7 additions & 4 deletions S1API/Internal/Patches/PhoneAppPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
using UnityEngine.SceneManagement;
using S1API.Internal.Utils;
using S1API.Internal.Abstraction;
using S1API.Logging;
using S1API.PhoneApp;

namespace S1API.Internal.Patches
{
#if IL2CPP
{
#if IL2CPPMELON || IL2CPPBEPINEX
[HarmonyPatch(typeof(SceneManager), nameof(SceneManager.Internal_SceneLoaded))]
#else
[HarmonyPatch(typeof(SceneManager), "Internal_SceneLoaded", new Type[] { typeof(Scene), typeof(LoadSceneMode) })]

#endif
internal static class PhoneAppPatches
{
private static readonly Log _loggerInstance = new Log("PhoneAppPatches");

private static bool _loaded = false;

/// <summary>
Expand All @@ -41,9 +44,9 @@ static void Postfix(Scene scene, LoadSceneMode mode)
}
catch (System.Exception e)
{
MelonLoader.MelonLogger.Warning($"[PhoneApp] Failed to register {type.FullName}: {e.Message}");
_loggerInstance.Warning($"[PhoneApp] Failed to register {type.FullName}: {e.Message}");
}
}
}
}
}
}
6 changes: 3 additions & 3 deletions S1API/Internal/Patches/QuestPatches.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1Loaders = Il2CppScheduleOne.Persistence.Loaders;
using S1Datas = Il2CppScheduleOne.Persistence.Datas;
using S1Quests = Il2CppScheduleOne.Quests;
using Il2CppSystem.Collections.Generic;
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
using S1Loaders = ScheduleOne.Persistence.Loaders;
using S1Datas = ScheduleOne.Persistence.Datas;
using S1Quests = ScheduleOne.Quests;
Expand Down Expand Up @@ -128,4 +128,4 @@ private static void QuestStart(S1Quests.Quest __instance) =>
// NPCs.Remove(npc);
// }
}
}
}
6 changes: 3 additions & 3 deletions S1API/Internal/Patches/TimePatches.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1GameTime = Il2CppScheduleOne.GameTime;
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
using S1GameTime = ScheduleOne.GameTime;
#endif

Expand Down Expand Up @@ -33,4 +33,4 @@ void DayPass()
__instance.onDayPass += (Action)DayPass;
}
}
}
}
26 changes: 13 additions & 13 deletions S1API/Internal/Utils/CrossType.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if (MONO)
#if (MONOMELON || MONOBEPINEX)
using System;
# elif (IL2CPP)
# elif (IL2CPPMELON || IL2CPPBEPINEX)
using Il2CppSystem;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
Expand All @@ -21,9 +21,9 @@ internal static class CrossType
/// <returns>The type of the class.</returns>
internal static Type Of<T>()
{
#if (MONO)
#if (MONOMELON || MONOBEPINEX)
return typeof(T);
# elif (IL2CPP)
# elif (IL2CPPMELON || IL2CPPBEPINEX)
return Il2CppType.Of<T>();
#endif
}
Expand All @@ -36,13 +36,13 @@ internal static Type Of<T>()
/// <typeparam name="T">The class we're checking against.</typeparam>
/// <returns>Whether obj is of class T or not.</returns>
internal static bool Is<T>(object obj, out T result)
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
where T : Il2CppObjectBase
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
where T : class
#endif
{
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
if (obj is Object il2CppObj)
{
Type il2CppType = Il2CppType.Of<T>();
Expand All @@ -52,7 +52,7 @@ internal static bool Is<T>(object obj, out T result)
return true;
}
}
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
if (obj is T t)
{
result = t;
Expand All @@ -71,16 +71,16 @@ internal static bool Is<T>(object obj, out T result)
/// <typeparam name="T">The type to cast to.</typeparam>
/// <returns>The object cast to the specified type.</returns>
internal static T As<T>(object obj)
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
where T : Il2CppObjectBase
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
where T : class
#endif
=>
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
obj is Object il2CppObj ? il2CppObj.Cast<T>() : null!;
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
(T)obj;
#endif
}
}
}
13 changes: 6 additions & 7 deletions S1API/Internal/Utils/ImageUtils.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
using MelonLoader;
using System;
using System.Collections.Generic;
using S1API.Logging;
using System.IO;
using System.Text;
using UnityEngine;

namespace S1API.Internal.Utils
{
public static class ImageUtils
{
private static readonly Log _loggerInstance = new Log("ImageUtils");

/// <summary>
/// Loads an image from the specified file path and converts it into a Sprite object.
/// </summary>
Expand All @@ -21,7 +20,7 @@ public static Sprite LoadImage(string fileName)
string fullPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) ?? string.Empty, fileName);
if (!File.Exists(fullPath))
{
MelonLogger.Error($"❌ Icon file not found: {fullPath}");
_loggerInstance.Error($"❌ Icon file not found: {fullPath}");
return null;
}

Expand All @@ -36,10 +35,10 @@ public static Sprite LoadImage(string fileName)
}
catch (System.Exception ex)
{
MelonLogger.Error("❌ Failed to load sprite: " + ex);
_loggerInstance.Error("❌ Failed to load sprite: " + ex);
}

return null;
}
}
}
}
6 changes: 3 additions & 3 deletions S1API/Items/ItemDefinition.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1ItemFramework = Il2CppScheduleOne.ItemFramework;
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
using S1ItemFramework = ScheduleOne.ItemFramework;
#endif

Expand Down Expand Up @@ -115,4 +115,4 @@ public override int GetHashCode() =>
public virtual ItemInstance CreateInstance(int quantity = 1) =>
new ItemInstance(S1ItemDefinition.GetDefaultInstance(quantity));
}
}
}
6 changes: 3 additions & 3 deletions S1API/Items/ItemInstance.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if (IL2CPP)
#if (IL2CPPMELON || IL2CPPBEPINEX)
using S1ItemFramework = Il2CppScheduleOne.ItemFramework;
#elif (MONO)
#elif (MONOMELON || MONOBEPINEX)
using S1ItemFramework = ScheduleOne.ItemFramework;
#endif

Expand Down Expand Up @@ -32,4 +32,4 @@ internal ItemInstance(S1ItemFramework.ItemInstance itemInstance) =>
public ItemDefinition Definition =>
new ItemDefinition(S1ItemInstance.Definition);
}
}
}
Loading