public static void Serialize(this Shim shim, LevelSerializeContext context)
        {
            context.WriteAnimationSet(shim.AnimationSet);
            context.bw.Write(shim.Position);
            context.bw.Write(shim.FacingLeft);
            context.bw.Write(shim.parallaxX);
            context.bw.Write(shim.parallaxY);
            context.bw.Write(shim.animationNumber);
            context.bw.WriteNullableString(shim.ambientSoundSource);

            if (context.Version >= 14)
            {
                context.bw.Write(shim.tag);
            }

            if (context.Version >= 16)
            {
                context.bw.Write(shim.properties.Count);
                foreach (var kvp in shim.properties)
                {
                    context.bw.Write(kvp.Key);
                    context.bw.Write(kvp.Value ?? string.Empty);                     // (null value should probably be blocked by editor, but being safe...)
                }
            }
        }
        public static void Serialize(this Thing thing, LevelSerializeContext context)
        {
            context.WriteAnimationSet(thing.AnimationSet);

            context.bw.Write(thing.Position);
            context.bw.Write(thing.FacingLeft);

            context.bw.WriteNullableString(thing.overrideBehaviour);

            context.bw.Write(thing.includeInNavigation);

            // Properties:
            {
                context.bw.Write(thing.properties.Count);
                foreach (var kvp in thing.properties)
                {
                    context.bw.Write(kvp.Key);
                    context.bw.Write(kvp.Value ?? string.Empty);                     // (null value should probably be blocked by editor, but being safe...)
                }
            }
        }
Esempio n. 3
0
        public virtual void Serialize(LevelSerializeContext context)
        {
            context.bw.WriteNullableStringNonBlank(friendlyName);
            context.bw.WriteNullableStringNonBlank(behaviourName);

            if (context.bw.WriteBoolean(levelAnimation != null))
            {
                context.WriteAnimationSet(levelAnimation);
            }

            // Properties
            {
                context.bw.Write(properties.Count);
                foreach (var kvp in properties)
                {
                    context.bw.Write(kvp.Key);
                    context.bw.Write(kvp.Value ?? string.Empty); // (null value should probably be blocked by editor, but being safe...)
                }
            }

            // Teleporters
            {
                context.bw.Write(teleporters.Count);
                foreach (var teleporter in teleporters)
                {
                    teleporter.Serialize(context);
                }
            }

            // Player Spawns
            {
                context.bw.Write(playerSpawns.Count);
                foreach (var item in playerSpawns)
                {
                    context.bw.Write(item.Key); // string
                    context.bw.Write(item.Value.Count);
                    foreach (var position in item.Value)
                    {
                        context.bw.Write(position);
                    }
                }
            }

            // Things
            {
                context.bw.Write(things.Count);
                foreach (var thing in things)
                {
                    thing.Serialize(context);
                }
            }

            // Geometry
            {
                // Regions
                {
                    context.bw.Write(regions.Count);
                    foreach (var region in regions)
                    {
                        context.bw.Write(region.Key);
                        context.bw.Write(region.Count());
                        foreach (var area in region)
                        {
                            area.Serialize(context);
                        }
                    }
                }

                // Paths
                {
                    context.bw.Write(paths.Count);
                    foreach (var kvp in paths)
                    {
                        context.bw.Write(kvp.Key);
                        kvp.Value.Serialize(context);
                    }
                }

                // Positions
                {
                    context.bw.Write(positions.Count);
                    foreach (var cluster in positions)
                    {
                        context.bw.Write(cluster.Key);
                        context.bw.Write(cluster.Count());
                        foreach (LevelPosition levelPosition in cluster)
                        {
                            levelPosition.Serialize(context);
                        }
                    }
                }
            }

            // Shims
            {
                context.bw.Write(shims.Count);
                foreach (var shim in shims)
                {
                    shim.Serialize(context);
                }

                context.bw.Write(backgroundShimsEndIndex);
                context.bw.Write(foregroundShimsStartIndex);
                context.bw.Write(animatedShimCount);
            }

            // Camera Bounds
            context.bw.Write(cameraBounds);

            if (context.Version >= 20)
            {
                context.bw.Write(isAPitLevel);
            }
        }