Skip to content

Commit 1c57d6e

Browse files
committed
Cleanup remaining IL2CPP related code
1 parent b558bad commit 1c57d6e

18 files changed

+19
-1742
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
This is a fork of [UnityExplorer](https://github.com/sinai-dev/UnityExplorer), modified to work as a standalone Kerbal Space Program plugin :
1212
- Uses Harmony instead of HarmonyX
1313
- Uses a forked version of UniverseLib wich also uses Harmony instead of HarmonyX
14-
- All dependencies, and notably `Mono.Cecil` are packed in the assembly to avoid conflicts with the outdated `Mono.Cecil` bundled with KSP.
14+
- All dependencies, and notably `Mono.Cecil` are IL-packed and internalized in the assembly to avoid conflicts with the outdated `Mono.Cecil` bundled with KSP.
1515
- Removed unused code (IL2CPP support, bepinex/melon loaders...)
1616

17+
### Dependencies
18+
- [HarmonyKSP](https://github.com/KSPModdingLibs/HarmonyKSP)
19+
1720
# Features
1821

1922
<p align="center">

lib_notpacked/UniverseLibKSP.dll

0 Bytes
Binary file not shown.

lib_notpacked/UniverseLibKSP.xml

Lines changed: 0 additions & 1462 deletions
This file was deleted.

src/CSConsole/ConsoleController.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ public static class ConsoleController
4545
"System.Collections.Generic",
4646
"System.Reflection",
4747
"UnityEngine",
48-
"UniverseLib",
49-
#if CPP
50-
"UnhollowerBaseLib",
51-
"UnhollowerRuntimeLib",
52-
#endif
48+
"UniverseLib"
5349
};
5450

5551
const int CSCONSOLE_LINEHEIGHT = 18;

src/Config/ConfigManager.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ public static void Init(ConfigHandler configHandler)
5252
Handler.LoadConfig();
5353
InternalHandler.LoadConfig();
5454

55-
#if STANDALONE
5655
Loader.Standalone.ExplorerEditorBehaviour.Instance?.LoadConfigs();
57-
#endif
5856
}
5957

6058
internal static void RegisterConfigElement<T>(ConfigElement<T> configElement)

src/ExplorerBehaviour.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,13 @@
11
using UnityExplorer.UI;
2-
#if CPP
3-
#if UNHOLLOWER
4-
using UnhollowerRuntimeLib;
5-
#else
6-
using Il2CppInterop.Runtime.Injection;
7-
#endif
8-
#endif
92

103
namespace UnityExplorer
114
{
125
public class ExplorerBehaviour : MonoBehaviour
136
{
147
internal static ExplorerBehaviour Instance { get; private set; }
158

16-
#if CPP
17-
public ExplorerBehaviour(System.IntPtr ptr) : base(ptr) { }
18-
#endif
19-
209
internal static void Setup()
2110
{
22-
#if CPP
23-
ClassInjector.RegisterTypeInIl2Cpp<ExplorerBehaviour>();
24-
#endif
25-
2611
GameObject obj = new("ExplorerBehaviour");
2712
DontDestroyOnLoad(obj);
2813
obj.hideFlags = HideFlags.HideAndDontSave;

src/ExplorerCore.cs

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static class ExplorerCore
2525

2626
public static IExplorerLoader Loader { get; private set; }
2727
public static string ExplorerFolder => Path.Combine(Loader.ExplorerFolderDestination, Loader.ExplorerFolderName);
28-
public const string DEFAULT_EXPLORER_FOLDER_NAME = "sinai-dev-UnityExplorer";
28+
public const string DEFAULT_EXPLORER_FOLDER_NAME = "PluginData";
2929

3030
public static HarmonyLib.Harmony Harmony { get; } = new HarmonyLib.Harmony(GUID);
3131

@@ -41,7 +41,6 @@ public static void Init(IExplorerLoader loader)
4141

4242
Log($"{NAME} {VERSION} initializing...");
4343

44-
CheckLegacyExplorerFolder();
4544
Directory.CreateDirectory(ExplorerFolder);
4645
ConfigManager.Init(Loader.ConfigHandler);
4746

@@ -127,63 +126,5 @@ private static void Log(object message, LogType logType)
127126
}
128127

129128
#endregion
130-
131-
132-
#region LEGACY FOLDER MIGRATION
133-
134-
// Can be removed eventually. For migration from <4.7.0
135-
static void CheckLegacyExplorerFolder()
136-
{
137-
string legacyPath = Path.Combine(Loader.ExplorerFolderDestination, "UnityExplorer");
138-
if (Directory.Exists(legacyPath))
139-
{
140-
LogWarning($"Attempting to migrate old 'UnityExplorer/' folder to 'sinai-dev-UnityExplorer/'...");
141-
142-
// If new folder doesn't exist yet, let's just use Move().
143-
if (!Directory.Exists(ExplorerFolder))
144-
{
145-
try
146-
{
147-
Directory.Move(legacyPath, ExplorerFolder);
148-
Log("Migrated successfully.");
149-
}
150-
catch (Exception ex)
151-
{
152-
LogWarning($"Exception migrating folder: {ex}");
153-
}
154-
}
155-
else // We have to merge
156-
{
157-
try
158-
{
159-
CopyAll(new(legacyPath), new(ExplorerFolder));
160-
Directory.Delete(legacyPath, true);
161-
Log("Migrated successfully.");
162-
}
163-
catch (Exception ex)
164-
{
165-
LogWarning($"Exception migrating folder: {ex}");
166-
}
167-
}
168-
}
169-
}
170-
171-
public static void CopyAll(DirectoryInfo source, DirectoryInfo target)
172-
{
173-
Directory.CreateDirectory(target.FullName);
174-
175-
// Copy each file into it's new directory.
176-
foreach (FileInfo fi in source.GetFiles())
177-
fi.MoveTo(Path.Combine(target.ToString(), fi.Name));
178-
179-
// Copy each subdirectory using recursion.
180-
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
181-
{
182-
DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name);
183-
CopyAll(diSourceSubDir, nextTargetSubDir);
184-
}
185-
}
186-
187-
#endregion
188129
}
189130
}

src/Loader/Standalone/Editor/ExplorerEditorBehaviour.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if STANDALONE
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.IO;
54
using System.Linq;
@@ -55,5 +54,4 @@ internal void LoadConfigs()
5554
ConfigManager.Disable_EventSystem_Override.Value = this.Disable_EventSystem_Override;
5655
}
5756
}
58-
}
59-
#endif
57+
}

src/Loader/Standalone/Editor/ExplorerEditorLoader.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if STANDALONE
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43
using System.IO;
54
using System.Linq;
@@ -39,5 +38,4 @@ protected override void CheckExplorerFolder()
3938
explorerFolderDest = Path.GetDirectoryName(Application.dataPath);
4039
}
4140
}
42-
}
43-
#endif
41+
}

src/Loader/Standalone/ExplorerStandalone.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if STANDALONE
2-
using HarmonyLib;
1+
using HarmonyLib;
32
using System;
43
using System.IO;
54
using System.Reflection;
@@ -8,9 +7,6 @@
87
using UnityEngine.EventSystems;
98
using UniverseLib.Input;
109
using UnityExplorer.Loader.Standalone;
11-
#if CPP
12-
using UnhollowerRuntimeLib;
13-
#endif
1410

1511
namespace UnityExplorer
1612
{
@@ -102,5 +98,4 @@ protected virtual void CheckExplorerFolder()
10298
}
10399
}
104100
}
105-
}
106-
#endif
101+
}

0 commit comments

Comments
 (0)