static void DisplayResult(TrieResult trieResult) { NodeUtility.DisplayCharOccurences(trieResult.CharCount); NodeUtility.DisplayNumberOfCapitalizedWord(trieResult); NodeUtility.DisplayMostCommonWord(trieResult.MostCommonWord, trieResult.Root); NodeUtility.DisplayMostCommonPrefix(trieResult.Root); }
internal override bool IsValidConnection(ConnectionPort nodePort, ConnectionPort otherPort, out string error) { // SubNodes can only connect to the same base. // Check if the node of the connection port is the same base. State myBase = NodeUtility.FindConnectedNodeOfType <State> (this); State otherBase; if (otherPort.node.IsState()) { otherBase = (State)otherPort.node; } else { otherBase = NodeUtility.FindConnectedNodeOfType <State> (otherPort.node); } if (myBase != null && otherBase != null) { if (myBase != otherBase) { error = "Sub Node Tree has not the same base State"; return(false); } } error = ""; return(true); }
public override bool Perform(Node node) { if (!base.Perform(node)) { return(false); } HelperTranspileStatic = HelperTranspile; var thisTranspiler = new HarmonyMethod(AccessTools.Method(typeof(AP_StatPatch), "Transpiler")); var TypeMethods = node.inputPorts[0].GetDataList <TypeMethod>(); var targetCI = TargetPos(node.inputPorts).GetDataList <List <ItemPos <StatDef> > >(); for (int i = 0; i < TypeMethods.Count; i++) { Type type = TypeMethods[i].type; Type ntype = TypeMethods[i].ntype; MethodInfo method = TypeMethods[i].method; Targets = targetCI[i]; List <StatDef> stats = Targets.ConvertAll(t => t.target); if (HelperPrepare == null || Helper_Prepare(type, ntype, method, stats)) { harmony.Patch(method, transpiler: thisTranspiler); if (successfull) { NodeUtility.RegisterOffset(method, Offsets); SuccessfulPorts(node)[0].AddData(TypeMethods[i]); } } } return(true); }
public NodeData AddNode(string name, Type nodeType, int x, int y) { var nodeInstance = NodeUtility.CreateNodeInstance(nodeType.AssemblyQualifiedName); var node = new NodeData(name, nodeInstance, x, y); m_allNodes.Add(node); return(node); }
public static async void Run(String fileUrl) { try { // var stream = await new HttpClient().GetStreamAsync(fileUrl); // var streamReader = new StreamReader(stream); var root = NodeUtility.CreateMainNode(); var testString = "FFnFunnFunyFunFunnniestFundamentalFurtherFunFunnyFurther"; var trieResult = NodeUtility.BuildTrie(testString, root); DisplayResult(trieResult); } catch (Exception exception) { Console.WriteLine(exception.Message); //just for now } }
private async Task <int> OnExecuteAsync(CommandLineApplication app, IConsole console) { try { var(chain, _) = Program.LoadExpressChain(Input); var senderAccount = chain.GetAccount(Sender); if (senderAccount == null) { throw new Exception($"{Sender} sender not found."); } var receiverAccount = chain.GetAccount(Receiver); if (receiverAccount == null) { throw new Exception($"{Receiver} receiver not found."); } var uri = chain.GetUri(); var unspents = (await NeoRpcClient.GetUnspents(uri, senderAccount.ScriptHash) .ConfigureAwait(false))?.ToObject <UnspentsResponse>(); if (unspents == null) { throw new Exception($"could not retrieve unspents for {Sender}"); } var assetId = NodeUtility.GetAssetId(Asset); var tx = RpcTransactionManager.CreateContractTransaction( assetId, Quantity, unspents, senderAccount, receiverAccount); tx.Witnesses = new[] { RpcTransactionManager.GetWitness(tx, chain, senderAccount) }; var sendResult = await NeoRpcClient.SendRawTransaction(uri, tx); if (sendResult == null || !sendResult.Value <bool>()) { throw new Exception("SendRawTransaction failed"); } console.WriteLine($"Transfer Transaction {tx.Hash} submitted"); return(0); } catch (Exception ex) { console.WriteError(ex.Message); app.ShowHelp(); return(1); } }
/******* CASE M *******/ void ModifyNode(string pathSubstring) { GameObject nodeToModify = NodeUtility.GetNodeWithGivenPath(pathSubstring, parent); NodeBehavior nodeToModifyBehavior = nodeToModify.GetComponent <NodeBehavior>(); if (nodeToModifyBehavior.leaf) { ParticleSystem particlesystem = (ParticleSystem)nodeToModify.GetComponent("ParticleSystem"); particlesystem.particleSystem.Play(); particlesystem.enableEmission = true; } else { parent = nodeToModify; } }
} // close function /******* CASE A *******/ void AddNode(string pathSubstring, string[] singleFilePathArray, int directoryLevel) { // create node if it doesn't exist if (NodeUtility.StringExistsAsNode(pathSubstring, parent) == false) { GameObject currentNode; bool isLeaf; if (directoryLevel == singleFilePathArray.Length - 1) { isLeaf = true; currentNode = (GameObject)Instantiate(NodeLeafPrefab, new Vector3(0, 0, 0), Quaternion.identity); } else { isLeaf = false; currentNode = (GameObject)Instantiate(NodeDirPrefab, new Vector3(0, 0, 0), Quaternion.identity); } currentNode = NodeUtility.PlaceNodeInScene(currentNode, parent); // accesses parent & adds a reference of the new node as being a child of parent & returns nodeBehavior NodeBehavior nodeToAddBehavior = setNodeAsChildOfParent(currentNode, pathSubstring); // filepath has a leaf node at the end i.e. when we're at the end of singleFilePathArray nodeToAddBehavior.leaf = isLeaf; if (!isLeaf) { parent = currentNode; parentBehavior = currentNode.GetComponent <NodeBehavior>(); } SetNodeText(currentNode, pathSubstring); } // close if // else the node with substring exists and continue traversal else { parent = NodeUtility.GetNodeWithGivenPath(pathSubstring, parent); // get node GameObject parentBehavior = parent.GetComponent <NodeBehavior>(); } }
/******* CASE D *******/ void DeleteNode(string pathSubstring, int directoryLevel) { GameObject nodeToDelete = NodeUtility.GetNodeWithGivenPath(pathSubstring, parent); NodeBehavior nodeToDeleteBehavior = nodeToDelete.GetComponent <NodeBehavior>(); if (nodeToDeleteBehavior.leaf) { // myKids is read-only so put it into a usable variable int parentKidsCount = parent.GetComponent <NodeBehavior>().myKids.Count; // this doesn't decrement the parentBehavior's myKids.Count so using parentKidsCount... NodeUtility.RemoveNode(nodeToDelete, this); // using parentKidsCount to check if a parent directory will be empty after node deletions parentKidsCount--; // git doesn't allow empty directories - it considers them implicitly deleted if (parentKidsCount < 1) { NodeUtility.RemoveNode(parent, this); } } parent = nodeToDelete; }
void StartOver() { NodeUtility.RemoveNode(ROOT, this); BeginViz(); }