Example #1
0
 public CommandListEnumerator(Command[] data)
 {
     _data = data;
 }
Example #2
0
 public void Add(Command var)
 {
     _commands.Add(var);
 }
Example #3
0
 public void Remove(Command var)
 {
     _commands.Remove(var);
 }
Example #4
0
 public void InsertAfter(int index, Command var)
 {
     _commands.Insert(index + 1, var);
 }
Example #5
0
 public void Insert(int index, Command var)
 {
     _commands.Insert(index, var);
 }
Example #6
0
 public int IndexOf(Command var)
 {
     return _commands.IndexOf(var);
 }
Example #7
0
        private CommandList ParseEventList(uint CRC, int Offset)
        {
            CommandList _list = new CommandList(CRC, this);

            Command c;
            UnknownCommand unkC = null;

            VoidPtr addr = (_workingSource.Address + Offset);

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

                // If a command definition exists, use that info to deserialize.
                if (info != null)
                {
                    // If previous commands were unknown, add them here.
                    if (unkC != null)
                    {
                        _list.Add(unkC);
                        unkC = null;
                    }

                    // Get command parameters and add the command to the event list.
                    c = new Command(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)), Endian));
                                break;
                            case 1:
                                c.parameters.Add(Util.GetFloatUnsafe(0x04 + (addr + (i * 4)), Endian));
                                break;
                            case 2:
                                c.parameters.Add((decimal)Util.GetWordUnsafe(0x04 + (addr + (i * 4)), Endian));
                                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
                {
                    if (unkC == null)
                        unkC = new UnknownCommand();
                    unkC.data.Add(Util.GetWordUnsafe(addr, Endian));
                    addr += 0x04;
                }
            }

            if (unkC != null)
                _list.Add(unkC);


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

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

            _list.Initialize();
            return _list;
        }