public ModuleStateObject GetModuleStateObject(bool forConfiguration) { ModuleStateObject mso = new ModuleStateObject(); mso.name = gameObject.name; mso.position = mo2MaComController.moduleRefPointerController.GetPartPointerByName(ModuleRefPointerController.PartNames.BackPlate.ToString()).transform.position; mso.rotation = mo2MaComController.moduleRefPointerController.GetPartPointerByName(ModuleRefPointerController.PartNames.BackPlate.ToString()).transform.rotation; foreach (JointCommandObject jco in jointCommandObjectDict.Values) { JointCommandObject jcoClone = jco.Clone(forConfiguration); mso.listOfJointCommands.Add(jcoClone); if (mso.period < jcoClone.period) { mso.period = jcoClone.period; } } foreach (Transform part in transform) { PartStateObject pso = new PartStateObject(); pso.name = part.name; pso.position = part.position; pso.rotation = part.rotation; mso.listOfPartStates.Add(pso); } return(mso); }
public void SetModuleStateObject(ModuleStateObject mso, bool reset = false) { if (reset) { foreach (PartStateObject pso in mso.listOfPartStates) { Transform part = transform.FindChild(pso.name); part.position = pso.position; part.rotation = pso.rotation; } } foreach (JointCommandObject jco in mso.listOfJointCommands) { SetJointFromJointCommandObject(jco, reset); } }