public void LoadEntities(string data) { { var keyvalues = KeyValuesParser.ParseAll(data); //For diagnostics: index of the entity in the entity data var index = 0; foreach (var block in keyvalues) { //Better error handling than the engine: if an entity couldn't be created, log it and keep going try { LoadEntity(block, index); } catch (ArgumentException e) { Log.Message($"A problem occurred while creating entity {index}:"); Log.Exception(e); } ++index; } } //At this point we'll have a lot of garbage, so clean up as much as possible GC.Collect(); }
private void LoadEntities(string entityData) { var keyvalues = KeyValuesParser.ParseAll(entityData); for (var index = 0; index < keyvalues.Count; ++index) { //Better error handling than the engine: if an entity couldn't be created, log it and keep going try { LoadEntity(keyvalues[index], index); } catch (EntityInstantiationException e) { _logger.Error(e, $"A problem occurred while creating entity {index}"); } } }
public void LoadEntities(string entityData) { var keyvalues = KeyValuesParser.ParseAll(entityData); for (var index = 0; index < keyvalues.Count; ++index) { //Better error handling than the engine: if an entity couldn't be created, log it and keep going try { LoadEntity(keyvalues[index], index); } catch (EntityInstantiationException e) { Logger.Error(e, $"A problem occurred while creating entity {index}"); } } //TODO: maybe verify that this is worldspawn? World = Entities[0].GetComponent <Collider>(); }