public PaletteEntryBase FindCascadedPaletteItem(int index) { PaletteEntryBase res = null; if (Palette != null) { res = Palette[index]; } if ((res == null) && (ParentBlock != null)) { return(ParentBlock.FindCascadedPaletteItem(index)); } if ((res == null) && (ParentBlock == null) && IsRoot && (Host.ParentFrame != null)) { return(Host.ParentFrame.FindCascadedPaletteItem(index)); } if ((res == null) && (ParentBlock == null) && (ParentNode != null) && (ParentNode.ApplicationPalette != null)) { res = ParentNode.ApplicationPalette[index]; } return(res); }
//update the virtual pointer in the parent block to make sure it still //points to the correct address if this block has moved or changed size public void UpdateSourcePointer() { if (ParentBlock == null) { return; } var newPointer = stream.AddressTranslator.GetPointer(VirtualAddress); if (stream.PointerExpander != null) { newPointer = stream.PointerExpander.Contract(newPointer); } var countBytes = BitConverter.GetBytes(EntryCount); var pointerBytes = BitConverter.GetBytes((int)newPointer); if (stream.ByteOrder == ByteOrder.BigEndian) { Array.Reverse(countBytes); Array.Reverse(pointerBytes); } var refOffset = ParentBlock.EntrySize * ParentEntryIndex + OffsetInParent; ParentBlock.Write(refOffset, countBytes); ParentBlock.Write(refOffset + 4, pointerBytes); }
public ParentBlockSerializer(ParentBlock parentBlock, ulong timestamp, uint nonce, bool hashingSerialization, bool headerOnly) { this.m_parentBlock = parentBlock; this.m_timestamp = timestamp; this.m_nonce = nonce; this.m_hashingSerialization = hashingSerialization; this.m_headerOnly = headerOnly; }
/// <summary>Finds the nearest parent try statement which encloses this block. </summary> /// <returns>The try statement. </returns> public virtual TryStatementModel FindNearestTryStatement() { if (ParentBlock == null) { return(null); } return(ParentBlock.FindNearestTryStatement()); }
/// <summary>Checks whether the block catches the given exception. </summary> /// <param name="exception">The exception. </param> /// <returns><c>true</c> if the exception is caught in the block; otherwise, <c>false</c>. </returns> public override bool CatchesException(IDeclaredType exception) { if (CatchClauses.Any(catchClauseModel => catchClauseModel.Catches(exception))) { return(true); } return(ParentBlock.CatchesException(exception)); }
private void AtomicBlock_Tap(object sender, GestureEventArgs e) { if (ParentBlock != null) { ParentBlock.SignalTap(this); } e.Handled = FireAction(Anchor.Fire); }
public override void OnEnter() { var flowchart = GetFlowchart(); if (targetBlock != null) { // Check if calling your own parent block if (ParentBlock != null && ParentBlock.Equals(targetBlock)) { // Just ignore the callmode in this case, and jump to first command in list Continue(0); return; } // Callback action for Wait Until Finished mode Action onComplete = null; if (callMode == CallMode.WaitUntilFinished) { onComplete = delegate { flowchart.SelectedBlock = ParentBlock; Continue(); }; } if (targetFlowchart == null || targetFlowchart.Equals(GetFlowchart())) { // If the executing block is currently selected then follow the execution // onto the next block in the inspector. if (flowchart.SelectedBlock == ParentBlock) { flowchart.SelectedBlock = targetBlock; } StartCoroutine(targetBlock.Execute(startIndex, onComplete)); } else { // Execute block in another Flowchart targetFlowchart.ExecuteBlock(targetBlock, startIndex, onComplete); } } if (callMode == CallMode.Stop) { StopParentBlock(); } else if (callMode == CallMode.Continue) { Continue(); } }
private void AtomicBlock_Hold(object sender, GestureEventArgs e) { if (ParentBlock != null) { ParentBlock.SignalTapAndHold(this); e.Handled = true; } else { e.Handled = false; } }
public Container GetVariable(string name) { if (Variables.ContainsKey(name)) { return(Variables[name]); } if (ParentBlock != null) { return(ParentBlock.GetVariable(name)); } throw new ArgumentException($"Variable <{name}> not in scope"); }
public override void SignalFocus(BlockBase block) { base.SignalFocus(block); foreach (BlockBase child in WaveChildren) { if (child != block) { child.SetState(false, child.IsChecked); } } if (ParentBlock != null) { ParentBlock.SignalFocus(this); } }
/// <summary> /// Ensure that this condition didn't come from a non matching if/elif. /// </summary> /// <returns></returns> protected virtual bool DoesPassElifSanityCheck() { System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType(); var prevCmdIndent = ParentBlock.GetPreviousActiveCommandIndent(); var prevCmd = ParentBlock.GetPreviousActiveCommand(); //handle our matching if or else if in the chain failing and moving to us, // need to make sure it is the same indent level if (prevCmd == null || prevCmdIndent != IndentLevel || !previousCommandType.IsSubclassOf(typeof(Condition)) || (prevCmd as Condition).IsLooping) { return(false); } return(true); }
public override void OnEnter() { System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType(); if (previousCommandType == typeof(If) || previousCommandType == typeof(ElseIf)) { // Else If behaves the same as an If command EvaluateAndContinue(); } else { // Else If behaves mostly like an Else command, // but will also jump to a following Else command. // Stop if this is the last command in the list if (CommandIndex >= ParentBlock.CommandList.Count - 1) { StopParentBlock(); return; } // Find the next End command at the same indent level as this Else If command int indent = indentLevel; for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i) { ICommand command = ParentBlock.CommandList[i]; if (command.IndentLevel == indent) { System.Type type = command.GetType(); if (type == typeof(End)) { // Execute command immediately after the Else or End command Continue(command.CommandIndex + 1); return; } } } // No End command found StopParentBlock(); } }
public override void SignalTap(BlockBase block) { base.SignalTap(block); bool changeFocus = (block.CanFocus && !block.IsFocused); bool changeCheck = (block.CanCheck && !block.IsChecked); bool doRadio = (ContainerDefinition != null) ? ContainerDefinition.EnforceRadioBehaviour : false; checkedChild = null; if (changeFocus || changeCheck) { foreach (BlockBase child in WaveChildren) { if (child == block) { child.SetState( changeFocus ? true : child.IsFocused, changeCheck ? true : child.IsChecked); } else { child.SetState( changeFocus ? false : child.IsFocused, changeCheck && doRadio ? false : child.IsChecked); } if (child.IsChecked) { checkedChild = child; } } if (ParentBlock != null) { ParentBlock.SignalFocus(this); } } }
public override void SignalTapAndHold(BlockBase block) { base.SignalTapAndHold(block); if (block.CanFocus && !block.IsFocused) { foreach (BlockBase child in WaveChildren) { if (child == block) { child.SetState(true, child.IsChecked); } else { child.SetState(false, child.IsChecked); } } if (ParentBlock != null) { ParentBlock.SignalFocus(this); } } }
public string GetLocationIdentifier() { return(ParentBlock.GetFlowchart().GetName() + ":" + ParentBlock.BlockName + ".Menu:" + CommandIndex.ToString()); }
public override void OnEnter() { var flowchart = GetFlowchart(); if (targetBlock != null) { // Check if calling your own parent block if (ParentBlock != null && ParentBlock.Equals(targetBlock)) { // Just ignore the callmode in this case, and jump to first command in list Continue(0); return; } if (targetBlock.IsExecuting()) { Debug.LogWarning(targetBlock.BlockName + " cannot be called/executed, it is already running."); Continue(); return; } // Callback action for Wait Until Finished mode Action onComplete = null; if (callMode == CallMode.WaitUntilFinished) { onComplete = delegate { Continue(); }; } // Find the command index to start execution at int index = startIndex; if (startLabel.Value != "") { int labelIndex = targetBlock.GetLabelIndex(startLabel.Value); if (labelIndex != -1) { index = labelIndex; } } if (targetFlowchart == null || targetFlowchart.Equals(GetFlowchart())) { if (callMode == CallMode.StopThenCall) { StopParentBlock(); } StartCoroutine(targetBlock.Execute(index, onComplete)); } else { if (callMode == CallMode.StopThenCall) { StopParentBlock(); } // Execute block in another Flowchart targetFlowchart.ExecuteBlock(targetBlock, index, onComplete); } } if (callMode == CallMode.Stop) { StopParentBlock(); } else if (callMode == CallMode.Continue) { Continue(); } }
public override void OnEnter() { if (ParentBlock == null) { return; } if (!HasNeededProperties()) { Continue(); return; } if (!this.IsElseIf) { EvaluateAndContinue(); } else { System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType(); var prevCmdIndent = ParentBlock.GetPreviousActiveCommandIndent(); //handle our matching if or else if in the chain failing and moving to us, // need to make sure it is the same indent level if (prevCmdIndent == IndentLevel && previousCommandType.IsSubclassOf(typeof(Condition))) { // Else If behaves the same as an If command EvaluateAndContinue(); } else { // Else If behaves mostly like an Else command, // but will also jump to a following Else command. // Stop if this is the last command in the list if (CommandIndex >= ParentBlock.CommandList.Count - 1) { StopParentBlock(); return; } // Find the next End command at the same indent level as this Else If command int indent = indentLevel; for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i) { var command = ParentBlock.CommandList[i]; if (command.IndentLevel == indent) { System.Type type = command.GetType(); if (type == typeof(End)) { // Execute command immediately after the Else or End command Continue(command.CommandIndex + 1); return; } } } // No End command found StopParentBlock(); } } }
public override void OnEnter() { var flowchart = GetFlowchart(); if (targetBlock != null) { // 如果目标block,是自己 // * 则,从命令0,开始重头执行 // Check if calling your own parent block if (ParentBlock != null && ParentBlock.Equals(targetBlock)) { // Just ignore the callmode in this case, and jump to first command in list Continue(0); return; } // target block如果已经执行中 // * 报warning错! if (targetBlock.IsExecuting()) { Debug.LogWarning(targetBlock.BlockName + " cannot be called/executed, it is already running."); Continue(); return; } // Callback action for Wait Until Finished mode Action onComplete = null; // 等待命令执行完成,并继续的模式 if (callMode == CallMode.WaitUntilFinished) { onComplete = delegate { // 选中当前命令的block flowchart.SelectedBlock = ParentBlock; // 并继续播放 Continue(); }; } // Find the command index to start execution at int index = startIndex; if (startLabel.Value != "") { int labelIndex = targetBlock.GetLabelIndex(startLabel.Value); if (labelIndex != -1) { index = labelIndex; } } if (targetFlowchart == null || targetFlowchart.Equals(GetFlowchart())) { // If the executing block is currently selected then follow the execution // onto the next block in the inspector. if (flowchart.SelectedBlock == ParentBlock) { flowchart.SelectedBlock = targetBlock; } if (callMode == CallMode.StopThenCall) { StopParentBlock(); } StartCoroutine(targetBlock.Execute(index, onComplete)); } else { if (callMode == CallMode.StopThenCall) { StopParentBlock(); } // Execute block in another Flowchart targetFlowchart.ExecuteBlock(targetBlock, index, onComplete); } } if (callMode == CallMode.Stop) { StopParentBlock(); } else if (callMode == CallMode.Continue) { Continue(); } }
public override void OnEnter() { //Randomiser int randomWeightTotal = 0; foreach (WeightedBlockCallClass block in targetBlocks) { randomWeightTotal += block.bias; } int randomWeight = UnityEngine.Random.Range(0, randomWeightTotal); int curBlockIndex = 0; foreach (WeightedBlockCallClass block in targetBlocks) { if (randomWeight - block.bias <= 0) { targetBlock = block.targetBlock; } else { randomWeightTotal -= block.bias; } } if (targetBlock == null) { Debug.LogError("Issue with the randomising system"); } // var flowchart = GetFlowchart(); if (targetBlock != null) { // Check if calling your own parent block if (ParentBlock != null && ParentBlock.Equals(targetBlock)) { // Just ignore the callmode in this case, and jump to first command in list Continue(0); return; } if (targetBlock.IsExecuting()) { Debug.LogWarning(targetBlock.BlockName + " cannot be called/executed, it is already running."); Continue(); return; } // Callback action for Wait Until Finished mode Action onComplete = null; if (callMode == CallMode.WaitUntilFinished) { onComplete = delegate { flowchart.SelectedBlock = ParentBlock; Continue(); }; } // Find the command index to start execution at int index = startIndex; if (startLabel.Value != "") { int labelIndex = targetBlock.GetLabelIndex(startLabel.Value); if (labelIndex != -1) { index = labelIndex; } } if (targetFlowchart == null || targetFlowchart.Equals(GetFlowchart())) { // If the executing block is currently selected then follow the execution // onto the next block in the inspector. if (flowchart.SelectedBlock == ParentBlock) { flowchart.SelectedBlock = targetBlock; } if (callMode == CallMode.StopThenCall) { StopParentBlock(); } StartCoroutine(targetBlock.Execute(index, onComplete)); } else { if (callMode == CallMode.StopThenCall) { StopParentBlock(); } // Execute block in another Flowchart targetFlowchart.ExecuteBlock(targetBlock, index, onComplete); } } if (callMode == CallMode.Stop) { StopParentBlock(); } else if (callMode == CallMode.Continue) { Continue(); } }
public void Method(string declaration, Action <MethodBlock> populate) { ParentBlock.Add(new MethodBlock(declaration, populate, Annotations)); }
public void SetVariable(string name, object value) => ParentBlock.SetVariable(name, value);
public Container GetVariable(string name) => ParentBlock.GetVariable(name);
public void Method(string declaration, Func <IEnumerable <string> > populate) { ParentBlock.Add(new MethodBlock(declaration, populate, Annotations)); }
public void Method(MethodBlock methodBlock) { ParentBlock.Add(methodBlock); }