예제 #1
0
        public Cutscene(Stream s, int commandCap = 250)
        {
            BinaryReader    br;
            CutsceneCommand cmd;
            Int32           commandId;
            int             commands;

            CommandCap = commandCap;
            br         = new BinaryReader(s);

            //Read the header
            commands = br.ReadBigInt32();
            Frames   = br.ReadBigInt32();

            error_CommandCount = commands;

            //early termination
            if (Frames < 0 || commands < 0)
            {
                return;
            }

            if (commands > commandCap)
            {
                CommandCapReached = true;
                return;
            }

            for (int i = 0; i < commands + 1; i++)
            {
                cmd       = null;
                commandId = br.ReadBigInt32();

                if (commandId == 0x3E8)
                {
                    cmd = new ExitCommand(commandId, br);
                }
                else if (commandId == -1)
                {
                    cmd = new EndCommand(commandId, br);
                }
                else if (commandId > 0 && commandId < 0x91)
                {
                    int functionalId = CommandMap[commandId];
                    switch (functionalId)
                    {
                    case 0x01: cmd = new CameraCommand(commandId, br); break; //Camera Positions

                    case 0x02: goto case 1;                                   //Camera Focus Points

                    case 0x03: goto default;                                  //Special Execution

                    case 0x04: cmd = new ActionCommand(commandId, br); break; //Lighting Settings

                    case 0x05: goto case 1;                                   //Camera Positions (Link)

                    case 0x06: goto case 1;                                   //Camera Focus Points (Link)

                    case 0x07: goto default;                                  //unknown 1

                    case 0x08: goto default;                                  //unknown 2

                    case 0x09: cmd = new Command09(commandId, br); break;

                    case 0x0A: goto default;     //Struct + 0x24, Link

                    case 0x0B: goto default;     //No Command

                    case 0x0E: goto default;     //Struct + 0x2C

                    case 0x0F: goto default;     //Struct + 0x28

                    case 0x13: cmd = new TextCommand(commandId, br); break;

                    case 0x19: goto default;     //Struct + 0x30

                    case 0x1D: goto default;     //Struct + 0x34

                    case 0x1E: goto default;     //Struct + 0x38

                    case 0x1F: goto default;     //Struct + 0x40

                    case 0x2C: goto default;     //Struct + 0x3C

                    case 0x2D: cmd = new ScreenTransitionCommand(commandId, br); break;

                    case 0x31: goto default;     //Struct + 0x44

                    case 0x3E: goto default;     //Struct + 0x48

                    case 0x56: goto default;     //Play Background Music

                    case 0x57: goto default;     //Stop Background Music

                    case 0x7C: goto default;     //Fade Background Music

                    case 0x8C: cmd = new TimeCommand(commandId, br); break;

                    case 0x8F: goto default;     //Struct + 0x4C

                    default: cmd = new ActionCommand(commandId, br); break;
                    }
                }

                if (cmd != null)
                {
                    Commands.Add(cmd);
                }
                else
                {
                    InvalidCommandReached = true;
                    return;
                }

                if (cmd is EndCommand)
                {
                    break;
                }

                if (i > CommandCap)
                {
                    CommandCapReached = true;
                    return;
                }
            }
            TryMergeCameraCommands();
        }
예제 #2
0
        public Cutscene(Stream s, int commandCap = 250)
        {
            BinaryReader    br;
            CutsceneCommand cmd;
            Int32           commandId;
            int             commands;

            CommandCap = commandCap;
            br         = new BinaryReader(s);

            Index = br.BaseStream.Position;

            //Read the header
            commands = br.ReadBigInt32();
            Frames   = br.ReadBigInt32();

            error_CommandCount = commands;

            //early termination
            if (Frames < 0 || commands < 0)
            {
                return;
            }

            if (commands > commandCap)
            {
                CommandCapReached = true;
                return;
            }

            for (int i = 0; i < commands + 1; i++)
            {
                cmd = null;
                var index = br.BaseStream.Position;
                commandId = br.ReadBigInt32();
                if (commandId > 0 && commandId < 0x91)
                {
                    switch ((byte)commandId)
                    {
                    case 0x01: cmd = new CameraCommand(commandId, br, index); break;

                    case 0x02: goto case 1;

                    case 0x05: goto case 1;

                    case 0x06: goto case 1;

                    case 0x09: cmd = new Command09(commandId, br, index); break;

                    case 0x13: cmd = new TextCommand(commandId, br, index); break;

                    case 0x2D: cmd = new ScreenTransitionCommand(commandId, br, index); break;

                    default: cmd = new ActorCommand(commandId, br, index); break;
                    }
                }
                else if (commandId == 0x3E8)
                {
                    cmd = new ExitCommand(commandId, br, index);
                }
                else if (commandId == -1)
                {
                    cmd = new EndCommand(commandId, br, index);
                }

                if (cmd != null)
                {
                    Commands.Add(cmd);
                }
                else
                {
                    InvalidCommandReached = true;
                    return;
                }

                if (cmd is EndCommand)
                {
                    break;
                }

                if (i > CommandCap)
                {
                    CommandCapReached = true;
                    return;
                }
            }
            TryMergeCameraCommands();
        }