/// <summary> /// Registers the given object. /// Returns true if it was registered, false if it was already registered. /// </summary> /// <param name="o"></param> /// <returns></returns> public bool Register(object o) { if (o == null) { throw new ArgumentException("Object given is null."); } if (!registeredObjects.ContainsKey(o)) { // Create a definition for this type, if it doesn't exist. if (!definitions.ContainsKey(o.GetType())) { StateDefinition sd = StateDefinitionFactory.CreateDefinition(o.GetType()); definitions.Add(o.GetType(), sd); } registeredObjects.Add(o, new RecordableMetadata(nextObjID, TimeState.NOMINAL)); nextObjID++; //print("Registered object " + o.ToString() + ". Hashcode: " + o.GetHashCode()); return(true); } else { print("Dictionary contains key " + o + ": " + registeredObjects.ContainsKey(o)); } return(false); }
public TimeEngine() { // Ensure script execution order is set MaxSamples = DEFAULT_MAX_SAMPLES; // Create default definitions for Unity types StateDefinition def; def = StateDefinitionFactory.CreateDefinition(typeof(Rigidbody), "position", "rotation", "velocity", "angularVelocity"); definitions.Add(typeof(Rigidbody), def); def = StateDefinitionFactory.CreateDefinition(typeof(Rigidbody2D), "position", "rotation", "velocity", "angularVelocity"); definitions.Add(typeof(Rigidbody2D), def); def = StateDefinitionFactory.CreateDefinition(typeof(Transform), "position", "rotation", "localScale"); definitions.Add(typeof(Transform), def); def = StateDefinitionFactory.CreateDefinition(typeof(RectTransform), "position", "rotation", "localScale"); definitions.Add(typeof(RectTransform), def); Play(); }