public void SendUpdate(Metadata.Update update) { var component = EntityManager.GetComponentData <Metadata.Component>(Entity); if (update.EntityType.HasValue) { component.EntityType = update.EntityType.Value; } EntityManager.SetComponentData(Entity, component); }
/// <summary> /// Create Updates for the Life and metadata components to the provided next state /// </summary> /// <param name="e"></param> /// <param name="isAliveNextState"></param> private static void CreateComponentUpdates(Connection connection, EntityId id, Entity e, bool isAliveNextState) { ulong curSequenceId = GetLatestSequenceId(e); bool curIsAlive = IsCellAlive(curSequenceId, id, e); //Update metadata for visualization in inspector Metadata.Update mu = new Metadata.Update(); if (isAliveNextState) { mu.SetEntityType(EntityTypeCellAlive); } else { mu.SetEntityType(EntityTypeCellDead); } //Create new component update object Life.Update lu = new Life.Update(); //set prev state and count id to the current state and time id lu.SetPrevSequenceId(curSequenceId); lu.SetPrevIsAlive(curIsAlive); //Set new current state lu.SetCurIsAlive(isAliveNextState); lu.SetCurSequenceId(curSequenceId + 1); //Add to the view ViewEntity viewEntity; if (EntityView.TryGetValue(id, out viewEntity)) { viewEntity.hasUpdate = true; viewEntity.metadataUpdate = mu; viewEntity.lifeUpdate = lu; } }