private static void ResetInstance(Instance old, Instance current) { ObjectSave save = new ObjectSave(old, current, old.GetType()); save.Reset(); current.Reload(); }
public override Instance clone() { Script script = new Script(); ObjectSave save = new ObjectSave(this, script, GetType()); save.Reset(); return(script); }
public override Instance clone() { Part part = new Part(); ObjectSave save = new ObjectSave(this, part, GetType()); save.Reset(); return(part); }
private static void Reset() { ActiveWorld world = FlexUtility.DeserializeToObject(_savedState) as ActiveWorld; List <InstancePair> correspondings; List <Instance> removedInstances; List <Instance> newInstances; List <Instance> newChildren = new List <Instance>(); List <Instance> oldChildren = new List <Instance>(); LoadResetInstanceHelper(_context.ActiveWorld.World, world.World, newChildren, oldChildren); newInstances = newChildren.Where(x => !oldChildren.Any(y => x.Equals(y))).ToList(); removedInstances = oldChildren.Where(x => !newChildren.Any(y => x.Equals(y))).ToList(); correspondings = oldChildren.Join(newChildren, x => x, y => y, (x, y) => { return(new InstancePair(x, y)); }).ToList(); foreach (Instance newInstance in newInstances) { newInstance.Cleanup(); } foreach (Instance removedInstance in removedInstances) { /* * Implement */ } foreach (InstancePair instancePair in correspondings) { ObjectSave save = new ObjectSave(instancePair.Old, instancePair.Current, instancePair.Current.GetType()); save.Reset(); try { InstancePair oldParent = correspondings.Where(x => x.Old.equals(instancePair.Old.parent)).FirstOrDefault(); if (oldParent != null && oldParent.Current != null) { instancePair.Current.parent = oldParent.Current; } } catch { } instancePair.Current.Reload(); } ResetInstance(world.Sky, _context.ActiveWorld.Sky); }