public void StateDefinitionTestSimplePasses() { DummyClass dc = new DummyClass(); DummyClass copy = new DummyClass(); dc.i = 1; dc.f = 2f; dc.d = 3d; dc.l = 4L; dc.v = new Vector3(1, 2, 3); dc.q = Quaternion.Euler(30f, 45f, 15f); dc.notRecorded = 1; StateDefinition sd = StateDefinitionFactory.CreateDefinition(typeof(DummyClass), "i", "f"); byte[] bytes = sd.GetState(dc); Debug.Log("State of data container: " + System.BitConverter.ToString(bytes)); sd.SetState(copy, bytes); Assert.AreEqual(dc.i, copy.i); Assert.AreEqual(dc.f, copy.f); Assert.AreEqual(dc.d, copy.d); Assert.AreEqual(dc.l, copy.l); Assert.AreNotEqual(dc.notRecorded, copy.notRecorded); }
// We remember the parents for States separately from the State object itself // to make it easier to deal with deserialized states (which lack the parent structure) /// <summary> /// Add a new state definition /// </summary> public static State AddState(string name, Func <TStateMachine, TEvent, State, TContext, Task>?entryAction = null, Func <TStateMachine, State, TEvent, TContext, Task>?exitAction = null, State?parent = null) { var stateDefinition = new StateDefinition(name, entryAction, exitAction, parent); definitions.Add(name, stateDefinition); return(stateDefinition.GetState()); }