public static TTOTDWordObject load(int addr, ProcessMemoryInterface iface) { var wO = new TTOTDWordObject(); wO.address = addr; wO.enabled = iface.getU16(addr + 0x4D) != 0x0001; wO.proximity = iface.getF32(addr + 0x48); wO.wordLength = iface.getU8(addr + 0x98); wO.typedLength = iface.getU8(addr + 0x99); wO.word = iface.getStringL(addr + 0x58, wO.wordLength); wO.pmI = iface; return(wO); }
static TTOTDWordObject[] getWordList() { var count = todInterface.getU32(WORDPOINTERS_LENG); int[] wordOPointers = new int[count]; TTOTDWordObject[] objects = new TTOTDWordObject[count]; for (int i = 0; i < count; i++) { wordOPointers[i] = todInterface.getI32(WORDPOINTERS_BASE + (4 * i)); } for (int i = 0; i < count; i++) { objects[i] = TTOTDWordObject.load(wordOPointers[i], todInterface); } return(objects); }
static TTOTDWordObject getBestWord(TTOTDWordObject[] words) { // Find the closest word that we can type on and return it TTOTDWordObject bestWord = null; for (int i = 0; i < words.Length; i++) { if (words[i].enabled) { if (words[i].proximity < (bestWord == null ? 100000 : bestWord.proximity)) // N: Proximity is never over 1 { bestWord = words[i]; } } } return(bestWord); }
static void typeWord(TTOTDWordObject word) { Console.Write($"typeWord {word.word} : "); var lastWordLen = 0; var anythingTyped = false; while (true) { if (word == null) { break; } word.update(); if (word.typedLength == word.wordLength) { break; } if (word.typedLength < lastWordLen) { break; } lastWordLen = word.typedLength; if (!DoesTTODHaveFocus() || !word.enabled) { Thread.Sleep(3); continue; } var wordString = word.word; var currentInput = wordString[word.typedLength]; simulateKeyPress(currentInput); Console.Write($"{currentInput}"); if (word.typedLength + 1 == word.wordLength) { break; } anythingTyped = true; word.update(); Thread.Sleep(35); } if (anythingTyped == true) { Console.WriteLine(); } }