EntityRepository

The live, in-memory source of truth for which shapes currently exist. Deliberately separate from com.tcsappdev.worldwinddraw.core.state.DrawEngineState, which only tracks interaction mode — com.tcsappdev.worldwinddraw.core.history.Commands (via HistoryManager) are what mutate this.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val entities: StateFlow<List<DrawableEntity>>

The shapes that exist now, in drawing order (the last is drawn on top of the ones before it, unless a DrawableEntity.zIndex says otherwise). Collect it to follow every change.

Functions

Link copied to clipboard
fun add(entity: DrawableEntity)

Puts entity after the shapes there are. Not a history step (it cannot be undone).

Link copied to clipboard
fun remove(entityId: EntityId)

Takes away the shape with the id entityId; nothing happens if there is none. Not a history step.

Link copied to clipboard
fun replaceAll(newEntities: List<DrawableEntity>)

Makes newEntities, in that order, the shapes that exist, whatever there was before, as ONE change: whoever watches entities sees the old list and then the new one, never the many in-between lists that removing and adding one by one would show (and that would each make the map redraw). What a loaded file or a restored snapshot needs. An empty list clears the repository. Not a history step: it is a command's job to make a change that can be undone, and replacing everything is meant for the host to set the scene (clear the history with it, see HistoryManager.clear).

Link copied to clipboard
fun update(entity: DrawableEntity)

Replaces the shape that has the id of entity by entity, in the same place in the order; nothing happens if there is none. Not a history step.