public override void OnSaveData() { Logger.LogDebug($"Start save map data"); string config = string.Empty; try { var sw = Stopwatch.StartNew(); config = Loader.GetString(MarkupManager.ToXml()); #if DEBUG Logger.LogDebug(config); #endif var compress = Loader.Compress(config); serializableDataManager.SaveData(Loader.Id, compress); sw.Stop(); Logger.LogDebug($"Map data saved in {sw.ElapsedMilliseconds}ms; Size = {compress.Length} bytes"); } catch (Exception error) { Logger.LogError("Save map data failed", error); Loader.SaveToFile(Loader.MarkingName, config, out _); throw; } }
public override void OnSaveData() { Logger.LogDebug($"{nameof(Serializer)}.{nameof(OnSaveData)}"); string xml = string.Empty; try { var sw = Stopwatch.StartNew(); var config = MarkupManager.ToXml(); xml = config.ToString(SaveOptions.DisableFormatting); #if DEBUG Logger.LogDebug(xml); #endif var compress = Compress(xml); serializableDataManager.SaveData(Id, compress); sw.Stop(); Logger.LogDebug($"Data saved in {sw.ElapsedMilliseconds}ms; Size = {compress.Length} bytes"); } catch (Exception error) { Logger.LogError(() => "Save data failed", error); SaveSettingDump(xml, out _); throw; } }
public override void OnAssetSaved(string name, object asset, out Dictionary <string, byte[]> userData) { userData = new Dictionary <string, byte[]>(); if (asset is not BuildingInfo prefab || !prefab.m_paths.Any()) { return; } Mod.Logger.Debug($"Start save prefab data \"{prefab.name}\""); try { var config = Loader.GetString(MarkupManager.ToXml()); var data = Loader.Compress(config); userData[DataId] = data; var instance = Singleton <NetManager> .instance; var segmentsId = new List <ushort>(); for (ushort i = 0; i < NetManager.MAX_SEGMENT_COUNT; i += 1) { if ((instance.m_segments.m_buffer[i].m_flags & NetSegment.Flags.Created) == NetSegment.Flags.Created) { segmentsId.Add(i); } } var map = new byte[sizeof(ushort) * 3 * segmentsId.Count]; for (var i = 0; i < segmentsId.Count; i += 1) { var segmentId = segmentsId[i]; var segment = instance.m_segments.m_buffer[segmentId]; GetBytes(segmentId, out map[i * 6], out map[i * 6 + 1]); GetBytes(segment.m_startNode, out map[i * 6 + 2], out map[i * 6 + 3]); GetBytes(segment.m_endNode, out map[i * 6 + 4], out map[i * 6 + 5]); } userData[MapId] = map; Mod.Logger.Debug($"Prefab data was saved; Size = {data.Length} bytes"); } catch (Exception error) { Mod.Logger.Error("Could not save prefab data", error); } }
public static bool OnDumpData(out string path) { Logger.LogDebug($"{nameof(Serializer)}.{nameof(OnDumpData)}"); try { var config = MarkupManager.ToXml(); var xml = config.ToString(SaveOptions.DisableFormatting); return(SaveSettingDump(xml, out path)); } catch (Exception error) { Logger.LogError(() => "Save dump failed", error); path = string.Empty; return(false); } }
public static bool DumpMarkingData(out string path) { Mod.Logger.Debug($"Dump marking data"); return(DumpData(GetString(MarkupManager.ToXml()), MarkingName, out path)); }
protected override XElement GetSaveData() => MarkupManager.ToXml();
public static bool DumpMarkingData(out string path) { Logger.LogDebug($"{nameof(Loader)}.{nameof(DumpMarkingData)}"); return(DumpData(GetString(MarkupManager.ToXml()), MarkingName, out path)); }
protected override XElement GetConfig() => MarkupManager.ToXml();