/// <inheritdoc />
    public void Unserialize(UndertaleReader reader)
    {
        Name          = reader.ReadUndertaleString();
        DisplayName   = reader.ReadUndertaleString();
        EmSize        = reader.ReadUInt32();
        EmSizeIsFloat = false;

        // since the float is always written negated, it has the first bit set.
        if ((EmSize & (1 << 31)) != 0)
        {
            float fsize = -BitConverter.ToSingle(BitConverter.GetBytes(EmSize), 0);
            EmSize        = (uint)fsize;
            EmSizeIsFloat = true;
        }

        Bold         = reader.ReadBoolean();
        Italic       = reader.ReadBoolean();
        RangeStart   = reader.ReadUInt16();
        Charset      = reader.ReadByte();
        AntiAliasing = reader.ReadByte();
        RangeEnd     = reader.ReadUInt32();
        Texture      = reader.ReadUndertaleObjectPointer <UndertaleTexturePageItem>();
        ScaleX       = reader.ReadSingle();
        ScaleY       = reader.ReadSingle();
        if (reader.undertaleData.GeneralInfo?.BytecodeVersion >= 17)
        {
            AscenderOffset = reader.ReadInt32();
        }
        if (reader.undertaleData.GMS2022_2)
        {
            Ascender = reader.ReadUInt32();
        }
        Glyphs = reader.ReadUndertaleObject <UndertalePointerList <Glyph> >();
    }
 public void Unserialize(UndertaleReader reader)
 {
     Name      = reader.ReadUndertaleString();
     IsSmooth  = reader.ReadBoolean();
     IsClosed  = reader.ReadBoolean();
     Precision = reader.ReadUInt32();
     Points    = reader.ReadUndertaleObject <UndertaleSimpleList <PathPoint> >();
 }
            public void Unserialize(UndertaleReader reader)
            {
                Key      = reader.ReadSingle();
                Length   = reader.ReadSingle();
                Stretch  = reader.ReadBoolean();
                Disabled = reader.ReadBoolean();
                int count = reader.ReadInt32();

                Channels = new Dictionary <int, T>();
                for (int i = 0; i < count; i++)
                {
                    int channel = reader.ReadInt32();
                    T   data    = new T();
                    data.Unserialize(reader);
                    Channels[channel] = data;
                }
            }
Beispiel #4
0
 public void Unserialize(UndertaleReader reader)
 {
     DisableDebugger          = reader.ReadByte() != 0 ? true : false;
     BytecodeVersion          = reader.ReadByte();
     Unknown                  = reader.ReadUInt16();
     Filename                 = reader.ReadUndertaleString();
     Config                   = reader.ReadUndertaleString();
     LastObj                  = reader.ReadUInt32();
     LastTile                 = reader.ReadUInt32();
     GameID                   = reader.ReadUInt32();
     Unknown1                 = reader.ReadUInt32();
     Unknown2                 = reader.ReadUInt32();
     Unknown3                 = reader.ReadUInt32();
     Unknown4                 = reader.ReadUInt32();
     Name                     = reader.ReadUndertaleString();
     Major                    = reader.ReadUInt32();
     Minor                    = reader.ReadUInt32();
     Release                  = reader.ReadUInt32();
     Build                    = reader.ReadUInt32();
     DefaultWindowWidth       = reader.ReadUInt32();
     DefaultWindowHeight      = reader.ReadUInt32();
     Info                     = (InfoFlags)reader.ReadUInt32();
     LicenseMD5               = reader.ReadBytes(16);
     LicenseCRC32             = reader.ReadUInt32();
     Timestamp                = reader.ReadUInt64();
     DisplayName              = reader.ReadUndertaleString();
     ActiveTargets1           = reader.ReadUInt32();
     ActiveTargets2           = reader.ReadUInt32();
     FunctionClassifications1 = reader.ReadUInt32();
     FunctionClassifications2 = reader.ReadUInt32();
     SteamAppID               = reader.ReadInt32();
     DebuggerPort             = reader.ReadUInt32();
     RoomOrder                = reader.ReadUndertaleObject <UndertaleSimpleResourcesList <UndertaleRoom, UndertaleChunkROOM> >();
     if (Major >= 2)
     {
         GMS2RandomUID       = reader.ReadBytes(40);
         GMS2FPS             = reader.ReadSingle();
         GMS2AllowStatistics = reader.ReadBoolean();
         GMS2GameGUID        = reader.ReadBytes(16);
     }
     reader.undertaleData.UnsupportedBytecodeVersion = BytecodeVersion < 14 || BytecodeVersion > 17;
     reader.Bytecode14OrLower = BytecodeVersion <= 14;
 }
 public virtual void Unserialize(UndertaleReader reader)
 {
     if (reader.ReadBoolean())
     {
         // The curve data is embedded in this sequence, right here
         IsCurveEmbedded = true;
         if (reader.ReadInt32() != -1)
         {
             throw new IOException("Expected -1");
         }
         EmbeddedAnimCurve = reader.ReadUndertaleObject <UndertaleAnimationCurve>();
     }
     else
     {
         // The curve data is an asset in the project
         IsCurveEmbedded = false;
         AssetAnimCurve  = new UndertaleResourceById <UndertaleAnimationCurve, UndertaleChunkACRV>();
         AssetAnimCurve.Unserialize(reader);
     }
 }
Beispiel #6
0
 public void Unserialize(UndertaleReader reader)
 {
     DisableDebugger = reader.ReadByte() != 0 ? true : false;
     BytecodeVersion = reader.ReadByte();
     Unknown         = reader.ReadUInt16();
     Filename        = reader.ReadUndertaleString();
     Config          = reader.ReadUndertaleString();
     LastObj         = reader.ReadUInt32();
     LastTile        = reader.ReadUInt32();
     GameID          = reader.ReadUInt32();
     byte[] GuidData = reader.ReadBytes(16);
     DirectPlayGuid          = new Guid(GuidData);
     Name                    = reader.ReadUndertaleString();
     Major                   = reader.ReadUInt32();
     Minor                   = reader.ReadUInt32();
     Release                 = reader.ReadUInt32();
     Build                   = reader.ReadUInt32();
     DefaultWindowWidth      = reader.ReadUInt32();
     DefaultWindowHeight     = reader.ReadUInt32();
     Info                    = (InfoFlags)reader.ReadUInt32();
     LicenseMD5              = reader.ReadBytes(16);
     LicenseCRC32            = reader.ReadUInt32();
     Timestamp               = reader.ReadUInt64();
     DisplayName             = reader.ReadUndertaleString();
     ActiveTargets           = reader.ReadUInt64();
     FunctionClassifications = (FunctionClassification)reader.ReadUInt64();
     SteamAppID              = reader.ReadInt32();
     DebuggerPort            = reader.ReadUInt32();
     RoomOrder               = reader.ReadUndertaleObject <UndertaleSimpleResourcesList <UndertaleRoom, UndertaleChunkROOM> >();
     if (Major >= 2)
     {
         // Begin parsing random UID, and verify it based on original algorithm
         GMS2RandomUID = new List <long>();
         Random random      = new Random((int)(Timestamp & 4294967295L));
         long   firstRandom = (long)random.Next() << 32 | (long)random.Next();
         if (reader.ReadInt64() != firstRandom)
         {
             //throw new IOException("Unexpected random UID");
         }
         long  infoNumber = (long)(Timestamp - 1000);
         ulong temp       = (ulong)infoNumber;
         temp = ((temp << 56 & 18374686479671623680UL) | (temp >> 8 & 71776119061217280UL) |
                 (temp << 32 & 280375465082880UL) | (temp >> 16 & 1095216660480UL) | (temp << 8 & 4278190080UL) |
                 (temp >> 24 & 16711680UL) | (temp >> 16 & 65280UL) | (temp >> 32 & 255UL));
         infoNumber  = (long)temp;
         infoNumber ^= firstRandom;
         infoNumber  = ~infoNumber;
         infoNumber ^= ((long)GameID << 32 | (long)GameID);
         infoNumber ^= ((long)(DefaultWindowWidth + (int)Info) << 48 |
                        (long)(DefaultWindowHeight + (int)Info) << 32 |
                        (long)(DefaultWindowHeight + (int)Info) << 16 |
                        (long)(DefaultWindowWidth + (int)Info));
         infoNumber ^= BytecodeVersion;
         int infoLocation = (int)(Math.Abs((int)(Timestamp & 65535L) / 7 + (GameID - DefaultWindowWidth) + RoomOrder.Count) % 4);
         for (int i = 0; i < 4; i++)
         {
             if (i == infoLocation)
             {
                 long curr = reader.ReadInt64();
                 curr = infoNumber;
                 GMS2RandomUID.Add(curr);
             }
             else
             {
                 int first  = reader.ReadInt32();
                 int second = reader.ReadInt32();
                 first  = random.Next();
                 second = random.Next();
                 GMS2RandomUID.Add(((long)first << 32) | (long)second);
             }
         }
         GMS2FPS             = reader.ReadSingle();
         GMS2AllowStatistics = reader.ReadBoolean();
         GMS2GameGUID        = reader.ReadBytes(16);
     }
     reader.undertaleData.UnsupportedBytecodeVersion = BytecodeVersion < 14 || BytecodeVersion > 17;
     reader.Bytecode14OrLower = BytecodeVersion <= 14;
 }
 public void Unserialize(UndertaleReader reader)
 {
     NewFormat        = reader.ReadInt32() == int.MinValue;
     reader.Position -= 4;
     if (NewFormat)
     {
         Unknown1    = reader.ReadUInt32();
         Unknown2    = reader.ReadUInt32();
         Info        = (OptionsFlags)reader.ReadUInt64();
         Scale       = reader.ReadInt32();
         WindowColor = reader.ReadUInt32();
         ColorDepth  = reader.ReadUInt32();
         Resolution  = reader.ReadUInt32();
         Frequency   = reader.ReadUInt32();
         VertexSync  = reader.ReadUInt32();
         Priority    = reader.ReadUInt32();
         BackImage   = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>();
         FrontImage  = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>();
         LoadImage   = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>();
         LoadAlpha   = reader.ReadUInt32();
         Constants   = reader.ReadUndertaleObject <UndertaleSimpleList <Constant> >();
     }
     else
     {
         Info = 0;
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.FullScreen;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.InterpolatePixels;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.UseNewAudio;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.NoBorder;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.ShowCursor;
         }
         Scale = reader.ReadInt32();
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.Sizeable;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.StayOnTop;
         }
         WindowColor = reader.ReadUInt32();
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.ChangeResolution;
         }
         ColorDepth = reader.ReadUInt32();
         Resolution = reader.ReadUInt32();
         Frequency  = reader.ReadUInt32();
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.NoButtons;
         }
         VertexSync = reader.ReadUInt32();
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.ScreenKey;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.HelpKey;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.QuitKey;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.SaveKey;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.ScreenShotKey;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.CloseSec;
         }
         Priority = reader.ReadUInt32();
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.Freeze;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.ShowProgress;
         }
         BackImage  = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>();
         FrontImage = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>();
         LoadImage  = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>();
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.LoadTransparent;
         }
         LoadAlpha = reader.ReadUInt32();
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.ScaleProgress;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.DisplayErrors;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.WriteErrors;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.AbortErrors;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.VariableErrors;
         }
         if (reader.ReadBoolean())
         {
             Info |= OptionsFlags.CreationEventOrder;
         }
         Constants = reader.ReadUndertaleObject <UndertaleSimpleList <Constant> >();
     }
 }
            public void Unserialize(UndertaleReader reader)
            {
                // This reads the string content immediately, if necessary (which it should be)
                UndertaleString ForceReadString()
                {
                    UndertaleString res      = reader.ReadUndertaleString();
                    uint            returnTo = reader.Position;

                    reader.Position = reader.GetOffsetMapRev()[res];
                    reader.ReadUndertaleObject <UndertaleString>();
                    reader.Position = returnTo;
                    return(res);
                }

                ModelName       = ForceReadString();
                Name            = reader.ReadUndertaleString();
                BuiltinName     = reader.ReadInt32();
                Traits          = reader.ReadInt32();
                IsCreationTrack = reader.ReadBoolean();

                int tagCount      = reader.ReadInt32();
                int ownedResCount = reader.ReadInt32();
                int trackCount    = reader.ReadInt32();

                Tags = new List <int>();
                for (int i = 0; i < tagCount; i++)
                {
                    Tags.Add(reader.ReadInt32());
                }

                OwnedResources = new List <UndertaleResource>();
                for (int i = 0; i < ownedResCount; i++)
                {
                    GMAnimCurveString = ForceReadString();
                    if (GMAnimCurveString.Content != "GMAnimCurve")
                    {
                        throw new IOException("Expected GMAnimCurve");
                    }
                    UndertaleAnimationCurve res = new UndertaleAnimationCurve();
                    res.Unserialize(reader);
                    OwnedResources.Add(res);
                }

                Tracks = new List <Track>();
                for (int i = 0; i < trackCount; i++)
                {
                    Tracks.Add(reader.ReadUndertaleObject <Track>());
                }

                // Now, handle specific keyframe/etc. data
                switch (ModelName.Content)
                {
                case "GMAudioTrack":
                    Keyframes = reader.ReadUndertaleObject <AudioKeyframes>();
                    break;

                case "GMInstanceTrack":
                    Keyframes = reader.ReadUndertaleObject <InstanceKeyframes>();
                    break;

                case "GMGraphicTrack":
                    Keyframes = reader.ReadUndertaleObject <GraphicKeyframes>();
                    break;

                case "GMSequenceTrack":
                    Keyframes = reader.ReadUndertaleObject <SequenceKeyframes>();
                    break;

                case "GMSpriteFramesTrack":
                    Keyframes = reader.ReadUndertaleObject <SpriteFramesKeyframes>();
                    break;

                case "GMAssetTrack":     // TODO?
                    throw new NotImplementedException("GMAssetTrack not implemented, report this");

                case "GMBoolTrack":
                    Keyframes = reader.ReadUndertaleObject <BoolKeyframes>();
                    break;

                case "GMStringTrack":
                    Keyframes = reader.ReadUndertaleObject <StringKeyframes>();
                    break;

                // TODO?
                //case "GMIntTrack":
                //  Keyframes = reader.ReadUndertaleObject<IntKeyframes>();
                //  break;
                case "GMRealTrack":
                    Keyframes = reader.ReadUndertaleObject <RealKeyframes>();
                    break;
                }
            }