public void TestRotorGroupEnigmaTest2() { List <int> fop1 = new List <int> { 17, }; List <int> fop2 = new List <int> { 5, }; List <int> fop3 = new List <int> { 22, }; Rotor rotorOne = new Rotor("Rotor III", 1, fop1); Rotor rotorTwo = new Rotor("Rotor II", 1, fop2); Rotor rotorThree = new Rotor("Rotor I", 1, fop3); Reflector reflector = new Reflector("B"); RotorGroup rg = new RotorGroup(rotorOne, rotorTwo, rotorThree, reflector); string expectedOut = "pgqpwitkgv"; string enigmaOut = ""; foreach (char c in "aaaaaaaaaa") { enigmaOut += rg.RotorEncrypt(c); } Assert.AreEqual(enigmaOut, expectedOut); }
public void CheckRotorIReturnsCorrectOutputToRightWithPositionARingB() { Rotor r; Letters right; // ring b, position a, k->a f->b r = Rotor.RotorI(Letters.B, Letters.A); // A //EKMFLGDQVZNTOWYHXUSPAIBRCJ right = r.GetRight(Letters.K); Assert.That(right, Is.EqualTo(Letters.A)); //B //EKMFLGDQVZNTOWYHXUSPAIBRCJ right = r.GetRight(Letters.F); Assert.That(right, Is.EqualTo(Letters.B)); // ring f, position y, w->a, h->b r = Rotor.RotorI(Letters.F, Letters.Y); // A //EKMFLGDQVZNTOWYHXUSPAIBRCJ right = r.GetRight(Letters.W); Assert.That(right, Is.EqualTo(Letters.A)); // B //EKMFLGDQVZNTOWYHXUSPAIBRCJ right = r.GetRight(Letters.H); Assert.That(right, Is.EqualTo(Letters.B)); }
public void CheckRotorIReturnsCorrectOutputToLeftWithPositionARingB() { Rotor r; Letters left; // ring b, position a, a->k b->f r = Rotor.RotorI(Letters.B, Letters.A); // A //EKMFLGDQVZNTOWYHXUSPAIBRCJ left = r.GetLeft(Letters.A); Assert.That(left, Is.EqualTo(Letters.K)); //B //EKMFLGDQVZNTOWYHXUSPAIBRCJ left = r.GetLeft(Letters.B); Assert.That(left, Is.EqualTo(Letters.F)); // ring f, position y, a->w, b->h r = Rotor.RotorI(Letters.F, Letters.Y); // A //EKMFLGDQVZNTOWYHXUSPAIBRCJ left = r.GetLeft(Letters.A); Assert.That(left, Is.EqualTo(Letters.W)); // B //EKMFLGDQVZNTOWYHXUSPAIBRCJ left = r.GetLeft(Letters.B); Assert.That(left, Is.EqualTo(Letters.H)); }
public Machine(Reflector reflector, Rotor left, Rotor middle, Rotor right) { this.reflector = reflector; this.left = left; this.middle = middle; this.right = right; }
public void TestDynamicInflow() { Rotor rotor = new Rotor().LoadDefault(); rotor.useDynamicInflow = true; rotor.trimflow = true; rotor.Collective = 0.25; rotor.Update(0.1); rotor.Collective = 1.0; // Simulate a bit Simulate(rotor, 0.05, 0.02); double thrust0 = rotor.Force [2]; double torque0 = rotor.Torque [2]; double coning0 = rotor.beta_0; Console.WriteLine("---"); // Simulate a bit further Simulate(rotor, 0.26, 0.02); double thrust1 = rotor.Force [2]; double torque1 = rotor.Torque [2]; double coning1 = rotor.beta_0; // Thrust and coning should initially be larger and then decrease due to inflow buildup // The opposite goes for moment Assert.IsTrue(Math.Abs(thrust1) < Math.Abs(thrust0)); Assert.IsTrue(Math.Abs(torque1) > Math.Abs(torque0)); Assert.IsTrue(Math.Abs(coning1) < Math.Abs(coning0)); }
// Start is called before the first frame update void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent <Craft>(); rotor = GetComponent <Rotor>(); rotor.minValue = 0; rotor.maxValue = player.speedlimit; }
/// <summary> /// Creates Enigma motors /// </summary> private static void BuildRotors() { // Rotor 1 int[] rotor1Cipher = { 4, 10, 12, 5, 11, 6, 3, 16, 21, 25, 13, 19, 14, 22, 24, 7, 23, 20, 18, 15, 0, 8, 1, 17, 2, 9 }; int[] rotor1Notches = { 16 }; _rotor1 = new Rotor(rotor1Cipher, rotor1Notches); // Rotor 2 int[] rotor2Cipher = { 0, 9, 3, 10, 18, 8, 17, 20, 23, 1, 11, 7, 22, 19, 12, 2, 16, 6, 25, 13, 15, 24, 5, 21, 14, 4 }; int[] rotor2Notches = { 4 }; _rotor2 = new Rotor(rotor2Cipher, rotor2Notches); // Rotor 3 int[] rotor3Cipher = { 1, 3, 5, 7, 9, 11, 2, 15, 17, 19, 23, 21, 25, 13, 24, 4, 8, 22, 6, 0, 10, 12, 20, 18, 16, 14 }; int[] rotor3Notches = { 21 }; _rotor3 = new Rotor(rotor3Cipher, rotor3Notches); // Rotor 4 int[] rotor4Cipher = { 4, 18, 14, 21, 15, 25, 9, 0, 24, 16, 20, 8, 17, 7, 23, 11, 13, 5, 19, 6, 10, 3, 2, 12, 22, 1 }; int[] rotor4Notches = { 9 }; _rotor4 = new Rotor(rotor4Cipher, rotor4Notches); // Rotor 5 int[] rotor5Cipher = { 21, 25, 1, 17, 6, 8, 19, 24, 20, 15, 18, 3, 13, 7, 11, 23, 0, 22, 12, 9, 16, 14, 5, 4, 2, 10 }; int[] rotor5Notches = { 12, 25 }; _rotor5 = new Rotor(rotor5Cipher, rotor5Notches); // Rotor 6 int[] rotor6Cipher = { 9, 15, 6, 21, 14, 20, 12, 5, 24, 16, 1, 4, 13, 7, 25, 17, 3, 10, 0, 18, 23, 11, 8, 2, 19, 22 }; int[] rotor6Notches = { 12, 25 }; _rotor6 = new Rotor(rotor6Cipher, rotor6Notches); // Rotor 7 int[] rotor7Cipher = { 13, 25, 9, 7, 6, 17, 2, 23, 12, 24, 18, 22, 1, 14, 20, 5, 0, 8, 21, 11, 15, 4, 10, 16, 3, 19 }; int[] rotor7Notches = { 12, 25 }; _rotor7 = new Rotor(rotor7Cipher, rotor7Notches); // Rotor 8 int[] rotor8Cipher = { 5, 10, 16, 7, 19, 11, 23, 14, 2, 1, 9, 18, 15, 3, 25, 17, 0, 12, 4, 22, 13, 8, 20, 24, 6, 21 }; int[] rotor8Notches = { 12, 25 }; _rotor8 = new Rotor(rotor8Cipher, rotor8Notches); }
public void Motor_Blend() { var r1 = new Rotor(MathF.PI * 0.5f, 0, 0, 1f); var t1 = new Translator(1f, 0f, 0f, 1f); Motor m1 = r1 * t1; var r2 = new Rotor(MathF.PI * 0.5f, 0.3f, -3f, 1f); var t2 = new Translator(12f, -2f, 0.4f, 1f); Motor m2 = r2 * t2; Motor motion = m2 * ~m1; Line step = Log(motion) / 4f; Motor motor_step = Exp(step); // Applying motor_step 0 times to m1 is m1. // Applying motor_step 4 times to m1 is m2 * ~m1; Motor result = motor_step * motor_step * motor_step * motor_step * m1; Assert.AreEqual(m2.Scalar, result.Scalar, Epsilon); Assert.AreEqual(m2.e12, result.e12, Epsilon); Assert.AreEqual(m2.e31, result.e31, Epsilon); Assert.AreEqual(m2.e23, result.e23, Epsilon); Assert.AreEqual(m2.e01, result.e01, Epsilon); Assert.AreEqual(m2.e02, result.e02, Epsilon); Assert.AreEqual(m2.e03, result.e03, Epsilon); Assert.AreEqual(m2.e0123, result.e0123, Epsilon); }
public void CheckOperationBarbarosaMessage() { string expectedPlainText = "AUFKLXABTEILUNGXVONXKURTINOWAXKURTINOWAXNORDWESTLXSEBEZXSEBEZXUAFFLIEGERSTRASZERIQTUNGXDUBROWKIXDUBROWKIXOPOTSCHKAXOPOTSCHKAXUMXEINSAQTDREINULLXUHRANGETRETENXANGRIFFXINFXRGTX"; // Message Key: BLA // Reflector: B // Wheel order: II IV V // Ring positions: 02 21 12 // Plug Pairs: AV BS CG DL FU HZ IN KM OW RX Scrambler3 s = new Scrambler3(Reflector.ReflectorB(), Rotor.RotorII((Letters)1, Letters.B), Rotor.RotorIV((Letters)20, Letters.L), Rotor.RotorV((Letters)11, Letters.A)); Plugboard p = new Plugboard(new Dictionary <Letters, Letters> { { Letters.A, Letters.V }, { Letters.B, Letters.S }, { Letters.C, Letters.G }, { Letters.D, Letters.L }, { Letters.F, Letters.U }, { Letters.H, Letters.Z }, { Letters.I, Letters.N }, { Letters.K, Letters.M }, { Letters.O, Letters.W }, { Letters.R, Letters.X }, }); EnigmaM3 e = new EnigmaM3(s, p); string cypherText = "EDPUDNRGYSZRCXNUYTPOMRMBOFKTBZREZKMLXLVEFGUEYSIOZVEQMIKUBPMMYLKLTTDEISMDICAGYKUACTCDOMOHWXMUUIAUBSTSLRNBZSZWNRFXWFYSSXJZVIJHIDISHPRKLKAYUPADTXQSPINQMATLPIFSVKDASCTACDPBOPVHJK"; string plainText = e.GetOutput(cypherText); Assert.That(plainText, Is.EqualTo(expectedPlainText)); }
public void Rotor_InitializedWithStaticFactory_IsNotNull() { var rotor = Rotor.Default(); rotor.Should() .NotBeNull(); }
public void Rotor_RotatesCorrectly() { Rotor testRotor = rotorFactory.CreateRotor("I", 'A'); testRotor.IncrementDeflection(); Assert.AreEqual(testRotor.Deflection, 1); }
public void CheckInstructionManualMessage() { string expectedPlainText = "FEINDLIQEINFANTERIEKOLONNEBEOBAQTETXANFANGSUEDAUSGANGBAERWALDEXENDEDREIKMOSTWAERTSNEUSTADT"; // Message Key: ABL // Reflector: A // Wheel order: II I III // Ring positions: 24 13 22 // Plug Pairs: AM FI NV PS TU WZ Scrambler3 s = new Scrambler3(Reflector.ReflectorA(), Rotor.RotorII((Letters)23, Letters.A), Rotor.RotorI((Letters)12, Letters.B), Rotor.RotorIII((Letters)21, Letters.L)); Plugboard p = new Plugboard(new Dictionary <Letters, Letters> { { Letters.A, Letters.M }, { Letters.F, Letters.I }, { Letters.N, Letters.V }, { Letters.P, Letters.S }, { Letters.T, Letters.U }, { Letters.W, Letters.Z }, }); EnigmaM3 e = new EnigmaM3(s, p); string cypherText = "GCDSEAHUGWTQGRKVLFGXUCALXVYMIGMMNMFDXTGNVHVRMMEVOUYFZSLRHDRRXFJWCFHUHMUNZEFRDISIKBGPMYVXUZ"; string plainText = e.GetOutput(cypherText); Assert.That(plainText, Is.EqualTo(expectedPlainText)); }
public void Construct_Motor() { var r = new Rotor(MathF.PI * 0.5f, 0, 0, 1f); var t = new Translator(1f, 0f, 0f, 1f); Motor m = r * t; var p1 = new Point(1, 0, 0); Point p2 = m[p1]; Assert.AreEqual(0f, p2.X); Assert.AreEqual(-1f, p2.Y, Epsilon); Assert.AreEqual(1f, p2.Z, Epsilon); // Rotation and translation about the same axis commutes m = t * r; p2 = m[p1]; Assert.AreEqual(0f, p2.X); Assert.AreEqual(-1f, p2.Y, Epsilon); Assert.AreEqual(1f, p2.Z, Epsilon); Line l = Log(m); Assert.AreEqual(0f, l.e23); Assert.AreEqual(0.7854, l.e12, Epsilon); Assert.AreEqual(0f, l.e31); Assert.AreEqual(0f, l.e01); Assert.AreEqual(0f, l.e02); Assert.AreEqual(-0.5, l.e03, Epsilon); }
public void TestRotorCreation() { List <int> fop1 = new List <int> { 17, }; List <int> fop2 = new List <int> { 5, }; List <int> fop3 = new List <int> { 22, }; Rotor rotorOne = new Rotor("Rotor I", 0, fop1); Rotor rotorTwo = new Rotor("Rotor II", 15, fop2); Rotor rotorThree = new Rotor("Rotor III", 25, fop3); string expectedR1Name = "Rotor I"; string expectedR2Name = "Rotor II"; string expectedR3Name = "Rotor III"; int expectedR1Offset = 0; int expectedR2Offset = 15; int expectedR3Offset = 25; List <int> expectedfop = new List <int> { 17, }; Assert.AreEqual(rotorOne.Name, expectedR1Name); Assert.AreEqual(rotorTwo.Name, expectedR2Name); Assert.AreEqual(rotorThree.Name, expectedR3Name); Assert.AreEqual(rotorOne.RotorOffset, expectedR1Offset); Assert.AreEqual(rotorTwo.RotorOffset, expectedR2Offset); Assert.AreEqual(rotorThree.RotorOffset, expectedR3Offset); }
public void Reset() { internalReset(); Rotor.SetValue("RotorLock", false); IncrementAngle = ResetInstructions.TargetAngle; State = RotorState.resetting; }
public virtual void CalcPointsCoordinates() { if (Stator == null) { throw new ArgumentNullException("StatorParams null"); } if (Rotor == null) { throw new ArgumentNullException("RotorParams null"); } if (Airgap == null) { throw new ArgumentNullException("AirgapParams null"); } Rotor.CalculatePoints(); Stator.CalculatePoints(); Airgap.CalculatePoints(); ListParamsValidation = new List <ParamValidationInfo>(); if (Rotor.ListParamsValidation != null) { ListParamsValidation.AddRange(Rotor.ListParamsValidation); } if (Stator.ListParamsValidation != null) { ListParamsValidation.AddRange(Stator.ListParamsValidation); } isPointsCoordCalculated = true; }
static void Main(string[] args) { Rotor rL = new Rotor(FixedMechanicRotor.ROTOR_II); //II has notch F Rotor rM = new Rotor(FixedMechanicRotor.ROTOR_IV); //IV has notch K Rotor rR = new Rotor(FixedMechanicRotor.ROTOR_V); //V has notch A //Following WW2 Convention, it is Left-Mid-Right e.g. II IV V Rotor[] rotors = { rL, rM, rR }; Reflector re = new Reflector(FixedMechanicReflector.REFLECTOR_B); Plugboard plug = new Plugboard(new String[] { "AV", "BS", "CG", "DL", "FU", "HZ", "IN", "KM", "OW", "RX"}); //Barbarosa WindowSetting initialSetting = new WindowSetting('B', 'L', 'A'); RingSetting ringPositions = new RingSetting(2, 21, 12); //an example of naming hassle because Enigma is both namespace and class Enigma.representation.Enigma enigma = new Enigma.representation.Enigma(rotors, re, plug, ringPositions, initialSetting); string myfile = "C:\\Users\\ToshiW\\Documents\\Visual Studio 2012\\Projects\\Enigma\\Enigma\\Resources\\BarbarosaCiphertext.txt"; string input = Utility.FileToString(myfile); //Console.WriteLine(readResult); //Console.ReadLine(); //Let Enigma do its thing string result = enigma.encryptString(input); Console.WriteLine(result); Console.ReadLine(); }
public void CheckU264Message() { string expectedPlainText = "VONVONJLOOKSJHFFTTTEINSEINSDREIZWOYYQNNSNEUNINHALTXXBEIANGRIFFUNTERWASSERGEDRUECKTYWABOSXLETZTERGEGNERSTANDNULACHTDREINULUHRMARQUANTONJOTANEUNACHTSEYHSDREIYZWOZWONULGRADYACHTSMYSTOSSENACHXEKNSVIERMBFAELLTYNNNNNNOOOVIERYSICHTEINSNULL"; // Message Key: VJNA // Reflector: Thin B // Wheel order: Beta II IV I // Ring positions: 01 01 01 22 // Plug Pairs: AT BL DF GJ HM NW OP QY RZ VX Scrambler4 s = new Scrambler4(Reflector.ReflectorThinB(), Rotor.RotorBeta((Letters)0, Letters.V), Rotor.RotorII((Letters)0, Letters.J), Rotor.RotorIV((Letters)0, Letters.N), Rotor.RotorI((Letters)21, Letters.A)); Plugboard p = new Plugboard(new Dictionary <Letters, Letters> { { Letters.A, Letters.T }, { Letters.B, Letters.L }, { Letters.D, Letters.F }, { Letters.G, Letters.J }, { Letters.H, Letters.M }, { Letters.N, Letters.W }, { Letters.O, Letters.P }, { Letters.Q, Letters.Y }, { Letters.R, Letters.Z }, { Letters.V, Letters.X }, }); EnigmaM4 e = new EnigmaM4(s, p); string cypherText = "NCZWVUSXPNYMINHZXMQXSFWXWLKJAHSHNMCOCCAKUQPMKCSMHKSEINJUSBLKIOSXCKUBHMLLXCSJUSRRDVKOHULXWCCBGVLIYXEOAHXRHKKFVDREWEZLXOBAFGYUJQUKGRTVUKAMEURBVEKSUHHVOYHABCJWMAKLFKLMYFVNRIZRVVRTKOFDANJMOLBGFFLEOPRGTFLVRHOWOPBEKVWMUQFMPWPARMFHAGKXIIBG"; string plainText = e.GetOutput(cypherText); Assert.That(plainText, Is.EqualTo(expectedPlainText)); }
public void Motor_ExpLogSqrt() { // Construct a Motor from a Translator and Rotor var r = new Rotor(MathF.PI * 0.5f, 0.3f, -3f, 1f); var t = new Translator(12f, -2f, 0.4f, 1f); Motor m1 = r * t; Line l = Log(m1); Motor m2 = Exp(l); Assert.AreEqual(m2.Scalar, m1.Scalar, Epsilon); Assert.AreEqual(m2.e12, m1.e12, Epsilon); Assert.AreEqual(m2.e31, m1.e31, Epsilon); Assert.AreEqual(m2.e23, m1.e23, Epsilon); Assert.AreEqual(m2.e01, m1.e01, Epsilon); Assert.AreEqual(m2.e02, m1.e02, Epsilon); Assert.AreEqual(m2.e03, m1.e03, Epsilon); Assert.AreEqual(m2.e0123, m1.e0123, Epsilon); Motor m3 = Sqrt(m1) * Sqrt(m1); Assert.AreEqual(m3.Scalar, m1.Scalar, Epsilon); Assert.AreEqual(m3.e12, m1.e12, Epsilon); Assert.AreEqual(m3.e31, m1.e31, Epsilon); Assert.AreEqual(m3.e23, m1.e23, Epsilon); Assert.AreEqual(m3.e01, m1.e01, Epsilon); Assert.AreEqual(m3.e02, m1.e02, Epsilon); Assert.AreEqual(m3.e03, m1.e03, Epsilon); Assert.AreEqual(m3.e0123, m1.e0123, Epsilon); }
/* Initializes an assembly based on: * Spin_key: how each rotor */ internal Assembly(int[][] assembly_key, int[] spin_key) { rotors = new Rotor[assembly_key.Length]; for (int i = 0; i < assembly_key.Length; i++) { rotors[i] = new Rotor(assembly_key[i], spin_key[i]); } }
private void internalReset() { Rotor.SetValue("RotorLock", LockRotor); Rotor.TargetVelocityRPM = 0; currentInstructionIndex = 0; currentTimeWaited = 0; TempInstructions = null; }
public HelicopterSettings() { Health = 200; RotorHealth = new Rotor(); Speed = 110; BulletDamage = 10; MaxCrates = 3; }
private void TestRotorReflection(string rotorType, char offset) { var rotor = Rotor.Create(rotorType, offset); IEnumerable <char> mappedLetters = AlphabetLetters.Select(l => rotor.GetMappedLetter(l)).ToArray(); IEnumerable <char> reversedLetters = mappedLetters.Select(l => rotor.GetMappedLetter(l, LetterMapper.MappingDirection.LeftToRight)); Assert.IsTrue(SequencesOrderedEqual(AlphabetLetters, reversedLetters)); }
public void SaveUnitsConfiguration() { Needle.SaveConfiguration("NeedleConfiguration"); Conveyor.SaveConfiguration("ConveyorConfiguration"); Charger.SaveConfiguration("ChargerConfiguration"); Rotor.SaveConfiguration("RotorConfiguration"); Pomp.SaveConfiguration("PompConfiguration"); }
public void LoadUnitsConfiguration() { Needle.LoadConfiguration("NeedleConfiguration"); Conveyor.LoadConfiguration("ConveyorConfiguration"); Charger.LoadConfiguration("ChargerConfiguration"); Rotor.LoadConfiguration("RotorConfiguration"); Pomp.LoadConfiguration("PompConfiguration"); }
public void Resume() { if (State == RotorState.suspended || State == RotorState.waiting) { Rotor.SetValue("RotorLock", false); State = RotorState.active; } }
public override void ParametrizeUnityFromModel() { base.ParametrizeUnityFromModel(); mainRotor = _model.MainRotor; tailRotor = _model.TailRotor; horizontalStabilizer = _model.HorizontalStabilizer; verticalStabilizer = _model.VerticalStabilizer; }
/// <summary> /// Default constructor. /// </summary> /// <param name="plugboard">Plugboard.</param> /// <param name="left">Left rotor.</param> /// <param name="center">Center rotor.</param> /// <param name="right">Right rotor.</param> /// <param name="reflector">Reflector.</param> public Enigma(Plugboard plugboard, Rotor left, Rotor center, Rotor right, Reflector reflector) { _plugboard = plugboard; _left = left; _right = right; _center = center; _reflector = reflector; }
public void CheckRotorIReturnsCorrectOutputToRightWithPositionA() { Rotor r = Rotor.RotorI(Letters.A, Letters.A); Letters right = r.GetRight(Letters.S); Assert.That(right, Is.EqualTo(Letters.S)); }
public void CheckRotorIReturnsCorrectOutputToLeftWithPositionA() { Rotor r = Rotor.RotorI(Letters.A, Letters.A); Letters left = r.GetLeft(Letters.D); Assert.That(left, Is.EqualTo(Letters.F)); }
public char GetRotorIndex(int index, Rotor Rotor) { while (index != Rotor.Index) { Rotor = Rotor.pointer; } return(Rotor.letter); }
// Constructor public EnigmaMachine() { plugBoard = new Dictionary<char, char>(); // Notch and alphabet are fixed on the rotor // First argument is alphabet, second is the turnover notch Rotor rI = new Rotor(rotorIconf, 'Q', "I"); Rotor rII = new Rotor(rotorIIconf, 'E', "II"); Rotor rIII = new Rotor(rotorIIIconf, 'V', "III"); rotors = new Rotor[] { rI, rII, rIII }; // Default ordering of rotors reflector = new Rotor(reflectorAconf, ' ', ""); }
public static void Main(string[] args) { rotor = new Rotor(); // changer = new ChangerService(); rotor.setChangerService(changer); // wallpaperManager = new WallpaperManager(); rotor.setWallpaperManager(wallpaperManager); // rotor.start(); // Application.Init (); MainWindow win = new MainWindow (); win.Show (); Application.Run (); rotor.stop(); }
private void rotateRotors(Rotor[] r) { if (r.Length == 3) { if (r[1].isInTurnOver()) { // If rotor II is on turnOver, all rotors step r[0].step(); r[1].step(); } else if (r[2].isInTurnOver()) { // If rotor III is on turnOver, the two rotors to the right step r[1].step(); } // Rotor III always steps r[2].step(); } }
private int rotorValue(Rotor r, int cPos, bool reverse) { int rPos = (int)r.ring - 65; int d; if (!reverse) d = r.map[(26 + cPos + r.getOuterPosition() - rPos) % 26]; else d = r.revMap[(26 + cPos + r.getOuterPosition() - rPos) % 26]; return (cPos + d) % 26; }
/// This will not work correctly if a rotor is replaced in less than 10 updates. public void Update10() { if (partner == null) { if (myStator.IsAttached) { MyObjectBuilder_MotorStator statorBuilder = (myStator as IMyCubeBlock).GetObjectBuilder_Safe() as MyObjectBuilder_MotorStator; if (Registrar.TryGetValue(statorBuilder.RotorEntityId.Value, out partner)) { myLogger.debugLog("Set partner to " + partner.myRotor.DisplayNameText, Logger.severity.INFO); Attach(partner.myRotor); partner.partner = this; } else myLogger.alwaysLog("Failed to set partner, Rotor not in registrar.", Logger.severity.WARNING); } } else // partner != null if (!myStator.IsAttached && !myStator.IsLocked) { myLogger.debugLog("Removing partner " + partner.myRotor.DisplayNameText, Logger.severity.INFO); Detach(); partner.partner = null; partner = null; } }
static Enigma _createMachine(Rotor rotor1, Rotor rotor2, Rotor rotor3, Reflector reflector) { var enigma = new Enigma(); enigma.Rotor_1 = rotor1; enigma.Rotor_2 = rotor2; enigma.Rotor_3 = rotor3; enigma.Reflector = reflector; return enigma; }
public RotorSocket(Rotor rotor, char startingLetter = 'A') { SetupRotor(rotor, startingLetter); }
public void SetPreviousRotor(Rotor previous) { this.previous = previous; }
public void SetNextRotor(Rotor next) { this.next = next; }
public void SetupRotor(Rotor rotor, char startingLetter = 'A') { SetRingLetter(startingLetter); _rotor = rotor; }