diff options
author | Colin Okay <colin@cicadas.surf> | 2022-06-29 11:54:24 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-06-29 11:54:24 -0500 |
commit | 82f71b0d13788b1cff9a24c5b652effd11631523 (patch) | |
tree | f0ec127b2f10f46029983ee95b6c72ef29bc504c /src/core-units/container.lisp | |
parent | 4d1ee56c96ce254134b692f0e3b3271c87a42b54 (diff) |
[refactor] [structure] modularized project file structure
Diffstat (limited to 'src/core-units/container.lisp')
-rw-r--r-- | src/core-units/container.lisp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core-units/container.lisp b/src/core-units/container.lisp new file mode 100644 index 0000000..afa68b3 --- /dev/null +++ b/src/core-units/container.lisp @@ -0,0 +1,32 @@ +;;;; units/container.lisp + +(in-package #:wheelwork) + + +(defclass/std container () + ((units :with :a)) + (:documentation "Just a list of units. Made into a class so that + transformation affine transformations methods can be specialzied on + whole groups of units")) + +(defmethod drop-unit ((unit unit)) + "Removes a unit from its container. Returns T if the unit actually was removed." + (when-let (container (unit-container unit)) + (setf + (container-units container) (delete unit (container-units container)) + (unit-container unit) nil) + t)) + +(defmethod add-unit ((container container) (unit unit)) + "Adds a unit to the end of a container (thus affecting render +order). Makes sure to remove the unit from its current container if +necessary." + (when (unit-container unit) + (drop-unit unit)) + (push unit (container-units container)) + (setf (unit-container unit) container) + unit) + +(defmethod cleanup ((container container)) + (dolist (u (container-units container)) + (cleanup u))) |