private static void SaveGame() { Save = new SaveData(); var metadata = SaveFileMeta.CreateCurrentMetadata(); var foundMetadata = GetLobbySaveMetadata(); Save.SaveFileMeta = foundMetadata ?? metadata; if (string.IsNullOrEmpty(Save.SaveFileMeta.FileName)) { do { Save.SaveFileMeta.FileName = Guid.NewGuid().ToString(); }while (File.Exists(Save.SaveFileMeta.FilePath)); } try { var json = JSONWriter.ToJson(Save); File.WriteAllText(Save.SaveFileMeta.FilePath, json); if (ReferenceEquals(Save.SaveFileMeta, metadata)) { SavesMetadata.Add(metadata); UpdateSavesMetadata(); } Chat.AddMessage(Language.GetString(LanguageConsts.PS_CHAT_SAVE)); } catch (Exception e) { Debug.LogWarning("[ProperSave] Couldn't save game"); } }
private static void SaveGame() { var save = ProperSavePlugin.CurrentSave = new SaveFile { SaveFileMeta = SaveFileMetadata.GetCurrentLobbySaveMetadata() ?? SaveFileMetadata.CreateMetadataForCurrentLobby() }; if (string.IsNullOrEmpty(save.SaveFileMeta.FileName)) { do { save.SaveFileMeta.FileName = Guid.NewGuid().ToString(); }while (File.Exists(save.SaveFileMeta.FilePath)); } try { var json = JSONWriter.ToJson(save); File.WriteAllText(save.SaveFileMeta.FilePath, json); SaveFileMetadata.AddIfNotExists(save.SaveFileMeta); Chat.AddMessage(Language.GetString(LanguageConsts.PS_CHAT_SAVE)); } catch (Exception e) { ProperSavePlugin.InstanceLogger.LogWarning("Failed to save the game"); ProperSavePlugin.InstanceLogger.LogError(e); } }
private static void SaveGame() { string filePath = GetSavePath(); var save = new SaveData(); var json = JSONWriter.ToJson(save); File.WriteAllText(filePath, json); }
public void DidStep(FrameSyncEngine engine, FrameSyncGame game) { if (_watchStarted && game.gameState == FrameSyncGameState.Running) { _watchStarted = false; float ms = _watch.Stop(); SWConsole.Verbose($"Debugger DidStep {game.frameNumber} ms={ms}"); //_watcStarted might be in wrong state if (game.frameNumber == 0) { return; } _debugFrame.frameNumber = game.frameNumber; _debugFrame.elapsedMS = ms; _debugFrame.playerFrameOnServer = engine.PlayerFrameCountOnServer; _debugFrame.localServerFrameCount = engine.LocalServerFrameCount; _debugFrame.inputSampleInterval = FrameSyncTime.internalInputSampleInterval * 1000; _debugFrame.localStepInterval = FrameSyncTime.internalFixedDeltaTime * 1000; SWSystemDataFrame systemDataFrame = engine.GetSystemDataFrame(game.frameNumber); _debugFrame.hash = systemDataFrame.bytes.Crc32(); SWConsole.Verbose($"Debugger DidStep frame hash={_debugFrame.hash}"); InputFrame inputFrame = engine.GetInputFrame(game.frameNumber); FrameSyncInput input = _agent.frameSyncInput; FrameSyncInputConfig inputConfig = input.inputConfig; _debugFrame.inputs.Clear(); foreach (FrameSyncPlayer player in input._Players()) { _debugFrame.inputs[player.PlayerID.ToString()] = player.ExportDictionary(inputConfig, inputFrame.bytes); } _debugFrame.staticBehaviours.Clear(); List <StaticFrameSyncBehaviour> staticFrameSyncBehaviours = new List <StaticFrameSyncBehaviour>(StaticFrameSyncBehaviourManager._behaviours.Values); foreach (StaticFrameSyncBehaviour behaviour in staticFrameSyncBehaviours) { _debugFrame.staticBehaviours[behaviour.FrameSyncBehaviourID.ToString()] = behaviour.ExportDictionary(); } string json = JSONWriter.ToJson(_debugFrame); SWConsole.Verbose(json); if (game.type == FrameSyncGameType.Offline) { SendData(json, 1); } else { SendData(json, game.localPlayer.PlayerID); } } }
public static void UploadRecordedData(RecordedData recordedData) { string data = JSONWriter.ToJson(recordedData); Debug.Log(data); Debug.Log($"{PlayTestToolkitSettings.API_DATA_ROUTE}/{recordedData.ConfigId}"); string message = HttpActions.JsonAction(data, $"{PlayTestToolkitSettings.API_DATA_ROUTE}/{recordedData.ConfigId}"); Debug.Log(message); }
public string toJSON() { //return "{" + // $" \"sdpMid\": \"{sdpMid ?? sdpMLineIndex.ToString()}\"," + // $" \"sdpMLineIndex\": {sdpMLineIndex}," + // $" \"usernameFragment\": \"{usernameFragment}\"," + // $" \"candidate\": \"{candidate}\"" + // "}"; return(JSONWriter.ToJson(this)); }
/// <summary> /// /// </summary> /// <param name="args"></param> /// <returns></returns> private static int Main(string[] args) { TemplateResults results = new TemplateResults(); if (args.Length == 0) { ShowHelp(); results.wasSuccssful = false; } else if (args[0] == HELP_ARG) { ShowHelp(); results.wasSuccssful = true; } else if (args.Length < 2) { ShowHelp(); results.wasSuccssful = false; } else { string input = args.First(); string output = args.Last(); results.inputPath = input; results.outputPath = output; // Create our generator TemplateGenerator geneator = new TemplateGenerator(); // run it geneator.ProcessTemplate(input, output); if (geneator.Errors.HasErrors) { foreach (CompilerError error in geneator.Errors) { results.compileErrors.Add(error); } results.wasSuccssful = false; } else { results.wasSuccssful = true; } } // Write our output string outputJson = JSONWriter.ToJson(results); // Write it out Console.WriteLine(outputJson); return(results.wasSuccssful ? 0 : 1); }
static void Postfix(StageControl __instance, int ___mapConfigSceneID) { var mapConfig = XML_Loader.instance.mapConfigs[___mapConfigSceneID]; LogF($"当前地图 {mapConfig.MapNameCHS} mapConfigSceneID={___mapConfigSceneID} stageMapId={__instance.stageMapId} " + $"sceneLevel={__instance.sceneLevel} LevelLoad.Count={LevelLoad.instances.Count}"); LevelLoad.instances.Select((s, i) => { LogF($"LevelLoad_{i} sceneIndex={JSONWriter.ToJson(s.sceneIndex)}"); return(i); }).ToList().ToString(); }
public static void UpdatePlayTestConfig(PlayTest playtest) { if (string.IsNullOrEmpty(playtest.Id)) { return; } ConfigFile config = new ConfigFile(playtest); string data = JSONWriter.ToJson(config); string message = HttpActions.JsonAction(data, $"{API_CONFIG_ROUTE}/{playtest.Id}", "PUT"); Debug.Log(message); }
public static void UploadPlayTestConfig(PlayTest playtest) { if (!string.IsNullOrEmpty(playtest.Id)) { return; } ConfigFile config = new ConfigFile(playtest); string data = JSONWriter.ToJson(config); string message = HttpActions.JsonAction(data, API_CONFIG_ROUTE); Debug.Log(message); playtest.Id = JSONParser.FromJson <ConfigFile>(message).Id; }
private static void UpdateSavesMetadata() { var path = $"{SavesDirectory}\\SavesMetadata.json"; if (!Directory.Exists(SavesDirectory)) { Directory.CreateDirectory(SavesDirectory); } try { File.WriteAllText(path, JSONWriter.ToJson(SavesMetadata)); } catch (Exception e) { Debug.LogWarning("[ProperSave] Can't update SavesMetadata file"); } }
private static void UpdateSaveMetadata() { var path = $"{ProperSavePlugin.SavesDirectory}\\SavesMetadata.json"; if (!Directory.Exists(ProperSavePlugin.SavesDirectory)) { Directory.CreateDirectory(ProperSavePlugin.SavesDirectory); } try { File.WriteAllText(path, JSONWriter.ToJson(SavesMetadata)); } catch (Exception e) { ProperSavePlugin.InstanceLogger.LogWarning("Can't update SavesMetadata file"); ProperSavePlugin.InstanceLogger.LogError(e); } }
private static void save() { if (File.Exists(_settingServerFilePath)) { File.Delete(_settingServerFilePath); } using (FileStream file = File.Create(_settingServerFilePath)) { string json = JSONWriter.ToJson(info); Byte[] data = new UTF8Encoding(true).GetBytes(json); file.Write(data, 0, data.Length); } if (File.Exists(_settingTreeFilePath)) { File.Delete(_settingTreeFilePath); } using (FileStream file = File.Create(_settingTreeFilePath)) { string json = JSONWriter.ToJson(tree); Byte[] data = new UTF8Encoding(true).GetBytes(json); file.Write(data, 0, data.Length); } if (File.Exists(_settingCommandFilePath)) { File.Delete(_settingCommandFilePath); } using (FileStream file = File.Create(_settingCommandFilePath)) { string json = JSONWriter.ToJson(commands); Byte[] data = new UTF8Encoding(true).GetBytes(json); file.Write(data, 0, data.Length); } Console.WriteLine(string.Format("[JSON] saved files")); }
public static string getSyncTree() { return("SYNCSET;tree;" + JSONWriter.ToJson(tree)); }
public static void resyncTree(Setting_Tree _tree) { ServerConnection.send("RESYNCSET;tree;" + JSONWriter.ToJson(_tree)); tree = _tree; }
public string Encode(object item) { return(JSONWriter.ToJson(item)); }
public static void resyncCommands(Setting_Device_Commmand[] _commands) { ServerConnection.send("RESYNCSET;commands;" + JSONWriter.ToJson(_commands)); commands = _commands; }
/// <summary> /// Ritorna rappresentazione JSON dell'oggetto /// </summary> /// <returns></returns> public virtual string ToJSON() { return(JSONWriter.ToJson(this)); }
public void Login() { SendString(DefCmd.Login, MessageType.Def, JSONWriter.ToJson(userInfo)); }
public static void load() { string json = ""; if (!File.Exists(_settingServerFilePath)) { using (FileStream file = File.Create(_settingServerFilePath)) { json = JSONWriter.ToJson(new Setting_Info() { name = "Tree Of Live", ip = "192.168.1.3", port = 11000, auth_key = "AABBCCDD11223344" }); Byte[] data = new UTF8Encoding(true).GetBytes(json); file.Write(data, 0, data.Length); } } else { json = ""; using (StreamReader sr = File.OpenText(_settingServerFilePath)){ json = sr.ReadLine(); } } info = JSONParser.FromJson <Setting_Info>(json); Console.WriteLine(string.Format("[JSON] info file: {0}", json)); json = ""; if (!File.Exists(_settingTreeFilePath)) { using (FileStream file = File.Create(_settingTreeFilePath)) { Setting_RGB _normal = new Setting_RGB() { r = 255, g = 255, b = 255 }; Setting_RGB _blink = new Setting_RGB() { r = 123, g = 123, b = 123 }; json = JSONWriter.ToJson(new Setting_Tree() { normal = _normal, blink = _blink }); Byte[] data = new UTF8Encoding(true).GetBytes(json); file.Write(data, 0, data.Length); } } else { json = ""; using (StreamReader sr = File.OpenText(_settingTreeFilePath)){ json = sr.ReadLine(); } } tree = JSONParser.FromJson <Setting_Tree>(json); Console.WriteLine(string.Format("[JSON] info file: {0}", json)); json = ""; if (!File.Exists(_settingCommandFilePath)) { using (FileStream file = File.Create(_settingCommandFilePath)) { json = JSONWriter.ToJson(new Setting_Device_Commmand[0]); Byte[] data = new UTF8Encoding(true).GetBytes(json); file.Write(data, 0, data.Length); } } else { json = ""; using (StreamReader sr = File.OpenText(_settingCommandFilePath)){ json = sr.ReadLine(); } } commands = JSONParser.FromJson <Setting_Device_Commmand[]>(json); Console.WriteLine(string.Format("[JSON] info file: {0}", json)); return; }
public static string getSyncCommands() { return("SYNCSET;commands;" + JSONWriter.ToJson(commands)); }
public static void resyncInfo(Setting_Info _info) { ServerConnection.send("RESYNCSET;info;" + JSONWriter.ToJson(_info)); info = _info; }
public static string getSyncInfo() { return("SYNCSET;info;" + JSONWriter.ToJson(info)); }