2016-12-14 21:45:50 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace IllusionInjector
|
|
|
|
|
{
|
|
|
|
|
public class PluginComponent : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private CompositePlugin plugins;
|
|
|
|
|
private bool freshlyLoaded = false;
|
2017-04-22 20:15:36 +01:00
|
|
|
|
private bool quitting = false;
|
2016-12-14 21:45:50 +00:00
|
|
|
|
|
2017-02-17 17:33:50 +00:00
|
|
|
|
public static PluginComponent Create()
|
|
|
|
|
{
|
|
|
|
|
return new GameObject("IPA_PluginManager").AddComponent<PluginComponent>();
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-14 21:45:50 +00:00
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
DontDestroyOnLoad(gameObject);
|
|
|
|
|
|
|
|
|
|
plugins = new CompositePlugin(PluginManager.Plugins);
|
|
|
|
|
plugins.OnApplicationStart();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
OnLevelWasLoaded(Application.loadedLevel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
if (freshlyLoaded)
|
|
|
|
|
{
|
|
|
|
|
freshlyLoaded = false;
|
|
|
|
|
plugins.OnLevelWasInitialized(Application.loadedLevel);
|
|
|
|
|
}
|
|
|
|
|
plugins.OnUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LateUpdate()
|
|
|
|
|
{
|
|
|
|
|
plugins.OnLateUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FixedUpdate()
|
|
|
|
|
{
|
|
|
|
|
plugins.OnFixedUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnDestroy()
|
2017-04-22 20:15:36 +01:00
|
|
|
|
{
|
|
|
|
|
if (!quitting)
|
|
|
|
|
{
|
|
|
|
|
Create();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnApplicationQuit()
|
2016-12-14 21:45:50 +00:00
|
|
|
|
{
|
|
|
|
|
plugins.OnApplicationQuit();
|
2017-02-17 17:33:50 +00:00
|
|
|
|
|
2017-04-22 20:15:36 +01:00
|
|
|
|
quitting = true;
|
2016-12-14 21:45:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void OnLevelWasLoaded(int level)
|
|
|
|
|
{
|
|
|
|
|
plugins.OnLevelWasLoaded(level);
|
|
|
|
|
freshlyLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|