Example #1
0
        internal static W3dEmitter Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dEmitter();

                ParseChunks(reader, context.CurrentEndPosition, chunkType =>
                {
                    switch (chunkType)
                    {
                    case W3dChunkType.W3D_CHUNK_EMITTER_HEADER:
                        result.Header = W3dEmitterHeader.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_USER_DATA:
                        result.UserData = W3dEmitterUserData.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_INFO:
                        result.Info = W3dEmitterInfo.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_INFOV2:
                        result.InfoV2 = W3dEmitterInfoV2.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_PROPS:
                        result.Properties = W3dEmitterProperties.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_ROTATION_KEYFRAMES:
                        result.RotationKeyframes = W3dEmitterRotationKeyframes.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_FRAME_KEYFRAMES:
                        result.FrameKeyframes = W3dEmitterFrameKeyframes.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_LINE_PROPERTIES:
                        result.LineProperties = W3dEmitterLineProperties.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_BLUR_TIME_KEYFRAMES:
                        result.BlurTimeKeyframes = W3dEmitterBlurTimeKeyframes.Parse(reader, context);
                        break;

                    case W3dChunkType.W3D_CHUNK_EMITTER_EXTRA_INFO:
                        result.ExtraInfo = W3dEmitterExtraInfo.Parse(reader, context);
                        break;

                    default:
                        throw CreateUnknownChunkException(chunkType);
                    }
                });

                return result;
            }));
        }
Example #2
0
        internal static W3dEmitterFrameKeyframes Parse(BinaryReader reader, W3dParseContext context)
        {
            return(ParseChunk(reader, context, header =>
            {
                var result = new W3dEmitterFrameKeyframes
                {
                    Header = W3dEmitterFrameHeader.Parse(reader)
                };

                // Certain enb w3d's break without this check. (example: astro00.w3d)
                if (reader.BaseStream.Position < context.CurrentEndPosition)
                {
                    var remaining = (int)context.CurrentEndPosition - (int)reader.BaseStream.Position;
                    var KeyframeCount = remaining / 8;
                    result.Keyframes = new W3dEmitterFrameKeyframe[KeyframeCount];
                    for (var i = 0; i < result.Keyframes.Length; i++)
                    {
                        result.Keyframes[i] = W3dEmitterFrameKeyframe.Parse(reader);
                    }
                }

                return result;
            }));
        }