2024-06-28 18:08:25 +08:00
|
|
|
|
using AxibugEmuOnline.Client.Manager;
|
|
|
|
|
using AxibugEmuOnline.Client.Network;
|
2024-08-22 15:16:58 +08:00
|
|
|
|
using System;
|
2024-08-13 18:35:20 +08:00
|
|
|
|
using System.Collections;
|
2024-06-28 18:08:25 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace AxibugEmuOnline.Client.ClientCore
|
|
|
|
|
{
|
2024-08-22 15:16:58 +08:00
|
|
|
|
public static class AppAxibugEmuOnline
|
2024-06-28 18:08:25 +08:00
|
|
|
|
{
|
|
|
|
|
public static string TokenStr;
|
|
|
|
|
public static long RID = -1;
|
|
|
|
|
public static string IP;
|
|
|
|
|
public static int Port;
|
|
|
|
|
public static LogManager log;
|
|
|
|
|
public static NetworkHelper networkHelper;
|
|
|
|
|
public static AppLogin login;
|
|
|
|
|
public static AppChat chat;
|
|
|
|
|
public static UserDataManager user;
|
2024-07-03 14:43:11 +08:00
|
|
|
|
public static AppNetGame netgame;
|
|
|
|
|
public static AppEmu emu;
|
2024-08-22 15:16:58 +08:00
|
|
|
|
public static RomLib nesRomLib;
|
2024-08-13 18:35:20 +08:00
|
|
|
|
public static HttpAPI httpAPI;
|
2024-08-22 17:25:00 +08:00
|
|
|
|
public static CacheManager CacheMgr;
|
2024-08-13 18:35:20 +08:00
|
|
|
|
|
|
|
|
|
private static CoroutineRunner coRunner;
|
|
|
|
|
|
2024-08-22 17:25:00 +08:00
|
|
|
|
public static string PersistentDataPath => Application.persistentDataPath;
|
|
|
|
|
|
2024-08-13 18:35:20 +08:00
|
|
|
|
[RuntimeInitializeOnLoadMethod]
|
|
|
|
|
static void Init()
|
2024-06-28 18:08:25 +08:00
|
|
|
|
{
|
|
|
|
|
log = new LogManager();
|
|
|
|
|
LogManager.OnLog += OnNoSugarNetLog;
|
|
|
|
|
networkHelper = new NetworkHelper();
|
|
|
|
|
login = new AppLogin();
|
|
|
|
|
chat = new AppChat();
|
|
|
|
|
user = new UserDataManager();
|
2024-07-03 14:43:11 +08:00
|
|
|
|
emu = new AppEmu();
|
|
|
|
|
netgame = new AppNetGame();
|
2024-08-14 13:09:22 +08:00
|
|
|
|
httpAPI = new HttpAPI();
|
2024-08-22 15:16:58 +08:00
|
|
|
|
nesRomLib = new RomLib(EnumPlatform.NES);
|
2024-08-22 17:25:00 +08:00
|
|
|
|
CacheMgr = new CacheManager();
|
2024-08-13 18:35:20 +08:00
|
|
|
|
|
|
|
|
|
var go = new GameObject("[AppAxibugEmuOnline]");
|
|
|
|
|
GameObject.DontDestroyOnLoad(go);
|
|
|
|
|
coRunner = go.AddComponent<CoroutineRunner>();
|
2024-08-22 15:16:58 +08:00
|
|
|
|
|
|
|
|
|
StartCoroutine(AppTickFlow());
|
2024-08-13 18:35:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-22 15:16:58 +08:00
|
|
|
|
private static IEnumerator AppTickFlow()
|
|
|
|
|
{
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
Tick();
|
|
|
|
|
yield return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void Tick()
|
|
|
|
|
{
|
|
|
|
|
nesRomLib.ExecuteFetchRomInfo();
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-13 18:35:20 +08:00
|
|
|
|
public static Coroutine StartCoroutine(IEnumerator itor)
|
|
|
|
|
{
|
|
|
|
|
return coRunner.StartCoroutine(itor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void StopCoroutine(Coroutine cor)
|
|
|
|
|
{
|
|
|
|
|
coRunner.StopCoroutine(cor);
|
2024-06-28 18:08:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool Connect(string IP, int port)
|
|
|
|
|
{
|
|
|
|
|
return networkHelper.Init(IP, port);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Close()
|
|
|
|
|
{
|
|
|
|
|
AppAxibugEmuOnline.log.Info("停止");
|
|
|
|
|
}
|
|
|
|
|
static void OnNoSugarNetLog(int LogLevel, string msg)
|
|
|
|
|
{
|
2024-08-13 18:35:20 +08:00
|
|
|
|
Debug.Log("[AxibugEmuOnline]:" + msg);
|
2024-06-28 18:08:25 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|