public AnimationSet(AnimationDeserializeContext context) { friendlyName = context.br.ReadNullableString(); importOrigin = context.br.ReadPoint(); behaviour = context.br.ReadNullableString(); if (context.br.ReadBoolean()) { Heightmap = new Heightmap(context); } if (Heightmap != null) { physicsStartX = Heightmap.StartX; physicsEndX = Heightmap.EndX; physicsStartZ = Heightmap.StartZ; physicsEndZ = Heightmap.EndZ; // Assume that reading is faster than walking the heightmap: physicsHeight = context.br.ReadInt32(); if (physicsHeight > 0) { depthBounds = new DepthBounds(context); } flatDirection = context.br.ReadOblique(); // <- for the sake of editing, keep this value around } else { physicsStartX = context.br.ReadInt32(); physicsEndX = context.br.ReadInt32(); physicsStartZ = context.br.ReadInt32(); physicsHeight = context.br.ReadInt32(); flatDirection = context.br.ReadOblique(); if (physicsHeight == 0) { physicsEndZ = context.br.ReadInt32(); // physicsEndZ gets auto-set during regen, except for carpets } RegenerateDepthBounds(); // <- Know this is reasonably fast to generate } if (context.Version >= 38) { coplanarPriority = context.br.ReadInt32(); } if (context.Version >= 36) { doAboveCheck = context.br.ReadBoolean(); } if (context.br.ReadBoolean()) { Ceiling = new Heightmap(context); } animations = context.DeserializeTagLookup(() => new Animation(context)); // Unused Animations { int count = context.br.ReadInt32(); if (count > 0) // unusedAnimations is lazy-initialized { unusedAnimations = new List <Animation>(count); for (var i = 0; i < count; i++) { unusedAnimations.Add(new Animation(context)); } } } cue = context.br.ReadNullableString(); // Shadow layers { int shadowLayerCount = context.br.ReadInt32(); if (shadowLayerCount <= 0) { shadowLayers = null; } else { shadowLayers = new List <ShadowLayer>(); for (var i = 0; i < shadowLayerCount; i++) { shadowLayers.Add(new ShadowLayer(context.br.ReadInt32(), new SpriteRef(context))); } cachedShadowBounds = context.br.ReadBounds(); } } // Properties: if (context.Version >= 40) { int count = context.br.ReadInt32(); for (int i = 0; i < count; i++) { properties.Add(context.br.ReadString(), context.br.ReadString()); } } }
public AnimationFrame(AnimationDeserializeContext context) { delay = context.br.ReadInt32(); positionDelta = context.br.ReadPosition(); shadowOffset = context.br.ReadPosition(); SnapToGround = context.br.ReadBoolean(); int layersCount = context.br.ReadInt32(); if (layersCount > 0) { Cel currentCel; firstLayer = currentCel = new Cel(context); for (var i = 1; i < layersCount; i++) { currentCel.next = new Cel(context); currentCel = currentCel.next; } } if (context.Version >= 39) { masks = context.DeserializeOrderedDictionary(() => new Mask(context)); outgoingAttachments = context.DeserializeOrderedDictionary(() => new OutgoingAttachment(context)); } else { // // Masks: { var legacy = context.DeserializeTagLookup(() => new Mask(context)); masks = new OrderedDictionary <string, Mask>(); foreach (var mask in legacy) { Debug.Assert(mask.Key.Count < 2, "we don't support multi-tags yet"); masks.Add(mask.Key.ToString(), mask.Value); } } // // Outgoing Attachments: { var legacy = context.DeserializeTagLookup(() => new OutgoingAttachment(context)); outgoingAttachments = new OrderedDictionary <string, OutgoingAttachment>(); foreach (var outgoingAttachment in legacy) { Debug.Assert(outgoingAttachment.Key.Count < 2, "we don't support multi-tags yet"); outgoingAttachments.Add(outgoingAttachment.Key.ToString(), outgoingAttachment.Value); } } } incomingAttachments = context.DeserializeTagLookup(() => context.br.ReadPosition()); int triggerCount = context.br.ReadInt32(); if (triggerCount > 0) { triggers = new List <string>(triggerCount); for (var i = 0; i < triggerCount; i++) { triggers.Add(context.br.ReadString()); } } attachAtLayer = context.br.ReadInt32(); canDrawLayersAboveSortedAttachees = context.br.ReadBoolean(); cue = context.br.ReadNullableString(); }