public NodeFromInvocable(ActionSet actionSet, PathmapClass pathmapClass, Element pathmapObject, ILambdaInvocable invocable) { _actionSet = actionSet; _pathmapClass = pathmapClass; _pathmapObject = pathmapObject; _invocable = invocable; }
public IWorkshopTree Parse(ActionSet actionSet, MethodCall methodCall) { if (LambdaType.IsConstant()) { ILambdaInvocable lambda = (ILambdaInvocable)actionSet.CurrentObject; return(lambda.Invoke(actionSet, methodCall.ParameterValues)); } return(actionSet.ToWorkshop.LambdaBuilder.Call(actionSet, methodCall, LambdaType.ReturnType)); }
public IWorkshopTree Parse(ActionSet actionSet, MethodCall methodCall) { if (LambdaType.IsConstant()) { ILambdaInvocable lambda = (ILambdaInvocable)actionSet.CurrentObject; return(lambda.Invoke(actionSet, methodCall.ParameterValues)); } return(actionSet.DeltinScript.GetComponent <LambdaGroup>().Call(actionSet, methodCall)); }
public PathmapBake(ActionSet actionSet, Element pathmapObject, Element attributes, ILambdaInvocable onLoop) { ActionSet = actionSet; var pathfinderClasses = actionSet.DeltinScript.GetComponent <PathfinderTypesComponent>(); _pathmapClass = pathfinderClasses.Pathmap; _bakemapClass = pathfinderClasses.Bakemap; _pathmapObject = pathmapObject; EnabledAttributes = attributes; _onLoop = onLoop; }
public PathmapPathfinderInfo(Element position, SharedPathfinderInfoValues pathfinderValues) { ActionSet = pathfinderValues.ActionSet; InitialNode = pathfinderValues.NodeFromPosition.NodeFromPosition(position); EnabledAttributes = pathfinderValues.Attributes; _onLoop = pathfinderValues.OnLoop; _onConnectLoop = pathfinderValues.OnConnectLoop; _pathmapClass = ActionSet.DeltinScript.GetComponent <PathfinderTypesComponent>().Pathmap; _nodeFromPosition = pathfinderValues.NodeFromPosition; OriginalPosition = position; PathmapObject = pathfinderValues.PathmapObject; ResolveInfo = ActionSet.DeltinScript.GetComponent <ResolveInfoComponent>(); }
public void Build(ActionSet actionSet, Element compressedNodeArray, Action <Element> printProgress, ILambdaInvocable onLoop) { var matcher = GetMatcher(actionSet); // Get the character matcher. var nodeArray = actionSet.VarCollection.Assign("compressedNodes", actionSet.IsGlobal, false); // The index the node array is stored in. var nodeCount = Element.CountOf(nodeArray.Get()); // The number of nodes. var bakeResult = actionSet.VarCollection.Assign("compressBakeResult", true, false); // Assign the nodeResult. var compressCurrentNodeArray = actionSet.VarCollection.Assign("compressCurrentNodeArray", true, false); // Assign the nodeResult. nodeArray.Set(actionSet, compressedNodeArray); bakeResult.Set(actionSet, Element.EmptyArray()); // Initialize the nodeResult. // Loop through each node. var nodeArrayLoop = new ForBuilder(actionSet, "compressBakeNodeLoop", nodeCount); printProgress(nodeArrayLoop.Value / nodeCount); // Print the node count. nodeArrayLoop.Init(); compressCurrentNodeArray.Set(actionSet, Element.EmptyArray()); var currentStringArray = nodeArray.Get()[nodeArrayLoop.Value]; // The current string array. // Loop through each string. var stringArrayLoop = new ForBuilder(actionSet, "compressBakeStringLoop", Element.CountOf(currentStringArray)); stringArrayLoop.Init(); var currentString = currentStringArray[stringArrayLoop.Value]; // The current string. // Create an array with the length of the number of characters in the string. var mapper = actionSet.VarCollection.Assign("compressMapper", actionSet.IsGlobal, false); mapper.Set(actionSet, Element.EmptyArray()); mapper.Set(actionSet, index: Element.StringLength(currentString) - 1, value: 0); actionSet.AddAction(compressCurrentNodeArray.ModifyVariable( operation: Operation.AppendToArray, value: Element.Map( mapper.Get(), Element.IndexOfArrayValue( matcher, Element.StringSlice(currentString, Element.ArrayIndex(), (Element)1) ) ) )); // Invoke onLoop. if (onLoop == null) { actionSet.AddAction(Element.Wait()); } else { onLoop.Invoke(actionSet); } stringArrayLoop.End(); actionSet.AddAction(bakeResult.SetVariable(index: nodeArrayLoop.Value, value: compressCurrentNodeArray.Get())); nodeArrayLoop.End(); Result = bakeResult.Get(); }