unsafe void Parse(SR1_Reader reader, Event scriptEvent, ScriptType type, SR1_PrimativeArray <short> scriptData)
        {
            if ((reader.File._ImportFlags & SR1_File.ImportFlags.LogScripts) != 0)
            {
                try
                {
                    string script = "";

                    short[] opCodes = new short[scriptData.Count];
                    int     c       = 0;
                    foreach (short code in scriptData)
                    {
                        opCodes[c] = code;
                        c++;
                    }

                    List <VarType> stack = new List <VarType>();

                    fixed(short *codeStreamStart = opCodes)
                    {
                        short *codeStream = codeStreamStart;

                        c = 0;
                        while (c < opCodes.Length)
                        {
                            PCode opcode          = (PCode)(*codeStream - 1);
                            int   mathOp          = _PCodes[(int)opcode].mathOp;
                            int   additionalBytes = 0;

                            script += "\t\t";

                            if (mathOp > -1)
                            {
                                Operation operation = GetCompareOperationFromID(stack[stack.Count - 1], _PCodes[(int)opcode].mathOp, stack, codeStream);

                                VarType param0VarType = stack[stack.Count - 2];
                                string  param0        = "(" + _VarTypes[(int)param0VarType] + ")var" + (stack.Count - 2);
                                VarType param1VarType = stack[stack.Count - 1];
                                string  param1        = "(" + _VarTypes[(int)param1VarType] + ")var" + (stack.Count - 1);
                                string  result        = "(" + _VarTypes[(int)operation.t] + ")";

                                script += "object var" + stack.Count + " = " + result + operation.n + "(" + param0 + ", " + param1 + ")";
                                stack.Add(operation.t);
                            }
                            else if (opcode == PCode.AddObjectToStack)
                            {
                                int             param = *(codeStream + 1);
                                EventBaseObject scriptEventInstance = (EventBaseObject)scriptEvent.instances[param];

                                VarType param0Type = GetVarType_AddObjectToStack(scriptEventInstance, stack, codeStream);
                                string  param0     = "(" + _VarTypes[(int)param0Type] + ")instances[" + param.ToString() + "]";

                                script += "object var" + stack.Count + " = " + param0;
                                stack.Add(param0Type);
                            }
                            else if (opcode == PCode.AddPlayerObjectToStack)
                            {
                                int param = *(codeStream + 1);

                                VarType param0Type = VarType.InstanceObject;
                                string  param0     = "(" + _VarTypes[(int)param0Type] + ")gameTrackerX.playerInstance";

                                script += "object var" + stack.Count + " = " + param0;
                                stack.Add(param0Type);
                            }
                            else if (opcode == PCode.ModifyObjectToStackWithAttribute)
                            {
                                int       param     = *(codeStream + 1);
                                Operation operation = GetTranformOperationFromID(stack[stack.Count - 1], param, stack, codeStream);

                                VarType param0VarType = stack[stack.Count - 1];
                                string  param0        = "(" + _VarTypes[(int)param0VarType] + ")var" + (stack.Count - 1);
                                string  result        = "(" + _VarTypes[(int)operation.t] + ")";

                                if (operation.t != VarType.None)
                                {
                                    script += "var" + (stack.Count - 1) + " = " + result;
                                }

                                if (param0VarType == VarType.EventObject)
                                {
                                    // SavedEvent and SavedEventSmallVars both inherit from SavedBasic.
                                    // Hopefully the opcodes don't care where these come from and behave the same as local events.
                                    if (operation.p == 1)
                                    {
                                        string param1 = (*(codeStream + 2)).ToString();
                                        script += operation.n + "(" + param0 + ", " + param1 + ")";
                                        additionalBytes++;
                                    }
                                    else
                                    {
                                        script += operation.n + "(" + param0 + ")";
                                    }
                                }
                                else
                                {
                                    script += operation.n + "(" + param0 + ")";
                                }

                                if (operation.t != VarType.None)
                                {
                                    stack[stack.Count - 1] = operation.t;
                                }
                            }
                            else if (opcode == PCode.AddNumberToStack)
                            {
                                int param = *(codeStream + 1);

                                VarType param0Type = VarType.Number;
                                string  param0     = "(" + _VarTypes[(int)param0Type] + ")" + param.ToString();
                                script += "object var" + stack.Count + " = " + param0;
                                stack.Add(VarType.Number);
                            }
                            else if (opcode == PCode.DoStackOperationEquals)
                            {
                                VarType param0VarType = stack[stack.Count - 2];
                                string  param0        = "(" + _VarTypes[(int)param0VarType] + ")var" + (stack.Count - 2);
                                VarType param1VarType = stack[stack.Count - 1];
                                string  param1        = "(" + _VarTypes[(int)param1VarType] + ")var" + (stack.Count - 1);

                                script += _PCodes[*codeStream - 1].n + "(" + param0 + ", " + param1 + ")";
                            }
                            else if (opcode == PCode.Execute)
                            {
                                script += _PCodes[*codeStream - 1].n + "()";
                                stack.Clear();
                            }
                            else
                            {
                                script += _PCodes[*codeStream - 1].n + "()";
                            }

                            script += ";\r\n";

                            codeStream += _PCodes[*codeStream - 1].l;
                            codeStream += additionalBytes;
                            c          += _PCodes[opCodes[c] - 1].l;
                            c          += additionalBytes;

                            if (c < opCodes.Length &&
                                (opcode == PCode.Execute ||
                                 opcode == PCode.EndConditional || opcode == PCode.EndAction || opcode == PCode.EndOfLine2))
                            {
                                script += "\r\n";
                            }
                        }

                        reader.LogScript(script);
                    }
                }
                catch
                {
                    reader.LogScript("\t\t// Error reading " + type.ToString() + " script.\r\n");
                }
            }
        }
 public SignalDepricated(int length)
 {
     buf = new SR1_PrimativeArray <int>(length);
 }