            [component]
     (class component))
 
+
+(defn add-component
+    "Add a component instance to a given entity. Will overwrite a component if already set."
+    [system entity instance]
+    (let [type (get-component-type instance)
+          system (transient system)
+          entity-components (:entity-components system)]
+        (-> system
+            (assoc! :entity-components (assoc! entity-components type (-> entity-components (get type) (assoc! entity instance))))
+            (assoc! :entity-component-types (-> system :entity-component-types (get entity) (conj! type) (assoc! entity))))
+        persistent!))
+
+#_
 (defn add-component!
     "Add a component instance to a given entity. Will overwrite a component if already set."
     [entity instance]

    [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!)))

#_

            (alter entity-components assoc type (dissoc (get @entity-components type) entity))
            (alter entity-component-types assoc entity (disj (get @entity-component-types entity) type)))))

#_
(reduce (fn [v e]
            (assoc v e (dissoc (get v e) :e)))
        m k)

(defn kill-entity
    "Destroy an entity completely."
    [system entity]
    (let [system (transient system)
          entity-component-types (:entity-component-types system)]
        (-> system
            (assoc! :all-entities (disj! (get-all-entities system)))
            (assoc! :entity-component-types (dissoc! entity-component-types entity))
            (assoc! :entity-components (reduce (fn [v type] (assoc! v type (dissoc! (get v type) entity)))
                                               (:entity-components system) (get entity-component-types entity)))
            persistent!)
        )
    )

#_
(defn kill-entity!
    "Destroy an entity completely."
    [entity]
