private void SetEventField(Action action, BaseEvent _trackEvent, SecurityElement _fieldNode)
        {
            string    text  = _fieldNode.get_Tag().ToLower();
            Type      type  = _trackEvent.GetType();
            FieldInfo field = type.GetField(_fieldNode.Attribute("name"));

            if (field == null)
            {
                return;
            }
            bool   flag = false;
            string name = string.Empty;

            if (_fieldNode.Attribute("useRefParam") != null)
            {
                flag = bool.Parse(_fieldNode.Attribute("useRefParam"));
            }
            if (flag && _fieldNode.Attribute("refParamName") != null)
            {
                name = _fieldNode.Attribute("refParamName");
            }
            if (text == "float")
            {
                float num = float.Parse(_fieldNode.Attribute("value"));
                field.SetValue(_trackEvent, num);
                if (flag)
                {
                    action.refParams.AddRefData(name, field, _trackEvent);
                    if (action.refParams.GetRefParam(name, ref num))
                    {
                        field.SetValue(_trackEvent, num);
                    }
                }
            }
            else if (text == "int")
            {
                int num2 = int.Parse(_fieldNode.Attribute("value"));
                field.SetValue(_trackEvent, num2);
                if (flag)
                {
                    action.refParams.AddRefData(name, field, _trackEvent);
                    if (action.refParams.GetRefParam(name, ref num2))
                    {
                        field.SetValue(_trackEvent, num2);
                    }
                }
            }
            else if (text == "templateobject" || text == "trackobject")
            {
                int num3 = int.Parse(_fieldNode.Attribute("id"));
                field.SetValue(_trackEvent, num3);
                if (flag)
                {
                    action.refParams.AddRefData(name, field, _trackEvent);
                    if (action.refParams.GetRefParam(name, ref num3))
                    {
                        field.SetValue(_trackEvent, num3);
                    }
                }
            }
            else if (text == "uint")
            {
                uint num4 = uint.Parse(_fieldNode.Attribute("value"));
                field.SetValue(_trackEvent, num4);
                if (flag)
                {
                    action.refParams.AddRefData(name, field, _trackEvent);
                    if (action.refParams.GetRefParam(name, ref num4))
                    {
                        field.SetValue(_trackEvent, num4);
                    }
                }
            }
            else if (text == "bool")
            {
                bool flag2 = bool.Parse(_fieldNode.Attribute("value"));
                field.SetValue(_trackEvent, flag2);
                if (flag)
                {
                    action.refParams.AddRefData(name, field, _trackEvent);
                    if (action.refParams.GetRefParam(name, ref flag2))
                    {
                        field.SetValue(_trackEvent, flag2);
                    }
                }
            }
            else if (text == "string")
            {
                string text2 = _fieldNode.Attribute("value");
                field.SetValue(_trackEvent, text2);
                if (flag)
                {
                    action.refParams.AddRefData(name, field, _trackEvent);
                    object obj = null;
                    if (action.refParams.GetRefParam(name, ref obj))
                    {
                        field.SetValue(_trackEvent, text2);
                    }
                }
            }
            else if (text == "vector3")
            {
                float   x      = float.Parse(_fieldNode.Attribute("x"));
                float   y      = float.Parse(_fieldNode.Attribute("y"));
                float   z      = float.Parse(_fieldNode.Attribute("z"));
                Vector3 vector = new Vector3(x, y, z);
                field.SetValue(_trackEvent, vector);
                if (flag)
                {
                    action.refParams.AddRefData(name, field, _trackEvent);
                    if (action.refParams.GetRefParam(name, ref vector))
                    {
                        field.SetValue(_trackEvent, vector);
                    }
                }
            }
            else if (text == "vector3i")
            {
                int   x2   = int.Parse(_fieldNode.Attribute("x"));
                int   y2   = int.Parse(_fieldNode.Attribute("y"));
                int   z2   = int.Parse(_fieldNode.Attribute("z"));
                VInt3 vInt = new VInt3(x2, y2, z2);
                field.SetValue(_trackEvent, vInt);
                if (flag)
                {
                    action.refParams.AddRefData(name, field, _trackEvent);
                    if (action.refParams.GetRefParam(name, ref vInt))
                    {
                        field.SetValue(_trackEvent, vInt);
                    }
                }
            }
            else if (text == "quaternion")
            {
                float      x3         = float.Parse(_fieldNode.Attribute("x"));
                float      y3         = float.Parse(_fieldNode.Attribute("y"));
                float      z3         = float.Parse(_fieldNode.Attribute("z"));
                float      w          = float.Parse(_fieldNode.Attribute("w"));
                Quaternion quaternion = new Quaternion(x3, y3, z3, w);
                field.SetValue(_trackEvent, quaternion);
                if (flag)
                {
                    action.refParams.AddRefData(name, field, _trackEvent);
                    if (action.refParams.GetRefParam(name, ref quaternion))
                    {
                        field.SetValue(_trackEvent, quaternion);
                    }
                }
            }
            else if (text == "eulerangle")
            {
                float      x4          = float.Parse(_fieldNode.Attribute("x"));
                float      y4          = float.Parse(_fieldNode.Attribute("y"));
                float      z4          = float.Parse(_fieldNode.Attribute("z"));
                Quaternion quaternion2 = Quaternion.Euler(x4, y4, z4);
                field.SetValue(_trackEvent, quaternion2);
                if (flag)
                {
                    action.refParams.AddRefData(name, field, _trackEvent);
                    if (action.refParams.GetRefParam(name, ref quaternion2))
                    {
                        field.SetValue(_trackEvent, quaternion2);
                    }
                }
            }
            else if (text == "enum")
            {
                field.SetValue(_trackEvent, Enum.Parse(field.get_FieldType(), _fieldNode.Attribute("value")));
                if (flag)
                {
                    int num5 = 0;
                    action.refParams.AddRefData(name, field, _trackEvent);
                    if (action.refParams.GetRefParam(name, ref num5))
                    {
                        field.SetValue(_trackEvent, num5);
                    }
                }
            }
            else if (text == "array")
            {
                if (_fieldNode.get_Children() != null)
                {
                    string text3 = _fieldNode.Attribute("type").ToLower();
                    if (text3 == "vector3i")
                    {
                        VInt3[] array = new VInt3[_fieldNode.get_Children().get_Count()];
                        int     num6  = 0;
                        using (IEnumerator enumerator = _fieldNode.get_Children().GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                SecurityElement securityElement = (SecurityElement)enumerator.get_Current();
                                int             x5    = int.Parse(securityElement.Attribute("x"));
                                int             y5    = int.Parse(securityElement.Attribute("y"));
                                int             z5    = int.Parse(securityElement.Attribute("z"));
                                VInt3           vInt2 = new VInt3(x5, y5, z5);
                                array[num6++] = vInt2;
                            }
                        }
                        field.SetValue(_trackEvent, array);
                    }
                    else if (text3 == "int")
                    {
                        int[] array2 = new int[_fieldNode.get_Children().get_Count()];
                        int   num7   = 0;
                        using (IEnumerator enumerator2 = _fieldNode.get_Children().GetEnumerator())
                        {
                            while (enumerator2.MoveNext())
                            {
                                SecurityElement securityElement2 = (SecurityElement)enumerator2.get_Current();
                                string          text4            = securityElement2.Attribute("value");
                                int             num8             = int.Parse(text4);
                                array2[num7++] = num8;
                            }
                        }
                        field.SetValue(_trackEvent, array2);
                    }
                    else if (text3 == "templateobject" || text3 == "trackobject")
                    {
                        int[] array3 = new int[_fieldNode.get_Children().get_Count()];
                        int   num9   = 0;
                        using (IEnumerator enumerator3 = _fieldNode.get_Children().GetEnumerator())
                        {
                            while (enumerator3.MoveNext())
                            {
                                SecurityElement securityElement3 = (SecurityElement)enumerator3.get_Current();
                                string          text5            = securityElement3.Attribute("id");
                                int             num10            = int.Parse(text5);
                                array3[num9++] = num10;
                            }
                        }
                        field.SetValue(_trackEvent, array3);
                    }
                    else if (text3 == "uint")
                    {
                        uint[] array4 = new uint[_fieldNode.get_Children().get_Count()];
                        int    num11  = 0;
                        using (IEnumerator enumerator4 = _fieldNode.get_Children().GetEnumerator())
                        {
                            while (enumerator4.MoveNext())
                            {
                                SecurityElement securityElement4 = (SecurityElement)enumerator4.get_Current();
                                string          text6            = securityElement4.Attribute("value");
                                uint            num12            = uint.Parse(text6);
                                array4[num11++] = num12;
                            }
                        }
                        field.SetValue(_trackEvent, array4);
                    }
                    else if (text3 == "bool")
                    {
                        bool[] array5 = new bool[_fieldNode.get_Children().get_Count()];
                        int    num13  = 0;
                        using (IEnumerator enumerator5 = _fieldNode.get_Children().GetEnumerator())
                        {
                            while (enumerator5.MoveNext())
                            {
                                SecurityElement securityElement5 = (SecurityElement)enumerator5.get_Current();
                                string          text7            = securityElement5.Attribute("value");
                                bool            flag3            = bool.Parse(text7);
                                array5[num13++] = flag3;
                            }
                        }
                        field.SetValue(_trackEvent, array5);
                    }
                    else if (text3 == "float")
                    {
                        float[] array6 = new float[_fieldNode.get_Children().get_Count()];
                        int     num14  = 0;
                        using (IEnumerator enumerator6 = _fieldNode.get_Children().GetEnumerator())
                        {
                            while (enumerator6.MoveNext())
                            {
                                SecurityElement securityElement6 = (SecurityElement)enumerator6.get_Current();
                                string          text8            = securityElement6.Attribute("value");
                                float           num15            = float.Parse(text8);
                                array6[num14++] = num15;
                            }
                        }
                        field.SetValue(_trackEvent, array6);
                    }
                    else if (text3 == "string")
                    {
                        string[] array7 = new string[_fieldNode.get_Children().get_Count()];
                        int      num16  = 0;
                        using (IEnumerator enumerator7 = _fieldNode.get_Children().GetEnumerator())
                        {
                            while (enumerator7.MoveNext())
                            {
                                SecurityElement securityElement7 = (SecurityElement)enumerator7.get_Current();
                                string          text9            = securityElement7.Attribute("value");
                                array7[num16++] = text9;
                            }
                        }
                        field.SetValue(_trackEvent, array7);
                    }
                }
            }
            else
            {
                Debug.LogError("Invalid field type \"" + text + "\"!");
            }
        }
Ejemplo n.º 2
0
 public void ResetLength(int inLengthMs, bool bPlaySpeed)
 {
     if ((this.length > 0) && (inLengthMs != 0))
     {
         bool flag  = true;
         bool flag2 = true;
         if (inLengthMs < 0)
         {
             inLengthMs = 0x3fffffff;
             flag       = true;
             flag2      = false;
         }
         VFactor factor = new VFactor((long)inLengthMs, (long)this.length);
         if (bPlaySpeed)
         {
             this.SetPlaySpeed(factor.Inverse);
         }
         else
         {
             this.length *= factor;
             int count = this.tracks.Count;
             for (int i = 0; i < count; i++)
             {
                 Track track = this.tracks[i];
                 if (track != null)
                 {
                     int num3 = track.trackEvents.Count;
                     for (int j = 0; j < num3; j++)
                     {
                         BaseEvent event2 = track.trackEvents[j];
                         if (event2 != null)
                         {
                             if (event2.GetType().IsSubclassOf(typeof(DurationEvent)))
                             {
                                 DurationEvent event3 = event2 as DurationEvent;
                                 if (flag2 && event3.bScaleStart)
                                 {
                                     event3.time *= factor;
                                 }
                                 if (event3.time > track.Length)
                                 {
                                     event3.time = track.Length;
                                 }
                                 if (flag && event3.bScaleLength)
                                 {
                                     event3.length *= factor;
                                 }
                                 if (event3.End > track.Length)
                                 {
                                     event3.End = track.Length;
                                 }
                             }
                             else
                             {
                                 if (flag2 && event2.bScaleStart)
                                 {
                                     event2.time *= factor;
                                 }
                                 if (event2.time > track.Length)
                                 {
                                     event2.time = track.Length;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }