示例#1
0
 public string GameName()
 {
     try
     {
         IO = GetIO();
         IO.BaseStream.Position = (int)Offsets.TitleName;
         byte[] b = IO.ReadBytes(0x80);
         IO.Close();
         Buffer = null;
         string ss = "";
         //naw return Encoding.Unicode.GetString(b);
         IO = new IOReader(new System.IO.MemoryStream(b));
         for (int i = 0; i < b.Length; i += 2)
         {
             char c = (char)IO.ReadUInt16(true);
             if (c != '\0')
             {
                 ss += c;
             }
         }
         IO.Close();
         return(ss);
     }
     catch { Close(); return(""); }
 }
示例#2
0
        public void Deserialize(IOReader reader)
        {
            // Read segment count.
            ushort segments = reader.ReadUInt16();

            Debug.Log($"Reading {segments} segments...");

            (int count, Tile tile)[] compressed = new(int, Tile)[segments];
示例#3
0
        public void DeserializeAllNew(IOReader reader)
        {
            ClearEntities();

            // Read name map...
            Type[]   blankParams = new Type[0];
            object[] blankArgs   = new object[0];
            int      count       = reader.ReadInt32();

            Type[]            types        = new Type[count];
            ConstructorInfo[] constructors = new ConstructorInfo[count];
            for (int i = 0; i < count; i++)
            {
                string typeName = reader.ReadString();

                Type t = Type.GetType(typeName, false, false);
                if (t == null)
                {
                    throw new Exception($"Entity of type {typeName} could not be found, so cannot be loaded from disk! Reading cannot continue because data length is unknown.");
                }

                var constructor = t.GetConstructor(blankParams);
                if (constructor == null)
                {
                    throw new Exception($"Entity of type {typeName} does not have a no-parameter constructor, so cannot be loaded. Reading cannot continue since data length is unknown.");
                }
                types[i]        = t;
                constructors[i] = constructor;
            }



            count = reader.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                ushort typeMapIndex = reader.ReadUInt16();
                var    constructor  = constructors[typeMapIndex];

                var obj = constructor.Invoke(blankArgs);

                // No need to register: Entities should auto register, especially since the default constructor is being used.
                Entity e = obj as Entity;
                e.Deserialize(reader);
            }
        }
示例#4
0
 public string DisplayName()
 {
     try
     {
         IO = GetIO();
         IO.BaseStream.Position = (int)Offsets.DisplayName;
         string ss = "";
         for (int i = 0; i < 0x80; i += 2)
         {
             char c = (char)IO.ReadUInt16(true);
             if (c != '\0')
             {
                 ss += c;
             }
         }
         IO.Close();
         return(ss);
     }
     catch { Close(); return(""); }
 }