Exemple #1
0
 public void Init(BloxContainer container)
 {
     if (!this.inited && this.active)
     {
         this.inited    = true;
         this.container = container;
         for (BloxBlock next = this.firstBlock; next != null; next = next.next)
         {
             next.owningEvent = this;
             if (next.next != null)
             {
                 next.next.prevBlock = next;
             }
             next.Init();
             if (next.selfOrChildCanYield)
             {
                 if (this.yieldAllowed)
                 {
                     this.canYield = true;
                 }
                 else
                 {
                     Debug.LogWarningFormat("You should not use Flow Blocks related to Waiting in this Event [{0}]. The Wait Block will be ignored.", this.ident);
                 }
             }
         }
     }
 }
        protected override object RunBlock()
        {
            object obj   = base.contextBlock.Run();
            Array  array = obj as Array;

            if (array != null)
            {
                BloxBlock obj2  = base.paramBlocks[0];
                object    value = (obj2 != null) ? obj2.Run() : null;
                try
                {
                    Array val = BloxUtil.ArrayAdd(array, value);
                    base.contextBlock.UpdateWith(val);
                }
                catch (Exception ex)
                {
                    base.LogError(ex.Message, null);
                }
            }
            else
            {
                base.LogError("The context must be an Array but was [" + ((obj != null) ? obj.GetType() : null) + "]", null);
            }
            return(null);
        }
Exemple #3
0
        private void CollectBlockData(BloxBlock b, List <BloxBlock> savedBlocks, BloxEventData data)
        {
            BloxBlockData item = new BloxBlockData(b);

            savedBlocks.Add(b);
            data.blocks.Add(item);
            if (b.contextBlock != null)
            {
                this.CollectBlockData(b.contextBlock, savedBlocks, data);
            }
            if (((b.paramBlocks != null) ? b.paramBlocks.Length : 0) != 0)
            {
                for (int i = 0; i < b.paramBlocks.Length; i++)
                {
                    if (b.paramBlocks[i] != null)
                    {
                        this.CollectBlockData(b.paramBlocks[i], savedBlocks, data);
                    }
                }
            }
            if (b.firstChild != null)
            {
                for (b = b.firstChild; b != null; b = b.next)
                {
                    this.CollectBlockData(b, savedBlocks, data);
                }
            }
        }
 protected override object RunBlock()
 {
     if (base.owningBlock != null)
     {
         if (this.RunAndGetVariable(null) == null)
         {
             return(null);
         }
         return(this.v.GetValue());
     }
     try
     {
         BloxBlock obj   = base.paramBlocks[0];
         object    value = (obj != null) ? obj.Run() : null;
         if (this.RunAndGetVariable(null) == null)
         {
             return(null);
         }
         this.v.SetValue(value);
     }
     catch (Exception e)
     {
         base.LogError("Could not set Variable Value: " + this.varName, e);
     }
     return(null);
 }
        protected override object RunBlock()
        {
            BloxContainer bloxContainer = (base.paramBlocks[1] == null) ? base.owningEvent.container : BloxUtil.GetComponent <BloxContainer>(base.paramBlocks[1].Run());

            if ((UnityEngine.Object)bloxContainer == (UnityEngine.Object)null)
            {
                base.LogError("Could not find a Blox Container component on the target GameObject", null);
                return(null);
            }
            string text = (string)base.paramBlocks[0].Run();

            if (string.IsNullOrEmpty(text))
            {
                base.LogError("The target Event name is invalid", null);
                return(null);
            }
            float afterSeconds = (float)((base.paramBlocks[2] == null) ? 0.0 : ((float)base.paramBlocks[2].Run()));

            if (base.paramBlocks.Length > 3)
            {
                BloxEventArg[] array = new BloxEventArg[base.paramBlocks.Length - 3];
                for (int i = 3; i < base.paramBlocks.Length; i++)
                {
                    BloxBlock obj = base.paramBlocks[i];
                    object    val = (obj != null) ? obj.Run() : null;
                    array[i - 3] = new BloxEventArg("param" + (i - 3).ToString(), val);
                }
                bloxContainer.TriggerEvent(text, afterSeconds, array);
            }
            else
            {
                bloxContainer.TriggerEvent(text, afterSeconds);
            }
            return(null);
        }
Exemple #6
0
        public override void CopyTo(BloxBlock block)
        {
            base.CopyTo(block);
            Debug_Block obj = block as Debug_Block;

            obj.message = this.message;
            obj.logType = this.logType;
        }
        public override void CopyTo(BloxBlock block)
        {
            base.CopyTo(block);
            Variable_Block obj = block as Variable_Block;

            obj.varName = this.varName;
            obj.varType = this.varType;
        }
Exemple #8
0
 public void Serialize()
 {
     if (this._isDirty)
     {
         //Debug.Log("Serialize", "BloxEvent", Color.yellow);
         this._isDirty        = false;
         this.storedBlocksIdx = new List <int>();
         List <BloxBlock> list = new List <BloxBlock>();
         this.data = new BloxEventData();
         if (this.firstBlock != null)
         {
             this.storedBlocksIdx.Add(0);
             for (BloxBlock next = this.firstBlock; next != null; next = next.next)
             {
                 this.CollectBlockData(next, list, this.data);
             }
         }
         else
         {
             this.storedBlocksIdx.Add(-1);
         }
         for (int i = 0; i < this.unlinkedBlocks.Count; i++)
         {
             this.storedBlocksIdx.Add(list.Count);
             for (BloxBlock bloxBlock = this.unlinkedBlocks[i]; bloxBlock != null; bloxBlock = bloxBlock.next)
             {
                 this.CollectBlockData(bloxBlock, list, this.data);
             }
         }
         for (int j = 0; j < list.Count; j++)
         {
             if (list[j] != null)
             {
                 if (list[j].next != null)
                 {
                     this.data.blocks[j].next = list.IndexOf(list[j].next);
                 }
                 if (list[j].firstChild != null)
                 {
                     this.data.blocks[j].firstChild = list.IndexOf(list[j].firstChild);
                 }
                 if (list[j].contextBlock != null)
                 {
                     this.data.blocks[j].contextBlock = list.IndexOf(list[j].contextBlock);
                 }
                 if (((list[j].paramBlocks != null) ? list[j].paramBlocks.Length : 0) != 0)
                 {
                     this.data.blocks[j].paramBlocks = new int[list[j].paramBlocks.Length];
                     for (int k = 0; k < list[j].paramBlocks.Length; k++)
                     {
                         this.data.blocks[j].paramBlocks[k] = list.IndexOf(list[j].paramBlocks[k]);
                     }
                 }
             }
         }
     }
 }
Exemple #9
0
 public virtual void CopyTo(BloxBlock block)
 {
     block.blockType    = this.blockType;
     block.ident        = this.ident;
     block.returnType   = this.returnType;
     block.returnValue  = this.returnValue;
     block.mi           = this.mi;
     block.active       = true;
     block._ed_viewOffs = Vector2.zero;
 }
        protected override object RunBlock()
        {
            object obj   = base.contextBlock.Run();
            Array  array = obj as Array;

            if (array != null)
            {
                int num = 0;
                try
                {
                    num = ((base.paramBlocks[0] != null) ? ((int)base.paramBlocks[0].Run()) : 0);
                }
                catch (Exception e)
                {
                    object value = base.paramBlocks[0].Run();
                    object obj2  = null;
                    if (BloxUtil.TryConvert(value, typeof(int), out obj2))
                    {
                        num = (int)obj2;
                        goto end_IL_003d;
                    }
                    base.LogError("The index is invalid. Expected Integer value.", e);
                    return(null);

                    end_IL_003d :;
                }
                if (array.Length == 0)
                {
                    base.LogError("There are no values in the list.", null);
                    return(null);
                }
                if (num >= 0 && num < array.Length)
                {
                    BloxBlock obj3   = base.paramBlocks[1];
                    object    value2 = (obj3 != null) ? obj3.Run() : null;
                    try
                    {
                        array.SetValue(value2, num);
                        base.contextBlock.UpdateWith(array);
                    }
                    catch (Exception ex)
                    {
                        base.LogError(ex.Message, null);
                    }
                    goto IL_0148;
                }
                base.LogError("The index [" + num + "] is out of range. It should be a value between Array Start:[0] and Array Size:[" + array.Length + "]. Remember that arrays start indexing at 0 and not 1.", null);
                return(null);
            }
            base.LogError("The context must be an Array but was [" + ((obj != null) ? obj.GetType() : null) + "]", null);
            goto IL_0148;
IL_0148:
            return(null);
        }
Exemple #11
0
 protected virtual object RunBlock()
 {
     if (this.mi != null)
     {
         this.RunContextBlock();
         if (this.mi.MemberType == MemberTypes.Field || this.mi.MemberType == MemberTypes.Property)
         {
             if (this.owningBlock == null)
             {
                 this.RunParamBlocks();
                 this.mi.SetValue(this.context, this.paramValues[0]);
                 BloxBlock obj = this.contextBlock;
                 if (obj != null)
                 {
                     obj.UpdateWith(this.context);
                 }
             }
             else
             {
                 this.returnValue = this.mi.GetValue(this.context);
             }
         }
         else
         {
             this.RunParamBlocks();
             this.returnValue = this.mi.Invoke(this.context, this.paramValues);
             if (this.hasReferenceTypes)
             {
                 Type[] array = this.ParamTypes();
                 for (int i = 0; i < this.paramValues.Length; i++)
                 {
                     try
                     {
                         if (array.Length > i)
                         {
                             if (array[i].IsByRef)
                             {
                                 ((Variable_Block)this.paramBlocks[i]).v.SetValue(this.paramValues[i]);
                             }
                             continue;
                         }
                     }
                     catch (Exception e)
                     {
                         this.LogError("Error while processing param[" + i + "] => [" + array[i] + "]", e);
                         continue;
                     }
                     break;
                 }
             }
         }
     }
     return(this.returnValue);
 }
Exemple #12
0
        protected override object RunBlock()
        {
            object obj  = base.contextBlock.Run();
            IList  list = obj as IList;

            if (list != null)
            {
                int num = 0;
                try
                {
                    num = ((base.paramBlocks[0] != null) ? ((int)base.paramBlocks[0].Run()) : 0);
                }
                catch (Exception e)
                {
                    object value = base.paramBlocks[0].Run();
                    object obj2  = null;
                    if (BloxUtil.TryConvert(value, typeof(int), out obj2))
                    {
                        num = (int)obj2;
                        goto end_IL_003d;
                    }
                    base.LogError("The index is invalid. Expected Integer value.", e);
                    return(null);

                    end_IL_003d :;
                }
                if (list.Count == 0)
                {
                    base.LogError("There are no values in the list.", null);
                    return(null);
                }
                if (num >= 0 && num < list.Count)
                {
                    BloxBlock obj3   = base.paramBlocks[1];
                    object    value2 = (obj3 != null) ? obj3.Run() : null;
                    try
                    {
                        BloxUtil.ListSet(list, value2, num);
                    }
                    catch (Exception ex)
                    {
                        base.LogError(ex.Message, null);
                    }
                    goto IL_013c;
                }
                base.LogError("The index [" + num + "] is out of range. It should be a value between List Start:[0] and List Size:[" + list.Count + "]. Remember that lists start indexing at 0 and not 1.", null);
                return(null);
            }
            base.LogError("The context must be a List but was [" + ((obj != null) ? obj.GetType() : null) + "]", null);
            goto IL_013c;
IL_013c:
            return(null);
        }
Exemple #13
0
        protected override object RunBlock()
        {
            object obj   = base.contextBlock.Run();
            Array  array = obj as Array;

            if (array != null)
            {
                BloxBlock obj2  = base.paramBlocks[0];
                object    value = (obj2 != null) ? obj2.Run() : null;
                return(BloxUtil.ArrayContains(array, value));
            }
            base.LogError("The context must be an Array but was [" + ((obj != null) ? obj.GetType() : null) + "]", null);
            return(false);
        }
Exemple #14
0
        protected override object RunBlock()
        {
            object obj  = base.contextBlock.Run();
            IList  list = obj as IList;

            if (list != null)
            {
                BloxBlock obj2  = base.paramBlocks[0];
                object    value = (obj2 != null) ? obj2.Run() : null;
                return(BloxUtil.ListContains(list, value));
            }
            base.LogError("The context must be a List but was [" + ((obj != null) ? obj.GetType() : null) + "]", null);
            return(false);
        }
Exemple #15
0
 public IEnumerator RunYield(BloxContainer container)
 {
     if (this.active && this.firstBlock != null)
     {
         this.container = container;
         this.flowSig   = BloxFlowSignal.None;
         BloxBlock b        = this.firstBlock;
         int       deadlock = 0;
         while (true)
         {
             if (b != null)
             {
                 if (b == this.firstBlock)
                 {
                     deadlock++;
                     if (deadlock >= BloxGlobal.Instance.deadlockDetect)
                     {
                         break;
                     }
                 }
                 b.Run();
                 if (this.flowSig == BloxFlowSignal.Wait)
                 {
                     yield return(b.yieldInstruction);
                 }
                 else
                 {
                     if (this.flowSig == BloxFlowSignal.Continue)
                     {
                         this.flowSig = BloxFlowSignal.None;
                         b            = this.firstBlock;
                         continue;
                     }
                     if (this.flowSig == BloxFlowSignal.Break)
                     {
                         yield break;
                     }
                     if (this.flowSig == BloxFlowSignal.Stop)
                     {
                         yield break;
                     }
                 }
                 b = b.next;
                 continue;
             }
             yield break;
         }
         Debug.LogErrorFormat(container.gameObject, "Deadlock detected in Event [{0}:{1}]. Forcing stop.", container.gameObject.name, this.screenName);
     }
 }
Exemple #16
0
 public BloxBlockData(BloxBlock b)
 {
     if (b != null)
     {
         Type type = b.GetType();
         this.blockSysType = type.AssemblyQualifiedName;
         this.blockType    = b.blockType;
         this.ident        = b.ident;
         this.active       = b.active;
         this._ed_viewOffs = b._ed_viewOffs;
         if (b.returnType != null)
         {
             this.returnType  = b.returnType.AssemblyQualifiedName;
             this.returnValue = BloxSerializer.Serialize(b.returnValue);
         }
         if (b.mi != null && b.mi.IsValid)
         {
             this.memberReflectedType = b.mi.ReflectedType.AssemblyQualifiedName;
             this.memberType          = b.mi.MemberType;
             this.memberName          = b.mi.Name;
             ParameterInfo[] parameters = b.mi.GetParameters();
             if (((parameters != null) ? parameters.Length : 0) != 0)
             {
                 this.paramTypes = new string[parameters.Length];
                 for (int i = 0; i < parameters.Length; i++)
                 {
                     this.paramTypes[i] = parameters[i].ParameterType.AssemblyQualifiedName;
                 }
             }
         }
         if (type != typeof(BloxBlock))
         {
             FieldInfo[] array = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
             this.fields = new BlockField[array.Length];
             for (int j = 0; j < array.Length; j++)
             {
                 object value = array[j].GetValue(b);
                 if (value != null)
                 {
                     this.fields[j].fieldName = array[j].Name;
                     this.fields[j].typeName  = array[j].FieldType.AssemblyQualifiedName;
                     this.fields[j].data      = BloxSerializer.Serialize(value);
                 }
             }
         }
     }
 }
Exemple #17
0
        private IEnumerator _RunChildBlocksYield()
        {
            this.flowSig = BloxFlowSignal.None;
            BloxBlock b        = this.firstChild;
            int       deadlock = 0;

            while (true)
            {
                if (b != null)
                {
                    if (b == this.firstChild)
                    {
                        deadlock++;
                        if (deadlock >= BloxGlobal.Instance.deadlockDetect)
                        {
                            break;
                        }
                    }
                    b.Run();
                    if (this.flowSig == BloxFlowSignal.Wait)
                    {
                        this.yieldInstruction = b.yieldInstruction;
                        yield return(b.yieldInstruction);
                    }
                    else
                    {
                        if (this.flowSig == BloxFlowSignal.Continue)
                        {
                            yield break;
                        }
                        if (this.flowSig == BloxFlowSignal.Break)
                        {
                            yield break;
                        }
                        if (this.flowSig == BloxFlowSignal.Stop)
                        {
                            yield break;
                        }
                    }
                    b = b.next;
                    continue;
                }
                yield break;
            }
            Debug.LogErrorFormat(this.owningEvent.container.gameObject, "Deadlock detected in Event [{0}:{1}]. Forcing stop.", this.owningEvent.container.gameObject.name, this.owningEvent.screenName);
            this.flowSig = BloxFlowSignal.Break;
        }
Exemple #18
0
 public void Run(BloxContainer container)
 {
     if (this.active && this.firstBlock != null)
     {
         this.container = container;
         this.flowSig   = BloxFlowSignal.None;
         BloxBlock next = this.firstBlock;
         int       num  = 0;
         while (true)
         {
             if (next != null)
             {
                 if (next == this.firstBlock)
                 {
                     num++;
                     if (num >= BloxGlobal.Instance.deadlockDetect)
                     {
                         break;
                     }
                 }
                 next.Run();
                 if (this.flowSig == BloxFlowSignal.Continue)
                 {
                     this.flowSig = BloxFlowSignal.None;
                     next         = this.firstBlock;
                 }
                 else
                 {
                     if (this.flowSig == BloxFlowSignal.Break)
                     {
                         return;
                     }
                     if (this.flowSig == BloxFlowSignal.Stop)
                     {
                         return;
                     }
                     next = next.next;
                 }
                 continue;
             }
             return;
         }
         Debug.LogErrorFormat(container.gameObject, "Deadlock detected in Event [{0}:{1}]. Forcing stop.", container.gameObject.name, this.screenName);
     }
 }
Exemple #19
0
 protected virtual object RunBlock()
 {
     if (this.mi != null)
     {
         this.RunContextBlock();
         if (this.mi.MemberType == MemberTypes.Field || this.mi.MemberType == MemberTypes.Property)
         {
             if (this.owningBlock == null)
             {
                 this.RunParamBlocks();
                 this.mi.SetValue(this.context, this.paramValues[0]);
                 BloxBlock obj = this.contextBlock;
                 if (obj != null)
                 {
                     obj.UpdateWith(this.context);
                 }
             }
             else
             {
                 this.returnValue = this.mi.GetValue(this.context);
             }
         }
         else
         {
             this.RunParamBlocks();
             this.returnValue = this.mi.Invoke(this.context, this.paramValues);
             if (this.hasReferenceTypes)
             {
                 int num = 0;
                 while (num < this.paramValues.Length && this.paramTypes.Length > num)
                 {
                     if (this.paramTypes[num].IsByRef)
                     {
                         ((Variable_Block)this.paramBlocks[num]).v.SetValue(this.paramValues[num]);
                     }
                     num++;
                 }
             }
         }
     }
     return(this.returnValue);
 }
Exemple #20
0
        public BloxEvent Init(BloxContainer container, Blox blox)
        {
            Debug.Log("Init", "BloxEvent", Color.yellow);
            if (!this.active)
            {
                return(null);
            }
            BloxEvent bloxEvent = new BloxEvent();

            bloxEvent.ident           = this.ident;
            bloxEvent.screenName      = this.screenName;
            bloxEvent.active          = this.active;
            bloxEvent.yieldAllowed    = this.yieldAllowed;
            bloxEvent.container       = container;
            bloxEvent.data            = this.data;
            bloxEvent.storedBlocksIdx = this.storedBlocksIdx;
            bloxEvent.Deserialize(blox);
            bloxEvent.data            = null;
            bloxEvent.storedBlocksIdx = null;
            for (BloxBlock next = bloxEvent.firstBlock; next != null; next = next.next)
            {
                next.owningEvent = bloxEvent;
                if (next.next != null)
                {
                    next.next.prevBlock = next;
                }
                next.Init();
                if (next.selfOrChildCanYield)
                {
                    if (bloxEvent.yieldAllowed)
                    {
                        bloxEvent.canYield = true;
                    }
                    else
                    {
                        Debug.LogWarningFormat("You should not use Flow Blocks related to Waiting in this Event [{0}]. The Wait Block will be ignored.", this.ident);
                    }
                }
            }
            return(bloxEvent);
        }
Exemple #21
0
        private void _RunChildBlocks()
        {
            BloxBlock bloxBlock = this.firstChild;
            int       num       = 0;

            while (true)
            {
                if (bloxBlock != null)
                {
                    if (bloxBlock == this.firstChild)
                    {
                        num++;
                        if (num >= BloxGlobal.Instance.deadlockDetect)
                        {
                            break;
                        }
                    }
                    bloxBlock.Run();
                    if (this.flowSig == BloxFlowSignal.Continue)
                    {
                        return;
                    }
                    if (this.flowSig == BloxFlowSignal.Break)
                    {
                        return;
                    }
                    if (this.flowSig == BloxFlowSignal.Stop)
                    {
                        return;
                    }
                    bloxBlock = bloxBlock.next;
                    continue;
                }
                return;
            }
            Debug.LogErrorFormat(this.owningEvent.container.gameObject, "Deadlock detected in Event [{0}:{1}]. Forcing stop.", this.owningEvent.container.gameObject.name, this.owningEvent.screenName);
            this.flowSig = BloxFlowSignal.Break;
        }
Exemple #22
0
        protected override object RunBlock()
        {
            object obj  = base.contextBlock.Run();
            IList  list = obj as IList;

            if (list != null)
            {
                BloxBlock obj2  = base.paramBlocks[0];
                object    value = (obj2 != null) ? obj2.Run() : null;
                try
                {
                    BloxUtil.ListAdd(list, value);
                }
                catch (Exception ex)
                {
                    base.LogError(ex.Message, null);
                }
            }
            else
            {
                base.LogError("The context must be a List but was [" + ((obj != null) ? obj.GetType() : null) + "]", null);
            }
            return(null);
        }
Exemple #23
0
        public BloxBlock CreateBlock()
        {
            if (string.IsNullOrEmpty(this.blockSysType))
            {
                return(null);
            }
            Type type = Type.GetType(this.blockSysType);

            if (type == null)
            {
                Debug.LogError("Could not find Block type: " + this.blockSysType);
                return(null);
            }
            BloxBlock bloxBlock = (BloxBlock)Activator.CreateInstance(type);

            bloxBlock.blockType    = this.blockType;
            bloxBlock.ident        = this.ident;
            bloxBlock.active       = this.active;
            bloxBlock._ed_viewOffs = this._ed_viewOffs;
            bloxBlock.returnType   = (string.IsNullOrEmpty(this.returnType) ? null : Type.GetType(this.returnType));
            if (bloxBlock.returnType != null)
            {
                bloxBlock.returnValue = BloxSerializer.Deserialize(this.returnValue, bloxBlock.returnType);
            }
            if (!string.IsNullOrEmpty(this.memberName))
            {
                Type type2 = string.IsNullOrEmpty(this.memberReflectedType) ? null : Type.GetType(this.memberReflectedType);
                if (type2 != null)
                {
                    if (this.memberType == MemberTypes.Field)
                    {
                        bloxBlock.mi = new BloxMemberInfo(type2.GetField(this.memberName, BloxBlockData.BindFlags), type2);
                    }
                    else if (this.memberType == MemberTypes.Property)
                    {
                        bloxBlock.mi = new BloxMemberInfo(type2.GetProperty(this.memberName, BloxBlockData.BindFlags), type2);
                    }
                    else if (this.memberType == MemberTypes.Constructor)
                    {
                        if (((this.paramTypes != null) ? this.paramTypes.Length : 0) != 0)
                        {
                            Type[] array = null;
                            array = new Type[this.paramTypes.Length];
                            for (int i = 0; i < this.paramTypes.Length; i++)
                            {
                                array[i] = Type.GetType(this.paramTypes[i]);
                            }
                            bloxBlock.mi = new BloxMemberInfo(type2.GetConstructor(BloxBlockData.CtorBindFlags, null, array, null), type2);
                        }
                        else
                        {
                            bloxBlock.mi = new BloxMemberInfo(type2.GetConstructor(Type.EmptyTypes), type2);
                        }
                    }
                    else if (this.memberType == MemberTypes.Method)
                    {
                        if (((this.paramTypes != null) ? this.paramTypes.Length : 0) != 0)
                        {
                            Type[] array2 = null;
                            array2 = new Type[this.paramTypes.Length];
                            for (int j = 0; j < this.paramTypes.Length; j++)
                            {
                                array2[j] = Type.GetType(this.paramTypes[j]);
                            }
                            bloxBlock.mi = new BloxMemberInfo(type2.GetMethod(this.memberName, BloxBlockData.BindFlags, null, array2, null), type2);
                        }
                        else
                        {
                            bloxBlock.mi = new BloxMemberInfo(type2.GetMethod(this.memberName, BloxBlockData.BindFlags, null, new Type[0], null), type2);
                        }
                    }
                }
            }
            if (((type != typeof(BloxBlock)) ? this.fields.Length : 0) != 0)
            {
                FieldInfo[] array3 = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public);
                for (int k = 0; k < this.fields.Length; k++)
                {
                    if (((this.fields[k].data != null) ? this.fields[k].data.Length : 0) != 0)
                    {
                        FieldInfo fieldInfo = null;
                        if (k < array3.Length && array3[k].Name == this.fields[k].fieldName)
                        {
                            fieldInfo = array3[k];
                        }
                        else
                        {
                            int num = 0;
                            while (num < array3.Length)
                            {
                                if (!(array3[num].Name == this.fields[k].fieldName))
                                {
                                    num++;
                                    continue;
                                }
                                fieldInfo = array3[num];
                                break;
                            }
                        }
                        if (fieldInfo != null)
                        {
                            Type type3 = Type.GetType(this.fields[k].typeName);
                            if (type3 != null && type3 == fieldInfo.FieldType)
                            {
                                object obj = BloxSerializer.Deserialize(this.fields[k].data, type3);
                                if (obj != null)
                                {
                                    fieldInfo.SetValue(bloxBlock, obj);
                                }
                            }
                        }
                    }
                }
            }
            return(bloxBlock);
        }
Exemple #24
0
 public void Deserialize(Blox owningBlox)
 {
     this.owningBlox = owningBlox;
     if (this._isDirty)
     {
         this.Serialize();
     }
     if (this.data != null)
     {
         this.firstBlock = null;
         this.unlinkedBlocks.Clear();
         List <BloxBlock> list = new List <BloxBlock>();
         for (int i = 0; i < this.data.blocks.Count; i++)
         {
             BloxBlock item = this.data.blocks[i].CreateBlock();
             list.Add(item);
         }
         for (int j = 0; j < this.data.blocks.Count; j++)
         {
             if (this.data.blocks[j].next >= 0)
             {
                 list[j].next = list[this.data.blocks[j].next];
             }
             if (this.data.blocks[j].firstChild >= 0)
             {
                 list[j].firstChild = list[this.data.blocks[j].firstChild];
             }
             if (this.data.blocks[j].contextBlock >= 0)
             {
                 list[j].contextBlock = list[this.data.blocks[j].contextBlock];
             }
             if (this.data.blocks[j].paramBlocks.Length != 0)
             {
                 list[j].paramBlocks = new BloxBlock[this.data.blocks[j].paramBlocks.Length];
                 for (int k = 0; k < this.data.blocks[j].paramBlocks.Length; k++)
                 {
                     if (this.data.blocks[j].paramBlocks[k] >= 0)
                     {
                         list[j].paramBlocks[k] = list[this.data.blocks[j].paramBlocks[k]];
                     }
                 }
             }
         }
         if (this.storedBlocksIdx != null)
         {
             if (this.storedBlocksIdx.Count > 0 && this.storedBlocksIdx[0] >= 0)
             {
                 this.firstBlock = list[this.storedBlocksIdx[0]];
             }
             if (this.storedBlocksIdx.Count > 1)
             {
                 for (int l = 1; l < this.storedBlocksIdx.Count; l++)
                 {
                     if (this.storedBlocksIdx[l] >= 0 && this.storedBlocksIdx[l] < list.Count)
                     {
                         BloxBlock bloxBlock = list[this.storedBlocksIdx[l]];
                         if (bloxBlock != null)
                         {
                             this.unlinkedBlocks.Add(bloxBlock);
                         }
                     }
                 }
             }
         }
         if (Application.isPlaying && !Application.isEditor)
         {
             this.data            = null;
             this.storedBlocksIdx = null;
         }
     }
 }
Exemple #25
0
 public void Init()
 {
     if (this.active)
     {
         if (this.blockType == BloxBlockType.Unknown || (this.mi != null && !this.mi.IsValid))
         {
             this.isValid = false;
         }
         else
         {
             if (this.returnValue == null && this.returnType != null && this.returnType != typeof(void))
             {
                 this.returnValue = BloxMemberInfo.GetDefaultValue(this.returnType);
             }
             if (this.owningBlock != null && this.mi != null && (this.mi.MemberType == MemberTypes.Field || this.mi.MemberType == MemberTypes.Property))
             {
                 this.paramBlocks = null;
             }
             BloxMemberInfo obj = this.mi;
             this.contextType = ((obj != null) ? obj.ReflectedType : null);
             if (this.contextBlock != null)
             {
                 this.contextBlock.owningEvent = this.owningEvent;
                 this.contextBlock.owningBlock = this;
                 this.contextBlock.Init();
             }
             BloxMemberInfo  obj2  = this.mi;
             ParameterInfo[] array = (obj2 != null) ? obj2.GetParameters() : null;
             if (((array != null) ? array.Length : 0) != 0)
             {
                 this.paramTypes = new Type[array.Length];
                 for (int i = 0; i < this.paramTypes.Length; i++)
                 {
                     this.paramTypes[i] = array[i].ParameterType;
                     if (this.paramTypes[i].IsByRef)
                     {
                         this.hasReferenceTypes = true;
                         if (this.paramBlocks != null && this.paramBlocks.Length >= i && this.paramBlocks[i] != null && this.paramBlocks[i].GetType() == typeof(Variable_Block))
                         {
                             break;
                         }
                         this.LogError("The Block field [" + array[i].Name + "] expected a Variable Block.", null);
                         return;
                     }
                 }
             }
             else if (this.mi != null && (this.mi.MemberType == MemberTypes.Field || this.mi.MemberType == MemberTypes.Property))
             {
                 this.paramTypes = new Type[1]
                 {
                     this.mi.ReturnType
                 };
             }
             if (((this.paramBlocks != null) ? this.paramBlocks.Length : 0) != 0)
             {
                 this.paramValues = new object[this.paramBlocks.Length];
                 for (int j = 0; j < this.paramBlocks.Length; j++)
                 {
                     if (this.paramBlocks[j] == null)
                     {
                         if (this.paramTypes != null && this.paramTypes.Length > j)
                         {
                             this.paramValues[j] = BloxMemberInfo.GetDefaultValue(this.paramTypes[j]);
                         }
                     }
                     else
                     {
                         this.paramBlocks[j].owningEvent = this.owningEvent;
                         this.paramBlocks[j].owningBlock = this;
                         this.paramBlocks[j].fieldIdx    = j;
                         this.paramBlocks[j].Init();
                     }
                 }
             }
             this.InitBlock();
             if (this.isValid)
             {
                 for (BloxBlock bloxBlock = this.firstChild; bloxBlock != null; bloxBlock = bloxBlock.next)
                 {
                     bloxBlock.parentBlock = this;
                     bloxBlock.owningEvent = this.owningEvent;
                     if (bloxBlock.next != null)
                     {
                         bloxBlock.next.prevBlock = bloxBlock;
                     }
                     bloxBlock.Init();
                     if (bloxBlock.selfOrChildCanYield)
                     {
                         this.selfOrChildCanYield = true;
                     }
                 }
             }
         }
     }
 }
Exemple #26
0
        public plyVar RunAndGetVariable(Type expectedType = null)
        {
            if (this.varType == plyVariablesType.Event)
            {
                this.v = base.owningEvent.FindVariable(this.varName, expectedType);
                if (this.v == null)
                {
                    if (base.owningBlock == null)
                    {
                        BloxBlock obj = base.paramBlocks[0];
                        expectedType = (((obj != null) ? obj.returnType : null) ?? typeof(object));
                    }
                    else if (base.fieldIdx == -1)
                    {
                        expectedType = (base.owningBlock.ContextType() ?? typeof(object));
                    }
                    else
                    {
                        Type[] array = base.owningBlock.ParamTypes();
                        expectedType = ((array == null || base.fieldIdx < 0 || base.fieldIdx >= array.Length) ? typeof(object) : (array[base.fieldIdx] ?? typeof(object)));
                    }
                    this.v = base.owningEvent.FindVariable(this.varName, expectedType);
                    if (this.v == null)
                    {
                        base.LogError("The Event Variable [" + this.varName + "] does not exist in Event [" + base.owningEvent.screenName + "] on GameObject: " + base.owningEvent.container.name, null);
                        return(null);
                    }
                }
            }
            else if (this.varType != plyVariablesType.Blox)
            {
                if (this.varType == plyVariablesType.Object)
                {
                    GameObject gameObject = null;
                    object     obj2       = (base.paramBlocks[1] == null) ? base.owningEvent.container.gameObject : base.paramBlocks[1].Run();
                    if (obj2 != null)
                    {
                        gameObject = (obj2 as GameObject);
                        if ((UnityEngine.Object)gameObject == (UnityEngine.Object)null)
                        {
                            Component component = obj2 as Component;
                            if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                            {
                                gameObject = component.gameObject;
                            }
                        }
                    }
                    if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null)
                    {
                        ObjectVariables component2 = gameObject.GetComponent <ObjectVariables>();
                        if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                        {
                            this.v = component2.variables.FindVariable(this.varName);
                            if (this.v == null)
                            {
                                base.LogError("The Object Variable [" + this.varName + "] does not exist on GameObject: " + gameObject.name, null);
                                return(null);
                            }
                            goto IL_0265;
                        }
                        base.LogError("Could not find ObjectVariables component on GameObject [" + gameObject.name + "] for Object Variable: " + this.varName, null);
                        return(null);
                    }
                    base.LogError("The 2nd field must be set to a target GameObject that has the Object Variable component on it with the variable named: " + this.varName, null);
                    return(null);
                }
                if (this.varType != plyVariablesType.Global)
                {
                    base.LogError("Invalid Variable Type specified. This should not happen.", null);
                    return(null);
                }
            }
            goto IL_0265;
IL_0265:
            return(this.v);
        }
Exemple #27
0
 public override void CopyTo(BloxBlock block)
 {
     base.CopyTo(block);
     ((Type_Block)block).typeName = this.typeName;
 }