feat(battle-engine): close the AI-simulation subsystem (verbatim)
Copied the 89 uncopied AI*SimulationUtility/extension files defining the AIVirtualCard/AIVirtualField extension methods; the compile loop then auto-closed the revealed type deps (~3049 files total, drift-clean). 10.0k -> 62 errors.
This commit is contained in:
61
SVSim.BattleEngine/Engine/Cute/AchievementManager.cs
Normal file
61
SVSim.BattleEngine/Engine/Cute/AchievementManager.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cute;
|
||||
|
||||
public static class AchievementManager
|
||||
{
|
||||
private static IAchievementCallback mCallback;
|
||||
|
||||
public static void Initialize(IAchievementCallback callback)
|
||||
{
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
public static void ShowAchievementsUI()
|
||||
{
|
||||
Social.ShowAchievementsUI();
|
||||
}
|
||||
|
||||
public static void ReleaseAchievement(string id)
|
||||
{
|
||||
Social.ReportProgress(id, 100.0, delegate(bool success)
|
||||
{
|
||||
if (mCallback != null)
|
||||
{
|
||||
mCallback.OnReleaseAchievement(success);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void ProceedAchievement(string id, float value)
|
||||
{
|
||||
Social.ReportProgress(id, value, delegate(bool success)
|
||||
{
|
||||
if (mCallback != null)
|
||||
{
|
||||
mCallback.OnProceedAchievement(success);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void ResetAchievements(Action<bool> callback)
|
||||
{
|
||||
}
|
||||
|
||||
public static void LoadAchievements()
|
||||
{
|
||||
if (mCallback != null)
|
||||
{
|
||||
Social.LoadAchievements(mCallback.OnLoadAchievements);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadAchievementDescriptions()
|
||||
{
|
||||
if (mCallback != null)
|
||||
{
|
||||
Social.LoadAchievementDescriptions(mCallback.OnLoadAchievementDescriptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
SVSim.BattleEngine/Engine/Cute/AdjustManager.cs
Normal file
22
SVSim.BattleEngine/Engine/Cute/AdjustManager.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
namespace Cute;
|
||||
|
||||
public static class AdjustManager
|
||||
{
|
||||
private const string _viewerIDEventToken = "qxq65x";
|
||||
|
||||
private const string _tutorialEventToken = "wlojkf";
|
||||
|
||||
private const string _paymentEventToken = "sgqjsc";
|
||||
|
||||
public static void ViewerIDEvent()
|
||||
{
|
||||
}
|
||||
|
||||
public static void TutorialCompleteEvent()
|
||||
{
|
||||
}
|
||||
|
||||
public static void PaymentEvent(double price, string currencycode, string transactionId, string itemTitle, string productId)
|
||||
{
|
||||
}
|
||||
}
|
||||
75
SVSim.BattleEngine/Engine/Cute/BootApp.cs
Normal file
75
SVSim.BattleEngine/Engine/Cute/BootApp.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
using Wizard;
|
||||
|
||||
namespace Cute;
|
||||
|
||||
public class BootApp : MonoBehaviour
|
||||
{
|
||||
public static string BootScene;
|
||||
|
||||
private Coroutine _logCoroutine;
|
||||
|
||||
private string _logMsg = "";
|
||||
|
||||
private IEnumerator Start()
|
||||
{
|
||||
_logCoroutine = StartCoroutine(WaitToAccumulateTraceLog());
|
||||
_logMsg += "start";
|
||||
createMutex();
|
||||
restrainOSXProcess();
|
||||
startSteamClient();
|
||||
while (Toolbox.BootSystem == null)
|
||||
{
|
||||
yield return 0;
|
||||
}
|
||||
_logMsg += "start2";
|
||||
CultureInfo.DefaultThreadCurrentUICulture = (CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("ja-JP", useUserOverride: false));
|
||||
Toolbox.AssetManager.createSavePath();
|
||||
yield return StartCoroutine(FontChanger.FontTryChangePersistant(null));
|
||||
_logMsg += "start3";
|
||||
_logMsg += "start4";
|
||||
StopCoroutine(_logCoroutine);
|
||||
changeScene();
|
||||
}
|
||||
|
||||
private IEnumerator WaitToAccumulateTraceLog()
|
||||
{
|
||||
yield return new WaitForSeconds(5f);
|
||||
LocalLog.AccumulateTraceInquiryLog("BootApp " + _logMsg);
|
||||
}
|
||||
|
||||
private void createMutex()
|
||||
{
|
||||
Toolbox.mute = new Mutex(initiallyOwned: false, "Global\\ShadowversePcPlatformGlobalThread");
|
||||
if (Toolbox.mute != null && !Toolbox.mute.WaitOne(0, exitContext: false))
|
||||
{
|
||||
Toolbox.mute.Close();
|
||||
Toolbox.mute = null;
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
|
||||
private void startSteamClient()
|
||||
{
|
||||
_ = SteamManager.Initialized;
|
||||
}
|
||||
|
||||
private void restrainOSXProcess()
|
||||
{
|
||||
}
|
||||
|
||||
private void changeScene()
|
||||
{
|
||||
if (BootScene != null)
|
||||
{
|
||||
Toolbox.SceneManager.ChangeScene(BootScene);
|
||||
}
|
||||
else
|
||||
{
|
||||
Toolbox.SceneManager.ChangeScene(SceneType._Splash);
|
||||
}
|
||||
}
|
||||
}
|
||||
74
SVSim.BattleEngine/Engine/Cute/DataMigration.cs
Normal file
74
SVSim.BattleEngine/Engine/Cute/DataMigration.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using Wizard;
|
||||
|
||||
namespace Cute;
|
||||
|
||||
public class DataMigration
|
||||
{
|
||||
public enum status
|
||||
{
|
||||
NONE,
|
||||
OVER,
|
||||
FAIL
|
||||
}
|
||||
|
||||
private static bool inProgress;
|
||||
|
||||
public static bool canCombine()
|
||||
{
|
||||
if (Certification.ViewerId != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void CombineStart(string url)
|
||||
{
|
||||
BrowserURL.Open(url);
|
||||
inProgress = true;
|
||||
}
|
||||
|
||||
public static bool isCombineSucceed()
|
||||
{
|
||||
if (Toolbox.SavedataManager.GetInt("COMBINED") != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool isProgressing()
|
||||
{
|
||||
return inProgress;
|
||||
}
|
||||
|
||||
public static void ProgressOver()
|
||||
{
|
||||
inProgress = false;
|
||||
URLScheme.Clear();
|
||||
}
|
||||
|
||||
public static void CombineSucceed()
|
||||
{
|
||||
Toolbox.SavedataManager.SetInt("COMBINED", 1);
|
||||
}
|
||||
|
||||
public static void CombineFailed()
|
||||
{
|
||||
}
|
||||
|
||||
public static void MigrationStart(string url)
|
||||
{
|
||||
BrowserURL.Open(url);
|
||||
inProgress = true;
|
||||
}
|
||||
|
||||
public static void MigrationSucceed()
|
||||
{
|
||||
CombineSucceed();
|
||||
}
|
||||
|
||||
public static void MigrationFailed()
|
||||
{
|
||||
}
|
||||
}
|
||||
106
SVSim.BattleEngine/Engine/Cute/LeanThreadPool.cs
Normal file
106
SVSim.BattleEngine/Engine/Cute/LeanThreadPool.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cute;
|
||||
|
||||
public class LeanThreadPool
|
||||
{
|
||||
private static LeanThreadPool _instance;
|
||||
|
||||
private Thread[] _threads;
|
||||
|
||||
private Semaphore _semaphore;
|
||||
|
||||
private object _jobsLock;
|
||||
|
||||
private object _convergeLock;
|
||||
|
||||
private List<ParallelJob> _jobs;
|
||||
|
||||
private bool _quit;
|
||||
|
||||
private int _convergeCount;
|
||||
|
||||
public static LeanThreadPool Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new LeanThreadPool();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public int ThreadsCount => _threads.Length;
|
||||
|
||||
private LeanThreadPool()
|
||||
{
|
||||
int processorCount = SystemInfo.processorCount;
|
||||
_jobs = new List<ParallelJob>();
|
||||
_jobsLock = new object();
|
||||
_convergeLock = new object();
|
||||
_semaphore = new Semaphore(0, int.MaxValue);
|
||||
_threads = new Thread[processorCount];
|
||||
for (int i = 0; i < _threads.Length; i++)
|
||||
{
|
||||
_threads[i] = new Thread(ThreadFunction);
|
||||
_threads[i].Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void ThreadFunction()
|
||||
{
|
||||
ParallelJob parallelJob = null;
|
||||
while (!_quit)
|
||||
{
|
||||
_semaphore.WaitOne();
|
||||
lock (_jobsLock)
|
||||
{
|
||||
if (_jobs.Count > 0)
|
||||
{
|
||||
parallelJob = _jobs[0];
|
||||
_jobs.Remove(parallelJob);
|
||||
}
|
||||
}
|
||||
if (parallelJob != null)
|
||||
{
|
||||
parallelJob.Run();
|
||||
parallelJob = null;
|
||||
}
|
||||
}
|
||||
lock (_convergeLock)
|
||||
{
|
||||
_convergeCount++;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator KillAll(Action callback = null)
|
||||
{
|
||||
_quit = true;
|
||||
_convergeCount = 0;
|
||||
lock (_jobsLock)
|
||||
{
|
||||
_jobs.Clear();
|
||||
}
|
||||
_semaphore.Release(_threads.Length);
|
||||
while (_convergeCount < _threads.Length)
|
||||
{
|
||||
yield return 0;
|
||||
}
|
||||
callback.Call();
|
||||
}
|
||||
|
||||
public void AddJob(ParallelJob job)
|
||||
{
|
||||
lock (_jobsLock)
|
||||
{
|
||||
_jobs.Add(job);
|
||||
}
|
||||
_semaphore.Release();
|
||||
}
|
||||
}
|
||||
10
SVSim.BattleEngine/Engine/Cute/PCPlatform.cs
Normal file
10
SVSim.BattleEngine/Engine/Cute/PCPlatform.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using LitJson;
|
||||
|
||||
namespace Cute;
|
||||
|
||||
public abstract class PCPlatform
|
||||
{
|
||||
public abstract void Parse(JsonData response);
|
||||
|
||||
public abstract PaymentPCStartParams SetParameter(string productId, bool isAlertAgree, bool isAlertActive);
|
||||
}
|
||||
34
SVSim.BattleEngine/Engine/Cute/PCPlatformSTEAM.cs
Normal file
34
SVSim.BattleEngine/Engine/Cute/PCPlatformSTEAM.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using LitJson;
|
||||
|
||||
namespace Cute;
|
||||
|
||||
public class PCPlatformSTEAM : PCPlatform
|
||||
{
|
||||
protected PaymentPCStartParamsSTEAM _postParams = new PaymentPCStartParamsSTEAM();
|
||||
|
||||
public static string State { get; private set; }
|
||||
|
||||
public static string Country { get; private set; }
|
||||
|
||||
public static string Currency { get; private set; }
|
||||
|
||||
public static string Status { get; private set; }
|
||||
|
||||
public override PaymentPCStartParams SetParameter(string productId, bool isAlertAgree, bool isAlertActive)
|
||||
{
|
||||
_postParams.product_id = productId;
|
||||
_postParams.price = PaymentPC.GetInstance().ProductPriceList[productId];
|
||||
_postParams.ip_address = Toolbox.DeviceManager.GetIpAddress();
|
||||
_postParams.isalertagree = (isAlertAgree ? 1 : 0);
|
||||
_postParams.isalertactive = (isAlertActive ? 1 : 0);
|
||||
return _postParams;
|
||||
}
|
||||
|
||||
public override void Parse(JsonData response)
|
||||
{
|
||||
State = response["steam_user_info"]["state"].ToString();
|
||||
Country = response["steam_user_info"]["country"].ToString();
|
||||
Currency = response["steam_user_info"]["currency"].ToString();
|
||||
Status = response["steam_user_info"]["status"].ToString();
|
||||
}
|
||||
}
|
||||
12
SVSim.BattleEngine/Engine/Cute/PaymentPCStartParams.cs
Normal file
12
SVSim.BattleEngine/Engine/Cute/PaymentPCStartParams.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Cute;
|
||||
|
||||
public class PaymentPCStartParams : PostParams
|
||||
{
|
||||
public string product_id = "";
|
||||
|
||||
public string price = "";
|
||||
|
||||
public int isalertagree;
|
||||
|
||||
public int isalertactive;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Cute;
|
||||
|
||||
public class PaymentPCStartParamsSTEAM : PaymentPCStartParams
|
||||
{
|
||||
public string ip_address = "";
|
||||
}
|
||||
42
SVSim.BattleEngine/Engine/Cute/PaymentPCStartTask.cs
Normal file
42
SVSim.BattleEngine/Engine/Cute/PaymentPCStartTask.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
namespace Cute;
|
||||
|
||||
public class PaymentPCStartTask : NetworkTask
|
||||
{
|
||||
protected PCPlatform _platform;
|
||||
|
||||
protected CuteNetworkDefine.ApiType _apiType = CuteNetworkDefine.ApiType.PaymentPCStart;
|
||||
|
||||
public PaymentBase.RefundWarningType NeedRefundWarningType { get; private set; }
|
||||
|
||||
public override string Url => $"{CustomPreference.GetApplicationServerURL()}{CuteNetworkDefine.ApiUrlList[_apiType]}";
|
||||
|
||||
public PaymentPCStartTask()
|
||||
{
|
||||
_platform = new PCPlatformSTEAM();
|
||||
}
|
||||
|
||||
public void SetParameter(string ProductId, bool isAlertAgree, bool isAlertActive)
|
||||
{
|
||||
base.Params = _platform.SetParameter(ProductId, isAlertAgree, isAlertActive);
|
||||
}
|
||||
|
||||
protected override int Parse()
|
||||
{
|
||||
int num = base.Parse();
|
||||
if (num != 1)
|
||||
{
|
||||
return num;
|
||||
}
|
||||
if (base.ResponseData["data"].Count > 0)
|
||||
{
|
||||
_platform.Parse(base.ResponseData["data"]);
|
||||
NeedRefundWarningType = (PaymentBase.RefundWarningType)base.ResponseData["data"]["refund_penalty_type"].ToInt();
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public PCPlatform getPCPlatform()
|
||||
{
|
||||
return _platform;
|
||||
}
|
||||
}
|
||||
210
SVSim.BattleEngine/Engine/Cute/SocialServiceUtility.cs
Normal file
210
SVSim.BattleEngine/Engine/Cute/SocialServiceUtility.cs
Normal file
@@ -0,0 +1,210 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Facebook.Unity;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cute;
|
||||
|
||||
public class SocialServiceUtility : MonoBehaviour
|
||||
{
|
||||
private bool isLogin_;
|
||||
|
||||
private bool isCountTime;
|
||||
|
||||
private float timer;
|
||||
|
||||
public bool IsRunning { get; protected set; }
|
||||
|
||||
public bool IsLoggedIn
|
||||
{
|
||||
get
|
||||
{
|
||||
return isLogin_;
|
||||
}
|
||||
protected set
|
||||
{
|
||||
isLogin_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string SocialServiceUserId { get; private set; }
|
||||
|
||||
public string FirebaseIdToken { get; private set; }
|
||||
|
||||
public string FaceBookAccountId { get; private set; }
|
||||
|
||||
public string FaceBookAuthenticationToken { get; private set; }
|
||||
|
||||
public bool FaceBookIsLoggedIn => FB.IsLoggedIn;
|
||||
|
||||
public static SocialServiceUtility Instance { get; private set; }
|
||||
|
||||
public static SocialServiceUtility CreateInstance()
|
||||
{
|
||||
if (null == Instance)
|
||||
{
|
||||
Instance = new GameObject(typeof(SocialServiceUtility).Name).AddComponent<SocialServiceUtility>();
|
||||
UnityEngine.Object.DontDestroyOnLoad(Instance);
|
||||
}
|
||||
return Instance;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (isCountTime)
|
||||
{
|
||||
checkTimeOut();
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
}
|
||||
|
||||
private void AndroidInit()
|
||||
{
|
||||
}
|
||||
|
||||
private void FbInit()
|
||||
{
|
||||
}
|
||||
|
||||
public void FbSignIn(string nonce, Action<bool> onetimeCallback)
|
||||
{
|
||||
if (IsRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (FaceBookIsLoggedIn && FaceBookAccountId != null)
|
||||
{
|
||||
if (onetimeCallback != null)
|
||||
{
|
||||
onetimeCallback(FaceBookIsLoggedIn);
|
||||
}
|
||||
return;
|
||||
}
|
||||
IsRunning = true;
|
||||
INetworkUI networkUI = Toolbox.NetworkManager.NetworkUI;
|
||||
networkUI.StartLoading();
|
||||
FB.LogInWithReadPermissions(new List<string> { "public_profile" }, delegate(ILoginResult result)
|
||||
{
|
||||
IsRunning = false;
|
||||
networkUI.StopLoading();
|
||||
if (result == null)
|
||||
{
|
||||
onetimeCallback(obj: false);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(result.Error))
|
||||
{
|
||||
onetimeCallback(obj: false);
|
||||
}
|
||||
else if (result.Cancelled)
|
||||
{
|
||||
onetimeCallback(obj: false);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(result.RawResult))
|
||||
{
|
||||
FaceBookAccountId = AccessToken.CurrentAccessToken.TokenString;
|
||||
FaceBookAuthenticationToken = "";
|
||||
onetimeCallback(obj: true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerator SignIn(Action<bool> onetimeCallback)
|
||||
{
|
||||
if (IsRunning)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
if (IsLoggedIn && SocialServiceUserId != null)
|
||||
{
|
||||
onetimeCallback?.Invoke(IsLoggedIn);
|
||||
yield break;
|
||||
}
|
||||
IsRunning = true;
|
||||
INetworkUI networkUI = Toolbox.NetworkManager.NetworkUI;
|
||||
networkUI.StartLoading();
|
||||
StartTimeCount();
|
||||
UnitySocialPlatformSingIn(networkUI);
|
||||
while (IsRunning)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
onetimeCallback(IsLoggedIn);
|
||||
}
|
||||
|
||||
public void UnitySocialPlatformSingIn(INetworkUI networkUI)
|
||||
{
|
||||
Social.localUser.Authenticate(delegate(bool result)
|
||||
{
|
||||
if (IsRunning && !result)
|
||||
{
|
||||
IsLoggedIn = false;
|
||||
IsRunning = false;
|
||||
StopTimeCount();
|
||||
networkUI.StopLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getFirebaseIdToken(INetworkUI networkUI)
|
||||
{
|
||||
}
|
||||
|
||||
public void FbSignOut()
|
||||
{
|
||||
if (FaceBookIsLoggedIn)
|
||||
{
|
||||
FB.LogOut();
|
||||
FaceBookAccountId = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SignOut(Action onetimeCallback = null)
|
||||
{
|
||||
if (IsLoggedIn && !IsRunning)
|
||||
{
|
||||
IsRunning = true;
|
||||
IsRunning = false;
|
||||
IsLoggedIn = false;
|
||||
onetimeCallback?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetSocialServiceName()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public static int GetSocialServiceType()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void StartTimeCount()
|
||||
{
|
||||
isCountTime = true;
|
||||
}
|
||||
|
||||
public void StopTimeCount()
|
||||
{
|
||||
isCountTime = false;
|
||||
timer = 0f;
|
||||
}
|
||||
|
||||
private void checkTimeOut()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
if (timer >= 30f)
|
||||
{
|
||||
timer = 0f;
|
||||
INetworkUI networkUI = Toolbox.NetworkManager.NetworkUI;
|
||||
networkUI.StopLoading();
|
||||
StopTimeCount();
|
||||
networkUI.OpenSocialServiceNoResponseErrorPopup();
|
||||
IsRunning = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user