Beispiel #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()
        {
            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);
        }
Beispiel #3
0
 public void AddDelayedEvent(BloxContainer container, string eventName, float afterSeconds, params BloxEventArg[] args)
 {
     if (!((UnityEngine.Object)container == (UnityEngine.Object)null) && !string.IsNullOrEmpty(eventName))
     {
         this.delayedEvents.Add(new DelayedEvent
         {
             container = container,
             eventName = eventName,
             timer     = afterSeconds,
             args      = args
         });
     }
 }
Beispiel #4
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);
     }
 }
Beispiel #5
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);
     }
 }
Beispiel #6
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);
        }