コード例 #1
0
        protected void Backtrack(Element startNode, IndexReference finalPath, bool reversePath = false)
        {
            actionSet.AddAction(current.SetVariable(startNode));
            actionSet.AddAction(finalPath.SetVariable(new V_EmptyArray()));

            // Get the path.
            actionSet.AddAction(Element.Part <A_While>(new V_Compare(
                                                           current.GetVariable(),
                                                           Operators.GreaterThanOrEqual,
                                                           new V_Number(0)
                                                           )));

            Element nextNode = Nodes[(Element)current.GetVariable()];

            // For debugging generated path.
            // actionSet.AddAction(Element.Part<A_CreateEffect>(
            //     Element.Part<V_AllPlayers>(),
            //     EnumData.GetEnumValue(Effect.Orb),
            //     EnumData.GetEnumValue(Color.SkyBlue),
            //     next,
            //     new V_Number(0.5),
            //     EnumData.GetEnumValue(EffectRev.VisibleTo)
            // ));

            if (!reversePath)
            {
                // Add the current node to the final path.
                actionSet.AddAction(finalPath.ModifyVariable(Operation.AppendToArray, nextNode));
            }
            else
            {
                // Insert the current node to the final path.
                actionSet.AddAction(finalPath.SetVariable(Element.Part <V_Append>(nextNode, finalPath.GetVariable())));
            }

            actionSet.AddAction(current.SetVariable(Element.Part <V_ValueInArray>(parentArray.GetVariable(), current.GetVariable()) - 1));
            actionSet.AddAction(new A_End());
        }
コード例 #2
0
        protected override void New(ActionSet actionSet, NewClassInfo newClassInfo)
        {
            // Get the pathmap data.
            PathMap pathMap = (PathMap)newClassInfo.AdditionalParameterData[0];

            Element        index    = (Element)newClassInfo.ObjectReference.GetVariable();
            IndexReference nodes    = actionSet.VarCollection.Assign("_tempNodes", actionSet.IsGlobal, false);
            IndexReference segments = actionSet.VarCollection.Assign("_tempSegments", actionSet.IsGlobal, false);

            actionSet.AddAction(nodes.SetVariable(new V_EmptyArray()));
            actionSet.AddAction(segments.SetVariable(new V_EmptyArray()));

            foreach (var node in pathMap.Nodes)
            {
                actionSet.AddAction(nodes.ModifyVariable(operation: Operation.AppendToArray, value: node.ToVector()));
            }
            foreach (var segment in pathMap.Segments)
            {
                actionSet.AddAction(segments.ModifyVariable(operation: Operation.AppendToArray, value: segment.AsWorkshopData()));
            }

            actionSet.AddAction(Nodes.SetVariable((Element)nodes.GetVariable(), index: index));
            actionSet.AddAction(Segments.SetVariable((Element)segments.GetVariable(), index: index));
        }
コード例 #3
0
 public void AddToQueue(ActionSet actionSet, Element seconds, Element function)
 {
     actionSet.AddAction(_waitAsyncQueue.ModifyVariable(Operation.AppendToArray, Element.CreateArray(Element.CreateArray(Element.Part <V_TotalTimeElapsed>() + seconds, function))));
 }