public void TestHotReload() { _maps.CreateNewMapEntity(new MapId(0)); var entity = _entities.SpawnEntity(DummyId, MapCoordinates.Nullspace); var entityComponent = entity.GetComponent <HotReloadTestComponentOne>(); Assert.That(entityComponent.Value, Is.EqualTo(5)); Assert.False(entity.HasComponent <HotReloadTestComponentTwo>()); var reloaded = false; _prototypes.PrototypesReloaded += _ => reloaded = true; _prototypes.ReloadPrototypes(new List <IPrototype>()); Assert.True(reloaded); reloaded = false; Assert.That(entityComponent.Value, Is.EqualTo(5)); Assert.False(entity.HasComponent <HotReloadTestComponentTwo>()); var changedPrototypes = _prototypes.LoadString(ReloadedPrototypes, true); _prototypes.ReloadPrototypes(changedPrototypes); Assert.True(reloaded); reloaded = false; // Existing component values are not modified in the current implementation Assert.That(entityComponent.Value, Is.EqualTo(5)); // New components are added Assert.True(entity.HasComponent <HotReloadTestComponentTwo>()); changedPrototypes = _prototypes.LoadString(InitialPrototypes, true); _prototypes.ReloadPrototypes(changedPrototypes); Assert.True(reloaded); reloaded = false; // Existing component values are not modified in the current implementation Assert.That(entityComponent.Value, Is.EqualTo(5)); // Old components are removed Assert.False(entity.HasComponent <HotReloadTestComponentTwo>()); }
public void Setup() { _components = IoCManager.Resolve <IComponentFactory>(); _components.RegisterClass <HotReloadTestComponentOne>(); _components.RegisterClass <HotReloadTestComponentTwo>(); IoCManager.Resolve <ISerializationManager>().Initialize(); _prototypes = (PrototypeManager)IoCManager.Resolve <IPrototypeManager>(); _prototypes.LoadString(InitialPrototypes); _prototypes.Resync(); _maps = IoCManager.Resolve <IMapManager>(); _entities = IoCManager.Resolve <IEntityManager>(); }
public void Setup() { _components = IoCManager.Resolve <IComponentFactory>(); _components.RegisterClass <HotReloadTestOneComponent>(); _components.RegisterClass <HotReloadTestTwoComponent>(); _components.GenerateNetIds(); IoCManager.Resolve <ISerializationManager>().Initialize(); _prototypes = (PrototypeManager)IoCManager.Resolve <IPrototypeManager>(); _prototypes.RegisterType(typeof(EntityPrototype)); _prototypes.LoadString(InitialPrototypes); _prototypes.Resync(); _maps = IoCManager.Resolve <IMapManager>(); _entities = IoCManager.Resolve <IEntityManager>(); }