/* After this method is called, the conditions for this promise will be checked every frame */ public void StartPollUpdateGlobal() { foreach (KeyValuePair <string, Action> pair in GetUpdates()) { MonoHelper.MonoRegisterUpdateFunction(pair.Key, pair.Value); } }
private static Task ExecuteWorkerService(string commandVerb, InstallDirectoryItem appInstallation, int?timeoutSeconds = null, string startOptions = null) { var workerServiceFile = Path.Combine(appInstallation.Directory.FullName, WorkerServiceFile); var workerServiceArguments = BuildServiceCommand(commandVerb, appInstallation, timeoutSeconds, startOptions); return(MonoHelper.ExecuteProcessAsync(workerServiceFile, workerServiceArguments)); }
// private void _socket_OnError(object sender, ErrorEventArgs e) { MonoHelper.InvokeOnMainThread(() => { Debug.LogException(e.Exception); }); }
void DelayHandleImport() { MonoHelper.RemoveUpdateListener(DelayHandleImport); if (mImageFiles != null && mImageFiles.Length > 0) { mSprites = new Sprite[mImageFiles.Length]; } else { mSprites = null; } if (mImageFiles != null && mImageFiles.Length > 0) { for (int i = 0; i < mImageFiles.Length; i++) { FileStream fs = new FileStream(mImageFiles[i], FileMode.Open); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); fs.Close(); var originalTex = new Texture2D(2, 2); originalTex.LoadImage(buffer); originalTex.Apply(); mSprites[i] = ChangeToSprite(originalTex); } } Show(); }
//========================================================================================== #region 日志 public static void UploadLog() { if (m_IsLogUploading) { m_LogUploadTips = "正在上传中,请稍候再操作.."; return; } try { byte[] bytes = LoadCurrentLogFile(); if (bytes != null && bytes.Length > 0) { WWWForm form = new WWWForm(); form.AddField("User", 0); form.AddField("Time", (int)TimeUtils.GetTotalSecondsSince1970()); form.AddBinaryData("Content", bytes); WWW www = new WWW(m_LogUploadUrl, form); MonoHelper.StartCoroutine(UploadLogPost(www)); m_IsLogUploading = true; } } catch (Exception e) { Debuger.LogError("SGFDebugerGUI", "Upload() Failed: " + e.Message + e.StackTrace); return; } }
public void RequestMemoryAsync(MemoryQuest memory_quest, MemoryLoadCallbackFunc callback) { if (AppConst.UseUpdatOriModeReal && AppConst.UseUpdatOriThreadMode) { if (this.m_thread == null) { this.m_thread = new Thread(new ThreadStart(this.OnThreadUpdate)); this.m_thread.Start(); } DownloadData data = new DownloadData(); data.callback = callback; data.memory_quest = memory_quest; //如果没有传save_path,则默认是下载byte[]数据 if (string.IsNullOrEmpty(memory_quest.save_path)) { data.IsFile = false; } else { data.IsFile = true; } Queue <DownloadData> request_list = ResRequest.m_request_list; lock (request_list) { ResRequest.m_request_list.Enqueue(data); } } else { MonoHelper.StartCoroutine(this.LoadToMemoryAsyncImpl(memory_quest, callback)); } }
public void MigrateToLatest() { var announcer = new TextWriterAnnouncer(s => SharpStarLogger.DefaultLogger.Debug(s)); var assembly = Assembly.GetExecutingAssembly(); var migrationContext = new RunnerContext(announcer) { Namespace = "SharpStar.Database.Migrations" }; var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 }; ReflectionBasedDbFactory factory; if (MonoHelper.IsRunningOnMono()) { factory = new MonoSQLiteDbFactory(); } else { factory = new SqliteDbFactory(); } var connection = factory.CreateConnection(_config.GetProperty(NHibernate.Cfg.Environment.ConnectionString)); var processor = new SqliteProcessor(connection, new SqliteGenerator(), announcer, options, factory); var runner = new MigrationRunner(assembly, migrationContext, processor); runner.MigrateUp(true); }
public ISessionFactory GetSessionFactory() { var config = Fluently.Configure(); if (!File.Exists(DatabaseName)) { config = config.ExposeConfiguration(p => new SchemaExport(p).Execute(false, true, false)); } if (MonoHelper.IsRunningOnMono()) { config = config.Database(MonoSQLiteConfiguration.Standard.UsingFile(DatabaseName)); } else { config = config.Database(SQLiteConfiguration.Standard.UsingFile(DatabaseName)); } _config = config .Mappings(p => p.FluentMappings.AddFromAssemblyOf <SharpStarUser>()) .BuildConfiguration(); MigrateToLatest(); return(config.BuildSessionFactory()); }
public WebSocketServer(string location) { var uri = new Uri(location); Port = uri.Port; Location = location; _locationIP = ParseIPAddress(uri); _scheme = uri.Scheme; var socket = new Socket(_locationIP.AddressFamily, SocketType.Stream, ProtocolType.IP); if (!MonoHelper.IsRunningOnMono()) { #if __MonoCS__ #else #if !NET45 if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) #endif { socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false); } #if !NET45 if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1); } #endif #endif } ListenerSocket = new SocketWrapper(socket); SupportedSubProtocols = new string[0]; }
/// <summary> /// start the game /// </summary> /// <param name="param"></param> public void Start(GameParam param) { GameManager.Instance.CreateGame(param); GameManager.Instance.onPlayerDie += OnPlayerDie; m_context = GameManager.Instance.Context; PlayerData pd = new PlayerData(); pd.id = m_mainPlayerId; pd.userId = UserManager.Instance.MainUserData.id; pd.snakeData.id = SkinManager.Instance.SkinType; pd.snakeData.length = 50; pd.ai = 0; GameManager.Instance.RegPlayerData(pd); //initial Game Input GameInput.Create(); GameInput.OnVkey += OnVKey; //listen on EnterFrame MonoHelper.AddFixedUpdateListener(FixedUpdate); GameCamera.FocusPlayerId = m_mainPlayerId; }
public static JSONClass ToJSON(MonoHelper helper) { JSONClass componentData = new JSONClass(); componentData.Add("hash", new JSONData(helper.monoID)); componentData.Add("fields", GetFields(helper)); return componentData; }
public void LoadSceneAsync(string sceneName, AsyncSceneCallBack data = null, LoadSceneMode mode = LoadSceneMode.Single) { if (_asyncRecordDic.ContainsKey(sceneName)) { Debuger.LogError($"repeat load scene {sceneName}"); } else { _asyncRecordDic.Add(sceneName, data); } var async = SceneManager.LoadSceneAsync(sceneName, mode); async.completed += operation => { if (_asyncRecordDic.ContainsKey(sceneName)) { var recordData = _asyncRecordDic[sceneName]; recordData.Progress = 0.9f; } _removeSceneList.Add(sceneName); }; MonoHelper.GlobalStartCoroutine(LoadSceneAsync(sceneName, async)); }
public static void StartHotfix() { #if XLUA LuaHelper.StartHotfix(); #else MonoHelper.StartHotfix(); #endif }
public void Close() { if (AppConst.UpdateMode && ResUpdateManager.Instance != null) { ResUpdateManager.Instance.Close(); } MonoHelper.RemoveUpdateListener(Update); }
private void _socket_OnMessage(object sender, MessageEventArgs e) { MonoHelper.InvokeOnMainThread(() => { ChatModel model = JsonUtility.FromJson <ChatModel>(e.Data); OnChat(model); }); }
void Process_Exited(object sender, EventArgs e) { Process tempP = sender as Process; StreamReader tempSr = tempP.StandardOutput; string tempText = tempSr.ReadToEnd(); mImageFiles = tempText.Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); MonoHelper.AddUpdateListener(DelayHandleImport); }
protected void SetError(string message) { if (MonoHelper.IsRunningOnMono && MonoHelper.IsOlderVersionThan("2.4")) { return; } errorProvider.SetError(this, message); }
static void EnsureInitialized() { if (_instance == null) { var go = new GameObject("_MonoHelper"); DontDestroyOnLoad(go); _instance = go.AddComponent <MonoHelper>(); } }
public ClipMidiEvent(Params ps) : base(ps) { this.clipName = ps.GetString("ClipName"); this.channel = ps.GetInt("Channel"); this.type = (Midi.MidiMessage.Type)Enum.Parse(typeof(Midi.MidiMessage.Type), ps.GetString("MessageType")); this.clip = MonoHelper.MonoFindClip(clipName); this.tracker = clip.GetTracker(); }
public static void UseLinuxIfAvailable(this HostConfigurator configurator) { if (MonoHelper.RunninOnLinux) { // Needed to overcome mono-service style arguments. configurator.ApplyCommandLine(MonoHelper.GetUnparsedCommandLine()); configurator.UseEnvironmentBuilder((cfg) => new LinuxHostEnvironmentBuilder(cfg)); } }
public ActionResult Download() { string fileName = Request ["FileName"]; string decodedFileName = MonoHelper.DecodeName(fileName); FileModel downloadFile = new FileModel(decodedFileName); return(File(downloadFile.File.FullName, "application/octet-stream", downloadFile.File.Name)); }
public void LoadModel(string name) { uniFBXImport.setting.paths.urlModels = Constant.GetModelPath(); uniFBXImport.setting.paths.urlTextures = Constant.GetModelTexPath(); uniFBXImport.setting.paths.filename = name; uniFBXImport.Load(); MonoHelper.StartCoroutine(WaitForLoad()); ShowModelList(); }
static SharpStarLogger() { _pluginLoggers = new Dictionary <string, SharpStarLogger>(); PatternLayout layout = new PatternLayout(); layout.ConversionPattern = "%level - %message%newline"; layout.ActivateOptions(); IAppender appender; if (MonoHelper.IsRunningOnMono()) { AnsiColorTerminalAppender ansiColor = new AnsiColorTerminalAppender(); ansiColor.AddMapping(new AnsiColorTerminalAppender.LevelColors { Level = Level.Info, ForeColor = AnsiColorTerminalAppender.AnsiColor.Blue, BackColor = AnsiColorTerminalAppender.AnsiColor.White }); ansiColor.AddMapping(new AnsiColorTerminalAppender.LevelColors { Level = Level.Debug, ForeColor = AnsiColorTerminalAppender.AnsiColor.White, BackColor = AnsiColorTerminalAppender.AnsiColor.Blue }); ansiColor.AddMapping(new AnsiColorTerminalAppender.LevelColors { Level = Level.Warn, ForeColor = AnsiColorTerminalAppender.AnsiColor.Yellow, BackColor = AnsiColorTerminalAppender.AnsiColor.Magenta }); ansiColor.AddMapping(new AnsiColorTerminalAppender.LevelColors { Level = Level.Error, ForeColor = AnsiColorTerminalAppender.AnsiColor.Yellow, BackColor = AnsiColorTerminalAppender.AnsiColor.Red }); ansiColor.Layout = layout; ansiColor.ActivateOptions(); appender = ansiColor; } else { ColoredConsoleAppender colorAppender = new ColoredConsoleAppender(); colorAppender.AddMapping(new ColoredConsoleAppender.LevelColors { Level = Level.Info, ForeColor = ColoredConsoleAppender.Colors.Blue | ColoredConsoleAppender.Colors.HighIntensity, BackColor = ColoredConsoleAppender.Colors.White }); colorAppender.AddMapping(new ColoredConsoleAppender.LevelColors { Level = Level.Debug, ForeColor = ColoredConsoleAppender.Colors.White | ColoredConsoleAppender.Colors.HighIntensity, BackColor = ColoredConsoleAppender.Colors.Blue }); colorAppender.AddMapping(new ColoredConsoleAppender.LevelColors { Level = Level.Warn, ForeColor = ColoredConsoleAppender.Colors.Yellow | ColoredConsoleAppender.Colors.HighIntensity, BackColor = ColoredConsoleAppender.Colors.Purple }); colorAppender.AddMapping(new ColoredConsoleAppender.LevelColors { Level = Level.Error, ForeColor = ColoredConsoleAppender.Colors.Yellow | ColoredConsoleAppender.Colors.HighIntensity, BackColor = ColoredConsoleAppender.Colors.Red }); colorAppender.Layout = layout; colorAppender.ActivateOptions(); appender = colorAppender; } ((Logger)Log.Logger).AddAppender(appender); }
private void _socket_OnMessage(object sender, MessageEventArgs e) { Debug.Log("hgv"); MonoHelper.InvokeOnMainThread(() => { ChatModel model = JsonUtility.FromJson <ChatModel>(e.Data); ChatService.call(model); }); }
public void Stop(int timeout = Timeout.Infinite) { try { MonoHelper.ExecuteProcessSync("service", $" {ServiceName} stop", timeout); } catch (Exception error) { throw new InvalidOperationException(string.Format(Properties.Resources.CantStopService, ServiceName), error); } }
public static void AddToHashLookup(MonoHash hash, MonoHelper helper) { string fullPosHash = hash.fullPosHash; if (hashLookup.ContainsKey(fullPosHash)) { MonoHelper oldHash = hashLookup[fullPosHash]; if (oldHash != null && oldHash != helper) { if (!oldHash.gameObject.activeInHierarchy) { MonoBehaviour.Destroy(oldHash.gameObject); hashLookup[fullPosHash] = helper; } else if (oldHash.name != helper.name) { oldHash.SetName(oldHash.name); // This should remove any old key that's already in there if (hashLookup.ContainsKey(fullPosHash)) // Should never happen { if (!SaveGame.IsLoading()) { throw ThrowHashCollision(oldHash, helper); } MonoBehaviour.Destroy(oldHash.gameObject); hashLookup[fullPosHash] = helper; } else { hashLookup.Add(fullPosHash, helper); } } else { if (!SaveGame.IsLoading()) { throw ThrowHashCollision(oldHash, helper); } MonoBehaviour.Destroy(oldHash.gameObject); hashLookup[fullPosHash] = helper; } } else { hashLookup[fullPosHash] = helper; } } else { hashLookup.Add(fullPosHash, helper); } if (!SaveGame.IsLoading()) { Instancing.ObjectLoader.ClearLoadingQueue(); } }
private void PrintArgs() { // 获取命令行参数,第二个开始才是参数 var tempArray = Environment.GetCommandLineArgs(); foreach (string tempStr in tempArray) { Debuger.Log(tempStr); } MonoHelper.RemoveUpdateListener(PrintArgs); }
public static void StartHotfix() { if (Define.IsLua) { LuaHelper.StartHotfix(); } else { MonoHelper.StartHotfix(); } }
public static MonoHelper GetInstance() { if (instance == null) { GameObject go = new GameObject("[MonoHelper]"); GameObject.DontDestroyOnLoad(go); // go.hideFlags = HideFlags.HideAndDontSave; instance = go.AddComponent <MonoHelper>(); } return(instance); }
/// <summary> /// stop the game /// </summary> public void Stop() { MonoHelper.RemoveFixedUpdateListener(FixedUpdate); GameInput.Release(); GameManager.Instance.ReleaseGame(); onGameEnd = null; onMainPlayerDie = null; m_context = null; }
private static Assembly GetAssemblyFor(string assemblyName) { // Due to the fact that Uri lowercase's the assembly name and // that *nix file system's are case sensitive we // need to locate the assembly manually and return it if (MonoHelper.IsMono) { return(MonoHelper.GetLoadedAssembly(assemblyName)); } return(Assembly.Load(assemblyName)); }
public void CheckExtractResource() { bool debugMode = AppConst.DebugMode; if (debugMode) { this.ToNextState(); } else { MonoHelper.StartCoroutine(this.OnExtractResource()); } }
public static Object Load(string path, Vector3 location, MonoHelper instance) { return instance.Load(path, location); }
public MonoSubject(MonoHelper mHelper) { helper = mHelper; AddConstantObservers(); }
private static HashCollisionException ThrowHashCollision(MonoHelper first, MonoHelper second) { string message = "Hash collision detected between " + first + " and " + second + ""; string oldHash = first.monoID; string newHash = second.monoID; if (oldHash == newHash) { message += "! Hash: " + oldHash; } else { message += ", but the hashes did not match. First: " + oldHash + ", Second: " + newHash; } HashCollisionException ex = new HashCollisionException(message); ex.hash = newHash; return ex; }
public MonoObserver(MonoHelper monoHelper) { helper = monoHelper; }
public MonoHash(MonoHelper bHelper) { helper = bHelper; GenerateMonoID(); }
public static MonoHelper GetMonoHelper(GameObject go) { if (go == null) { return null; } MonoHelper helper = null; helper = go.GetComponent<MonoHelper>(); if (helper == null) { helper = go.AddComponent<MonoHelper>(); } return helper; }
public static void LoadField(JSONClass source, System.Reflection.FieldInfo field, MonoHelper dest) { if (source == null) { Console.LogWarning("Cannot find source JSON for " + field.Name + " in " + dest + "!"); throw new SaveGameException(); } string fieldName = field.Name; object value = field.GetValue(dest); if (value == null || value is LuaBinding || source[fieldName] == "") { return; } try { if (value is string) { string result = source[fieldName]; field.SetValue(dest, result); } else if (value is double) { double result = source[fieldName].AsDouble; field.SetValue(dest, result); } else if (value is float) { float result = source[fieldName].AsFloat; field.SetValue(dest, result); } else if (value is bool) { bool result = source[fieldName].AsBool; field.SetValue(dest, result); } else if (value is int) { int result = source[fieldName].AsInt; field.SetValue(dest, result); } else if (value is Color) { Color result = ConvertColor(source[fieldName].AsObject); field.SetValue(dest, result); } else if (value is Vector4) { Vector4 result = ConvertVector4(source[fieldName].AsObject); field.SetValue(dest, result); } else if (value is Vector3) { Vector3 result = ConvertVector3(source[fieldName].AsObject); field.SetValue(dest, result); } else if (value is Vector2) { Vector2 result = ConvertVector2(source[fieldName].AsObject); field.SetValue(dest, result); } else if (value is AudioClip) { JSONClass jsonObject = source[fieldName].AsObject; AudioClip result = AudioManager.GetClip(jsonObject["name"]); field.SetValue(dest, result); } else if (value is Enum) { Enum result = ConvertEnum(source[fieldName].AsObject); field.SetValue(dest, result); } else if (value is GameObject) { string hash = source[OBJECT_ID_JSON_STRING]; if (hash == null) { return; } MonoHelper helper = MonoHelper.GetMonoHelper(hash); if (helper == null || helper.gameObject == null) { return; } field.SetValue(dest, helper.gameObject); } else if (value is MonoHelper) { string hash = source[OBJECT_ID_JSON_STRING]; if (hash == null) { return; } MonoHelper helper = MonoHelper.GetMonoHelper(hash); if (helper == null || helper.gameObject == null) { return; } field.SetValue(dest, helper); } else { Debug.LogWarning(fieldName + " (" + value.GetType() + "): " + value + ", " + source.ToString()); } } catch (Exception ex) { if (!(ex is InvalidOperationException || ex is ArgumentException)) { throw ex; } } }
public static void AddToLoadingQueue(MonoHelper helper) { string hash = helper.monoID; if (loadingQueue.ContainsKey(hash)) { Console.LogWarning("Attempting to load a duplicate hash! " + hash + " in MonoHelper " + helper + " is a duplicate of " + loadingQueue[hash] + "!"); } else { loadingQueue.Add(hash, helper); } }
public static Object Load(string path, Transform parent, Vector3 localPosition, MonoHelper instance) { return instance.Load(path, parent, localPosition); }
public static JSONClass GetFields(MonoHelper source, JSONClass fieldArray) { System.Type t = source.GetType(); BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.FlattenHierarchy; FieldInfo[] fields = t.GetFields(flags); FieldInfo[] badFieldArray = typeof(MonoHelper).GetFields(flags); List<string> badFields = new List<string>(); foreach (FieldInfo field in badFieldArray) { badFields.Add(field.Name); } foreach (FieldInfo field in fields) { object fieldObj = field.GetValue(source); if (fieldObj == null) { continue; } string fieldName = field.Name; if (badFields.Contains(fieldName) || System.Attribute.IsDefined(field, typeof(DontSave))) { continue; } JSONClass fieldData = SaveGame.SaveField(fieldObj, fieldName); if (fieldData == null) { continue; } fieldArray.Add(fieldName, fieldData); } return fieldArray; }
public static JSONClass GetFields(MonoHelper source) { return GetFields(source, new JSONClass()); }
public MonoJSON(MonoHelper mHelper) { helper = mHelper; }