void LoadReplay(string name) { List <FixedQueue <StateDescriptor> > fieldStates; List <FixedQueue <StateDescriptor> > robotStates; Dictionary <string, List <FixedQueue <StateDescriptor> > > gamePieceStates; List <List <KeyValuePair <ContactDescriptor, int> > > contacts; string simSelectedField; string simSelectedRobot; ReplayImporter.Read(name, out simSelectedField, out simSelectedRobot, out fieldStates, out robotStates, out gamePieceStates, out contacts); LoadField(simSelectedField); LoadRobot(simSelectedRobot); List <Tracker> robotTrackers = Trackers.Where(x => x.transform.parent.name.Equals("Robot")).ToList(); List <Tracker> fieldTrackers = Trackers.Except(robotTrackers).ToList(); int i = 0; foreach (Tracker t in fieldTrackers) { t.States = fieldStates[i]; i++; } i = 0; foreach (Tracker t in robotTrackers) { t.States = robotStates[i]; i++; } foreach (KeyValuePair <string, List <FixedQueue <StateDescriptor> > > k in gamePieceStates) { GameObject referenceObject = GameObject.Find(k.Key); if (referenceObject == null) { continue; } foreach (FixedQueue <StateDescriptor> f in k.Value) { GameObject currentPiece = UnityEngine.Object.Instantiate(referenceObject); currentPiece.name = "clone_" + k.Key; currentPiece.GetComponent <Tracker>().States = f; } } foreach (var c in contacts) { if (c != null) { List <ContactDescriptor> currentContacts = new List <ContactDescriptor>(); foreach (var d in c) { ContactDescriptor currentContact = d.Key; currentContact.RobotBody = robotTrackers[d.Value].GetComponent <BRigidBody>(); currentContacts.Add(currentContact); } contactPoints.Add(currentContacts); } else { contactPoints.Add(null); } } }