public byte[] ToBytes() { using var stream = new MemoryStream(); stream.Write(Players.ToBytes().ToArray()); stream.Write(Faulty.ToBytes().ToArray()); stream.Write(Cycle.ToBytes().ToArray()); foreach (var publicKey in _publicKeys) { stream.Write(publicKey.Buffer.ToArray()); } foreach (var keyGenState in _keyGenStates) { var bytes = keyGenState.ToBytes(); stream.Write(bytes.Length.ToBytes().ToArray()); stream.Write(bytes); } stream.Write(_finished.Count.ToBytes().ToArray()); foreach (var f in _finished) { stream.Write(f.ToBytes().ToArray()); } stream.Write(_confirmations.Count.ToBytes().ToArray()); foreach (var confirmation in _confirmations) { stream.Write(confirmation.Key.ToBytes()); stream.Write(confirmation.Value.ToBytes().ToArray()); } stream.Write(new[] { _confirmSent ? (byte)1 : (byte)0 }); return(stream.ToArray()); }
protected void Start() { var faulty = new Faulty(); Rules.Module = this; faulty.Module = this; Backgrounds_moduleId = Backgrounds_moduleIdCounter++; Submit.OnInteract += HandlePressSubmit; check = Rules.Rules(); //The colors are now determined in the Rule Generator //This is due to the fact that all boolean values are determined at runtime //So these need to have values before the rules are randomized. ColBacking = Rules.ColBacking; ColButton = Rules.ColButton; if (ModuleType == Type.Faulty) { faulty.Rules(); } else { ButtonA.OnInteract += delegate() { HandlePressButton(ButtonA); return(false); }; correctMesh = ButtonAMesh; correctTextMesh = ButtonATextMesh; DebugLog("Backing is {0}, Button is {1}", colorList[ColBacking], colorList[ColButton]); } BackingMesh.material.color = color[ColBacking]; correctMesh.material.color = color[ColButton]; Faulty.ReadableText(ColButton, correctTextMesh); //Grab our X value for the table (the first instance of "true") RuleA = check.IndexOf(true); //Remove RuleA from check check[RuleA] = false; //If there are no true values left, it means the otherwise rule was reached twice if (!check.Contains(true)) { RuleB = RuleA; } //Otherwise, there's still another true value in check else { RuleB = check.IndexOf(true); } //coordX contains X values for the first letter, //and coordY contains Y values for the second letter GoalPresses = BGManualTable[coordX[RuleA], coordY[RuleB]]; //ToString("X") translates the number into a hexidecimal. //As it so happens, the columns use letters A-F, which fits perfectly into hexidecimal values. DebugLog("Row in table is {0} due to rule {1}", (coordX[RuleA] + 10).ToString("X"), RuleA + 1); DebugLog("Column in table is {0} due to rule {1}", (coordY[RuleB] + 10).ToString("X"), RuleB + 1); DebugLog("Number needed is {0}", GoalPresses); BombModule.OnActivate += delegate { activated = true; }; }
public List <KeyValuePair <string, string> > GetAsPropertyList() { return(new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>(nameof(DisplayName), DisplayName), new KeyValuePair <string, string>(nameof(FeatureId), FeatureId.ToString()), new KeyValuePair <string, string>(nameof(LocationId), LocationId.ToString()), new KeyValuePair <string, string>(nameof(Scope), Definition.Scope.ToString()), new KeyValuePair <string, string>(nameof(TimeActivated), TimeActivated.ToString()), new KeyValuePair <string, string>(nameof(Version), Version.ToString()), new KeyValuePair <string, string>(nameof(Faulty), Faulty.ToString()), new KeyValuePair <string, string>(nameof(SandBoxedSolutionLocation), SandBoxedSolutionLocation), new KeyValuePair <string, string>(nameof(Properties), Common.StringUtilities.PropertiesToString(Properties)) }); }