 
 (defn get-all-components-on-entity
     "Get all the components on a specific entity. Useful for debugging"
-    [entity]
-    (map #(get-in @entity-components [% entity]) (get @entity-component-types entity)))+    [system entity]
+    (map #(get-in (:entity-components system) [% entity]) (get (:entity-component-types system) entity)))
    [system]
    (:all-entities system))

(defn store-entity
    "Store the entity in the Entity System"
    [system entity]
    (let [system (transient system)]
        (->
            system
            (assoc! :all-entities (conj! (get-all-entities) entity))
            (assoc! :entity-component-types (assoc! (:entity-component-types system) entity #{}))
            persistent!)))

#_


(defn get-component
    "Get the component data for a specific component type"
    [system entity type]
    (-> system :entity-components (get-in [type entity])))

#_
(defn get-component
    "Get the component data for a specific component type"
    [entity type]
    (get-in @entity-components [type entity]))

(defn get-all-entities-with-component
    "Get all the entities that have a given component type"
    [system type]
    (if-let [entities (-> system :entity-components (get type) keys)]
        entities
        []))

(defn remove-component
    "Remove a component instance from an entity"
    [system entity instance]
    (let [type (get-component-type instance)
          system (transient system)
          entity-components (:entity-components system)
          entity-component-types (:entity-component-types system)]
        (-> system
            (assoc! :entity-components (assoc! entity-components type (-> entity-components (get type) (dissoc! entity))))
            (assoc! :entity-component-types (assoc! entity-component-types entity (-> entity-component-types (get entity) (disj! type))))
            persistent!)))

#_
(defn remove-component!
    "Remove a component instance from an entity"
    [entity instance]
