public ActiveWorld() { if (_activeWorld != null) { throw new Exception("Multiple active worlds initialized! Only one active world object should exist!"); } _activeWorld = this; _instances = new UISafeObservableCollection <Instance>(); _world = new World(true); _instances.Add(_world); _sky = new Sky(true); _instances.Add(_sky); _camera = new Camera(true); }
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); }
public DataContext() { _isRunning = false; _activeWorld = new ActiveWorld(); }