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>()); }