public Level(LocalLevel level) { LocalLevel = level; LevelString = DecompressLevel(level.LevelString); ParseObjects(); }
/// <summary> /// Decompresses a level's string. /// </summary> /// <param name="level">A local level.</param> /// <returns>The decompressed level string.</returns> public static string DecompressLevel(LocalLevel level) { if (!level.LevelString.StartsWith("H4sIAAAAAAAA")) { throw new ArgumentException("The provided level string is invalid."); } return(Encoding.ASCII.GetString(GameManager.Decompress(Base64.DecodeToBytes(level.LevelString)))); }
public static LocalLevel Load(string levelString) { var lvl = new LocalLevel(); var props = typeof(LocalLevel).GetProperties(); foreach (var prop in props) { var attrs = prop.GetCustomAttributes(false); foreach (var attr in attrs) { if (attr is GdXmlAttribute gdattr) { prop.SetValue(lvl, LocalLevelManager.GetPair(levelString, gdattr.Key, prop.PropertyType).Value); } } } return(lvl); }
/// <summary> /// A way to load a level. /// </summary> /// <param name="localLevel">Loads over a <see cref="LocalLevel" /> instance.</param> /// <returns>A parsed level.</returns> public static Level Load(LocalLevel localLevel) { var level = new Level(localLevel); return(level); }