/// <summary> /// Adds an entity to the snapshot /// </summary> /// <remarks> /// The entity ID is automatically assigned. /// </remarks> /// <param name="entityTemplate">The entity to be added to the snapshot.</param> /// <returns>The entity ID assigned to the entity in the snapshot.</returns> public EntityId AddEntity(EntityTemplate entityTemplate) { var entityId = new EntityId(entities.Count + 1); entities[entityId] = entityTemplate.GetEntity(); return(entityId); }
/// <summary> /// Adds an entity to the snapshot /// </summary> /// <param name="entityId">The entity ID of the entity to be added to the snapshot</param> /// <param name="entityTemplate">The entity to be added to the snapshot.</param> /// <remarks> /// You should obtain `entityId` using the `GetNextEntityId()` method, otherwise you could be given /// invalid entity IDs. /// </remarks> public void AddEntity(EntityId entityId, EntityTemplate entityTemplate) { if (entities.ContainsKey(entityId)) { throw new ArgumentException($"EntityId {entityId} already exists in the snapshot"); } var entity = entityTemplate.GetEntity(); // This is a no-op if the entity already has persistence. entity.Add(new ComponentData(PersistenceComponentId, SchemaComponentData.Create())); entities[entityId] = entity; }
/// <summary> /// Adds an entity to the snapshot /// </summary> /// <remarks> /// The entity ID is automatically assigned. /// </remarks> /// <param name="entityTemplate">The entity to be added to the snapshot.</param> public void AddEntity(EntityTemplate entityTemplate) { entities[new EntityId(entities.Count + 1)] = entityTemplate.GetEntity(); }
/// <summary> /// Adds an entity to the snapshot /// </summary> /// <param name="entityId">The entity ID of the entity to be added to the snapshot</param> /// <param name="entityTemplate">The entity to be added to the snapshot.</param> /// <remarks> /// You should obtain `entityId` using the `GetNextEntityId()` method, otherwise you could be given /// invalid entity IDs. /// </remarks> public void AddEntity(EntityId entityId, EntityTemplate entityTemplate) { entities[entityId] = entityTemplate.GetEntity(); }