예제 #1
0
        private ACMDScript ParseEventList(uint CRC, int Offset)
        {
            ACMDScript _list = new ACMDScript(CRC);

            ACMDCommand c;

            VoidPtr addr = (_workingSource.Address + Offset);

            // Loop through Event List.
            while (Util.GetWordUnsafe(addr, Runtime.WorkingEndian) != Runtime._endingCommand.Identifier)
            {
                // Try to get command definition
                uint          ident = (uint)Util.GetWordUnsafe(addr, Runtime.WorkingEndian);
                ACMD_CMD_INFO info  = Runtime.commandDictionary.FirstOrDefault(e => e.Identifier == ident);

                // If a command definition exists, use that info to deserialize.
                if (info != null)
                {
                    // Get command parameters and add the command to the event list.
                    c = new ACMDCommand(info);
                    for (int i = 0; i < info.ParamSpecifiers.Count; i++)
                    {
                        switch (info.ParamSpecifiers[i])
                        {
                        case 0:
                            c.parameters.Add(Util.GetWordUnsafe(0x04 + (addr + (i * 4)), Runtime.WorkingEndian));
                            break;

                        case 1:
                            c.parameters.Add(Util.GetFloatUnsafe(0x04 + (addr + (i * 4)), Runtime.WorkingEndian));
                            break;

                        case 2:
                            c.parameters.Add((decimal)Util.GetWordUnsafe(0x04 + (addr + (i * 4)), Runtime.WorkingEndian));
                            break;

                        default:
                            goto case 0;
                        }
                    }

                    _list.Add(c);
                    addr += c.CalcSize();
                }

                // If there is no command definition, this is unknown data.
                // Add the current word to the unk command and continue adding
                // until we hit a known command
                else
                {
                    _list.Add(new UnknownCommand()
                    {
                        ident = (uint)Util.GetWordUnsafe(addr, Runtime.WorkingEndian)
                    });
                    addr += 0x04;
                }
            }

            // If we hit a script_end command, add it to the the Event List and terminate looping.
            if (Util.GetWordUnsafe(addr, Runtime.WorkingEndian) == Runtime._endingCommand.Identifier)
            {
                ACMD_CMD_INFO info = Runtime.commandDictionary.FirstOrDefault(e => e.Identifier == Runtime._endingCommand.Identifier);

                c = new ACMDCommand(info);
                _list.Add(c);
            }

            _list.Initialize();
            return(_list);
        }
예제 #2
0
 public ACMDCommand(ACMD_CMD_INFO info)
 {
     _commandInfo = info;
 }