This repository has been archived by the owner on Feb 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathPlugin.cs
93 lines (78 loc) · 2.66 KB
/
Plugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using StreamCore.Chat;
using StreamCore.Config;
using IllusionPlugin;
using System;
using System.Collections;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.SceneManagement;
using StreamCore.YouTube;
using StreamCore.Utils;
using StreamCore.Twitch;
namespace StreamCore
{
public class Plugin : IPlugin
{
public static Plugin Instance { get; private set; }
private readonly TwitchLoginConfig TwitchLoginConfig = new TwitchLoginConfig();
public static readonly string ModuleName = "Stream Core";
public string Name => ModuleName;
public string Version => "2.2.4";
private static readonly object _loggerLock = new object();
public static void Log(string text,
[CallerFilePath] string file = "",
[CallerMemberName] string member = "",
[CallerLineNumber] int line = 0)
{
lock(_loggerLock)
Console.WriteLine($"{ModuleName}::{Path.GetFileName(file)}->{member}({line}): {text}");
}
public void OnApplicationStart()
{
if (Instance != null) return;
Instance = this;
SharedMonoBehaviour.StartCoroutine(GlobalChatHandler.InitGlobalChatHandlers());
SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
}
private void SceneManager_activeSceneChanged(Scene from, Scene to)
{
if (to.name == "MenuCore")
Globals.IsAtMainMenu = true;
else if (to.name == "GameCore")
Globals.IsAtMainMenu = false;
}
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
{
if(arg0.name == "MenuCore")
{
TwitchLoginConfig.Save(true);
}
}
public void OnApplicationQuit()
{
SceneManager.activeSceneChanged -= SceneManager_activeSceneChanged;
SceneManager.sceneLoaded -= SceneManager_sceneLoaded;
Globals.IsApplicationExiting = true;
// Cancel all running tasks
TaskHelper.CancelAllTasks();
// Shutdown our twitch client if it's initialized
TwitchWebSocketClient.Shutdown();
YouTubeConnection.Stop();
}
public void OnLevelWasLoaded(int level)
{
}
public void OnLevelWasInitialized(int level)
{
}
public void OnUpdate()
{
}
public void OnFixedUpdate()
{
}
}
}