예제 #1
0
        public void Serialize(UndertaleWriter writer)
        {
            writer.Write(Unknown1);
            LanguageCount = (uint)Languages.Count;
            writer.Write(LanguageCount);
            EntryCount = (uint)EntryIDs.Count;
            writer.Write(EntryCount);

            foreach (UndertaleString s in EntryIDs)
            {
                writer.WriteUndertaleString(s);
            }

            foreach (LanguageData ld in Languages)
            {
                ld.Serialize(writer);
            }
        }
예제 #2
0
        public void Serialize(UndertaleWriter writer)
        {
            writer.WriteUndertaleString(Name);

            writer.Write(Moments.Count);
            for (int i = 0; i < Moments.Count; i++)
            {
                // Write the time point
                writer.Write(Moments[i].Step);

                // Unnecessary pointer to next array
                writer.WriteUndertaleObjectPointer(Moments[i].Event);
            }

            for (int i = 0; i < Moments.Count; i++)
            {
                // Write the actions for this moment
                writer.WriteUndertaleObject(Moments[i].Event);
            }
        }
예제 #3
0
 public void Serialize(UndertaleWriter writer)
 {
     writer.WriteUndertaleString(Name);
     writer.Write(Occurrences);
     if (Occurrences > 0)
     {
         uint addr = writer.GetAddressForUndertaleObject(FirstAddress);
         if (GMS2_3)
         {
             writer.Write((addr == 0) ? 0 : (addr + 4)); // in GMS 2.3, it points to the actual reference rather than the instruction
         }
         else
         {
             writer.Write(addr);
         }
     }
     else
     {
         writer.Write((int)-1);
     }
 }
예제 #4
0
 public void Serialize(UndertaleWriter writer)
 {
     writer.WriteUndertaleString(Name);
     writer.WriteUndertaleString(Value);
 }
예제 #5
0
        } = new byte[16];                                        // more high entropy data

        public void Serialize(UndertaleWriter writer)
        {
            writer.Write(DisableDebugger ? (byte)1 : (byte)0);
            writer.Write(BytecodeVersion);
            writer.Write(Unknown);
            writer.WriteUndertaleString(Filename);
            writer.WriteUndertaleString(Config);
            writer.Write(LastObj);
            writer.Write(LastTile);
            writer.Write(GameID);
            writer.Write(DirectPlayGuid.ToByteArray());
            writer.WriteUndertaleString(Name);
            writer.Write(Major);
            writer.Write(Minor);
            writer.Write(Release);
            writer.Write(Build);
            writer.Write(DefaultWindowWidth);
            writer.Write(DefaultWindowHeight);
            writer.Write((uint)Info);
            if (LicenseMD5.Length != 16)
            {
                throw new IOException("LicenseMD5 has invalid length");
            }
            writer.Write(LicenseMD5);
            writer.Write(LicenseCRC32);
            writer.Write(Timestamp);
            writer.WriteUndertaleString(DisplayName);

            // Should always be zero.
            writer.Write(ActiveTargets);

            // Very weird value. Decides if Runner should initialize certain subsystems.
            writer.Write((ulong)FunctionClassifications);

            writer.Write(SteamAppID);
            writer.Write(DebuggerPort);
            writer.WriteUndertaleObject(RoomOrder);
            if (Major >= 2)
            {
                // Write random UID
                Random random      = new Random((int)(Timestamp & 4294967295L));
                long   firstRandom = (long)random.Next() << 32 | (long)random.Next();
                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 = Math.Abs((int)((int)(Timestamp & 65535L) / 7 + (GameID - DefaultWindowWidth) + RoomOrder.Count)) % 4;
                GMS2RandomUID.Clear();
                writer.Write(firstRandom);
                GMS2RandomUID.Add(firstRandom);
                for (int i = 0; i < 4; i++)
                {
                    if (i == infoLocation)
                    {
                        writer.Write(infoNumber);
                        GMS2RandomUID.Add(infoNumber);
                    }
                    else
                    {
                        int first  = random.Next();
                        int second = random.Next();
                        writer.Write(first);
                        writer.Write(second);
                        GMS2RandomUID.Add(((long)first << 32) | (long)second);
                    }
                }
                writer.Write(GMS2FPS);
                if (GMS2GameGUID.Length != 16)
                {
                    throw new IOException("GMS2GameGUID has invalid length");
                }
                writer.Write(GMS2AllowStatistics);
                writer.Write(GMS2GameGUID);
            }
        }
 public void Serialize(UndertaleWriter writer)
 {
     writer.WriteUndertaleString(SourceCode);
 }
예제 #7
0
 /// <inheritdoc />
 public void Serialize(UndertaleWriter writer)
 {
     writer.WriteUndertaleString(Name);
     writer.WriteUndertaleObjectPointer(TextureEntry);
 }
예제 #8
0
            public void Serialize(UndertaleWriter writer)
            {
                writer.WriteUndertaleString(ModelName);
                writer.WriteUndertaleString(Name);
                writer.Write(BuiltinName);
                writer.Write(Traits);
                writer.Write(IsCreationTrack);

                writer.Write(Tags.Count);
                writer.Write(OwnedResources.Count);
                writer.Write(Tracks.Count);

                foreach (int i in Tags)
                {
                    writer.Write(i);
                }

                foreach (UndertaleResource res in OwnedResources)
                {
                    if (res is UndertaleAnimationCurve)
                    {
                        writer.WriteUndertaleString(GMAnimCurveString);
                        res.Serialize(writer);
                    }
                    else
                    {
                        throw new IOException("Expected an animation curve");
                    }
                }

                foreach (Track t in Tracks)
                {
                    writer.WriteUndertaleObject(t);
                }

                // Now, handle specific keyframe/etc. data
                switch (ModelName.Content)
                {
                case "GMAudioTrack":
                    writer.WriteUndertaleObject(Keyframes as AudioKeyframes);
                    break;

                case "GMInstanceTrack":
                    writer.WriteUndertaleObject(Keyframes as InstanceKeyframes);
                    break;

                case "GMGraphicTrack":
                    writer.WriteUndertaleObject(Keyframes as GraphicKeyframes);
                    break;

                case "GMSequenceTrack":
                    writer.WriteUndertaleObject(Keyframes as SequenceKeyframes);
                    break;

                case "GMSpriteFramesTrack":
                    writer.WriteUndertaleObject(Keyframes as SpriteFramesKeyframes);
                    break;

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

                case "GMBoolTrack":
                    writer.WriteUndertaleObject(Keyframes as BoolKeyframes);
                    break;

                case "GMStringTrack":
                    writer.WriteUndertaleObject(Keyframes as StringKeyframes);
                    break;

                // TODO?
                //case "GMIntTrack":
                //  writer.WriteUndertaleObject(Keyframes as IntKeyframes);
                //  break;
                case "GMRealTrack":
                    writer.WriteUndertaleObject(Keyframes as RealKeyframes);
                    break;
                }
            }
예제 #9
0
        public void Serialize(UndertaleWriter writer)
        {
            writer.WriteUndertaleString(Name);
            writer.Write((uint)Type | 0x80000000u); // in big-endian?

            writer.WriteUndertaleString(GLSL_ES_Vertex);
            writer.WriteUndertaleString(GLSL_ES_Fragment);
            writer.WriteUndertaleString(GLSL_Vertex);
            writer.WriteUndertaleString(GLSL_Fragment);
            writer.WriteUndertaleString(HLSL9_Vertex);
            writer.WriteUndertaleString(HLSL9_Fragment);

            HLSL11_VertexData.Serialize(writer, false);
            HLSL11_PixelData.Serialize(writer, false);

            writer.WriteUndertaleObject(VertexShaderAttributes);

            writer.Write(Version);

            PSSL_VertexData.Serialize(writer);
            PSSL_PixelData.Serialize(writer);
            Cg_PSVita_VertexData.Serialize(writer);
            Cg_PSVita_PixelData.Serialize(writer);

            if (Version >= 2)
            {
                Cg_PS3_VertexData.Serialize(writer);
                Cg_PS3_PixelData.Serialize(writer);
            }

            if (!HLSL11_VertexData.IsNull)
            {
                WritePadding(writer, 7);

                HLSL11_VertexData.WriteData(writer);
            }
            if (!HLSL11_PixelData.IsNull)
            {
                WritePadding(writer, 7);

                HLSL11_PixelData.WriteData(writer);
            }

            if (!PSSL_VertexData.IsNull)
            {
                WritePadding(writer, 7);

                PSSL_VertexData.WriteData(writer);
            }
            if (!PSSL_PixelData.IsNull)
            {
                WritePadding(writer, 7);

                PSSL_PixelData.WriteData(writer);
            }

            if (!Cg_PSVita_VertexData.IsNull)
            {
                WritePadding(writer, 7);

                Cg_PSVita_VertexData.WriteData(writer);
            }
            if (!Cg_PSVita_PixelData.IsNull)
            {
                WritePadding(writer, 7);

                Cg_PSVita_PixelData.WriteData(writer);
            }

            if (Version >= 2)
            {
                if (!Cg_PS3_VertexData.IsNull)
                {
                    WritePadding(writer, 15);

                    Cg_PS3_VertexData.WriteData(writer);
                }
                if (!Cg_PS3_PixelData.IsNull)
                {
                    WritePadding(writer, 15);

                    Cg_PS3_PixelData.WriteData(writer);
                }
            }
        }
예제 #10
0
 public void Serialize(UndertaleWriter writer)
 {
     writer.WriteUndertaleString(Name);
     writer.Write((uint)GraphType);
     Channels.Serialize(writer);
 }