protected override void OnEnter() { Variable var = GetInput("Value"); int value = var.ConvertedValue <int>(); int smallest = -1; Pin pin = null; foreach (var w in Weights) { Variable wv = Variables.GetByName(w.VariableName); int weight = wv.ConvertedValue <int>(); if (weight == value) { pin = PinCollection.Get(w.OutputName); break; } else if (weight > value && smallest > weight) { pin = PinCollection.Get(w.OutputName); smallest = weight; } } _calculatedNextNode = pin; IsFinished = true; }
protected override void OnEnter() { Variable input = GetInput("Condition"); string name = (input.ConvertedValue <bool>()) ? "True" : "False"; _calculatedNextNode = PinCollection.Get(name); IsFinished = true; }
protected override void OnInit() { PinCollection.AddInput("Input", typeof(object)); var input = PinCollection.Get("Input"); input.IsDynamicType = true; PinCollection.AddOutput("Result", typeof(string)); }
public void ChangeVariable(string name) { VariableName = name; Variable v = GetVariable(); if (v == null) { VariableName = ""; } var value = PinCollection.Get("Value"); value.VariableType = (v != null) ? v.type : typeof(object); HasChanges = true; Root.HasChanges = true; }
void onInputTypeChanged(bool wasInput, bool isInput) { var pin = PinCollection.Get("Value"); if (pin != null) { Pin.Disconnect(pin); } PinCollection.Clear(); if (IsInput) { PinCollection.AddInput("Value", Type); } else { PinCollection.AddOutput("Value", Type); } }
void onInputTypeChanged(bool wasInput, bool isInput) { string removeName = (IsInput) ? "OUT" : "IN"; var pin = PinCollection.Get(removeName); if (pin != null) { Pin.Disconnect(pin); } PinCollection.Clear(); if (IsInput) { PinCollection.AddInTransition("IN"); } else { PinCollection.AddOutTransition("OUT"); } }
/// <summary> /// Changes the variable to another one. /// </summary> /// <param name="name"></param> public void ChangeVariable(string name) { VariableName = name; Variable variable = GetVariable(); if (variable == null) { VariableName = ""; } var value = PinCollection.Get("Value"); value.VariableType = (variable != null) ? variable.type : typeof(object); var newValue = PinCollection.Get("NewValue"); newValue.VariableType = (variable != null) ? variable.type : typeof(object); RemoveStoredVariable("NewValue"); HasChanges = true; Root.HasChanges = true; }
public void SelectAnswer(string outputName) { _calculatedNextNode = PinCollection.Get(outputName); IsFinished = true; }