(dump-scene) & (dump-actors) (for #3)

This commit is contained in:
~keith 2021-12-15 21:00:02 +00:00
parent ea2d68ba57
commit 99238fea55
Signed by: keith
GPG Key ID: 5BEBEEAB2C73D520
1 changed files with 27 additions and 1 deletions

View File

@ -145,7 +145,7 @@
(defun generate-load-forms (obj &key (prune t) (nice-syms nil))
"Generate code that restores the current state of obj."
(declare (type boolean prune))
(declare (type boolean prune nice-syms))
(let ((table (make-hash-table :test #'eq))
sym init-forms)
@ -164,3 +164,29 @@
,@init-forms
,sym)
))
(defun dump-scene (scene &key (destroy-after t) (prune t) (nice-syms nil))
"Suspend and serialize scene."
(declare (type scene scene))
(declare (type boolean destroy-after prune nice-syms))
[scene (suspend)]
(prog1 (generate-load-forms scene :prune prune :nice-syms nice-syms)
(if destroy-after
[scene (destroy)]
[scene (resume)])))
(defun dump-actors (actors &key (destroy-after t) (prune t) (nice-syms nil))
"Suspend and serialize actors."
(declare (type (proper-list actor) actors))
(declare (type boolean destroy-after prune nice-syms))
(loop for actor in actors
collect
(prog2
;; FIXME Children are destroyed with actor, but not serialized with it
[actor (suspend)]
(generate-load-forms actor :prune prune :nice-syms nice-syms)
(if destroy-after
[actor (destroy)]
[actor (resume)]))))