Browse Source

Config system now skips any properties with index parameters

pull/62/head
Anairkoen Schno 3 years ago
parent
commit
c5b15e867c
Signed by: DaNike GPG Key ID: BEFB74D5F3FC4387
2 changed files with 134 additions and 131 deletions
  1. +3
    -0
      IPA.Loader/Config/Stores/GeneratedStoreImpl/ObjectStructure.cs
  2. +131
    -131
      IPA.Loader/Loader/PluginComponent.cs

+ 3
- 0
IPA.Loader/Config/Stores/GeneratedStoreImpl/ObjectStructure.cs View File

@ -141,6 +141,9 @@ namespace IPA.Config.Stores
// only looks at public/protected properties // only looks at public/protected properties
foreach (var prop in type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) foreach (var prop in type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
{ {
if (prop.GetIndexParameters().Length > 0)
continue; // we skip anything with index parameters
if (prop.GetSetMethod(true)?.IsPrivate ?? true) if (prop.GetSetMethod(true)?.IsPrivate ?? true)
{ // we enter this block if the setter is inacessible or doesn't exist { // we enter this block if the setter is inacessible or doesn't exist
continue; // ignore props without setter continue; // ignore props without setter


+ 131
- 131
IPA.Loader/Loader/PluginComponent.cs View File

@ -1,133 +1,133 @@
using IPA.Config;
using IPA.Loader.Composite;
using IPA.Utilities;
using IPA.Utilities.Async;
using System.Diagnostics.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
// ReSharper disable UnusedMember.Local
namespace IPA.Loader
{
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
internal class PluginComponent : MonoBehaviour
{
private CompositeBSPlugin bsPlugins;
private CompositeIPAPlugin ipaPlugins;
private bool quitting;
public static PluginComponent Instance;
private static bool initialized = false;
internal static PluginComponent Create()
{
return Instance = new GameObject("IPA_PluginManager").AddComponent<PluginComponent>();
}
internal void Awake()
{
DontDestroyOnLoad(gameObject);
if (!initialized)
{
UnityGame.SetMainThread();
UnityGame.EnsureRuntimeGameVersion();
PluginManager.Load();
bsPlugins = new CompositeBSPlugin(PluginManager.BSMetas);
#pragma warning disable 618
ipaPlugins = new CompositeIPAPlugin(PluginManager.Plugins);
#pragma warning restore 618
#if BeatSaber // TODO: remove this
gameObject.AddComponent<Updating.BeatMods.Updater>();
#endif
bsPlugins.OnEnable();
ipaPlugins.OnApplicationStart();
SceneManager.activeSceneChanged += OnActiveSceneChanged;
SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.sceneUnloaded += OnSceneUnloaded;
var unitySched = UnityMainThreadTaskScheduler.Default as UnityMainThreadTaskScheduler;
if (!unitySched.IsRunning)
StartCoroutine(unitySched.Coroutine());
initialized = true;
#if DEBUG
Config.Stores.GeneratedStoreImpl.DebugSaveAssembly("GeneratedAssembly.dll");
#endif
}
}
internal void Update()
{
bsPlugins.OnUpdate();
ipaPlugins.OnUpdate();
var unitySched = UnityMainThreadTaskScheduler.Default as UnityMainThreadTaskScheduler;
if (!unitySched.IsRunning)
StartCoroutine(unitySched.Coroutine());
}
internal void LateUpdate()
{
bsPlugins.OnLateUpdate();
ipaPlugins.OnLateUpdate();
}
internal void FixedUpdate()
{
bsPlugins.OnFixedUpdate();
ipaPlugins.OnFixedUpdate();
}
internal void OnDestroy()
{
if (!quitting)
{
Create();
}
using IPA.Config;
using IPA.Loader.Composite;
using IPA.Utilities;
using IPA.Utilities.Async;
using System.Diagnostics.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
// ReSharper disable UnusedMember.Local
namespace IPA.Loader
{
[SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")]
internal class PluginComponent : MonoBehaviour
{
private CompositeBSPlugin bsPlugins;
private CompositeIPAPlugin ipaPlugins;
private bool quitting;
public static PluginComponent Instance;
private static bool initialized = false;
internal static PluginComponent Create()
{
return Instance = new GameObject("IPA_PluginManager").AddComponent<PluginComponent>();
}
internal void Awake()
{
DontDestroyOnLoad(gameObject);
if (!initialized)
{
UnityGame.SetMainThread();
UnityGame.EnsureRuntimeGameVersion();
PluginManager.Load();
bsPlugins = new CompositeBSPlugin(PluginManager.BSMetas);
#pragma warning disable 618
ipaPlugins = new CompositeIPAPlugin(PluginManager.Plugins);
#pragma warning restore 618
#if BeatSaber // TODO: remove this
gameObject.AddComponent<Updating.BeatMods.Updater>();
#endif
bsPlugins.OnEnable();
ipaPlugins.OnApplicationStart();
SceneManager.activeSceneChanged += OnActiveSceneChanged;
SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.sceneUnloaded += OnSceneUnloaded;
var unitySched = UnityMainThreadTaskScheduler.Default as UnityMainThreadTaskScheduler;
if (!unitySched.IsRunning)
StartCoroutine(unitySched.Coroutine());
initialized = true;
#if DEBUG
Config.Stores.GeneratedStoreImpl.DebugSaveAssembly("GeneratedAssembly.dll");
#endif
}
}
internal void Update()
{
bsPlugins.OnUpdate();
ipaPlugins.OnUpdate();
var unitySched = UnityMainThreadTaskScheduler.Default as UnityMainThreadTaskScheduler;
if (!unitySched.IsRunning)
StartCoroutine(unitySched.Coroutine());
}
internal void LateUpdate()
{
bsPlugins.OnLateUpdate();
ipaPlugins.OnLateUpdate();
}
internal void FixedUpdate()
{
bsPlugins.OnFixedUpdate();
ipaPlugins.OnFixedUpdate();
}
internal void OnDestroy()
{
if (!quitting)
{
Create();
}
}
internal void OnApplicationQuit()
{
SceneManager.activeSceneChanged -= OnActiveSceneChanged;
SceneManager.sceneLoaded -= OnSceneLoaded;
SceneManager.sceneUnloaded -= OnSceneUnloaded;
bsPlugins.OnApplicationQuit();
ipaPlugins.OnApplicationQuit();
ConfigRuntime.ShutdownRuntime(); // this seems to be needed
quitting = true;
}
internal void OnLevelWasLoaded(int level)
{
ipaPlugins.OnLevelWasLoaded(level);
}
internal void OnLevelWasInitialized(int level)
{
ipaPlugins.OnLevelWasInitialized(level);
}
private void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
{
bsPlugins.OnSceneLoaded(scene, sceneMode);
}
private void OnSceneUnloaded(Scene scene) {
bsPlugins.OnSceneUnloaded(scene);
}
private void OnActiveSceneChanged(Scene prevScene, Scene nextScene) {
bsPlugins.OnActiveSceneChanged(prevScene, nextScene);
} }
internal void OnApplicationQuit()
{
SceneManager.activeSceneChanged -= OnActiveSceneChanged;
SceneManager.sceneLoaded -= OnSceneLoaded;
SceneManager.sceneUnloaded -= OnSceneUnloaded;
bsPlugins.OnApplicationQuit();
ipaPlugins.OnApplicationQuit();
ConfigRuntime.ShutdownRuntime(); // this seems to be needed
quitting = true;
}
internal void OnLevelWasLoaded(int level)
{
ipaPlugins.OnLevelWasLoaded(level);
}
internal void OnLevelWasInitialized(int level)
{
ipaPlugins.OnLevelWasInitialized(level);
}
private void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
{
bsPlugins.OnSceneLoaded(scene, sceneMode);
}
private void OnSceneUnloaded(Scene scene) {
bsPlugins.OnSceneUnloaded(scene);
}
private void OnActiveSceneChanged(Scene prevScene, Scene nextScene) {
bsPlugins.OnActiveSceneChanged(prevScene, nextScene);
}
}
}
}
}

Loading…
Cancel
Save