public void EngineLoadsWorldComponentStates() { using (var GraphicsDevice = Mock.CreateGraphicsDevice()) using (var Engine = new StackEngine(StackGame.Empty, Mock.Wrap(GraphicsDevice), Mock.Input, GameSettings.LoadFromConfigFile(""))) { var Bytes1 = State.Serialization.SaveState(Engine.Game.World); var SaveGame1 = new STACK.SaveGame("TestSave", Bytes1, null); Engine.Game.World.Get <Camera>().Zoom = 2f; var Bytes2 = State.Serialization.SaveState(Engine.Game.World); var SaveGame2 = new STACK.SaveGame("TestSave", Bytes2, null); Engine.LoadState(SaveGame1); Assert.AreEqual(1f, Engine.Game.World.Get <Camera>().Zoom); Engine.LoadState(SaveGame2); Assert.AreEqual(2f, Engine.Game.World.Get <Camera>().Zoom); } }
public void LoadSaveGameBeforeWorldStart() { STACK.SaveGame State; using (var GraphicsDevice = Mock.CreateGraphicsDevice()) using (var Runner = new TestEngine(StackGame.Empty, Mock.Wrap(GraphicsDevice), Mock.Input)) { Runner.StartGame(); Runner.Game.World.Scenes.FirstOrDefault().Push(new Entity("newobj")); Runner.Game.World.Interactive = false; State = new STACK.SaveGame("utest", STACK.State.Serialization.SaveState <World>(Runner.Game.World), new byte[0] { }); } using (var GraphicsDevice = Mock.CreateGraphicsDevice()) using (var Runner = new TestEngine(StackGame.Empty, Mock.Wrap(GraphicsDevice), Mock.Input)) { Runner.LoadState(State); Assert.AreEqual(1, Runner.Game.World.Scenes.FirstOrDefault().GameObjectCache.Entities.Count); Assert.AreEqual("newobj", Runner.Game.World.Scenes.FirstOrDefault().GameObjectCache.Entities.First().ID); Assert.IsFalse(Runner.Game.World.Interactive); } }