-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
scene.lisp
47 lines (34 loc) · 1.49 KB
/
scene.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(in-package #:org.shirakumo.fraf.trial)
(define-event scene-change () changed-node)
(define-event register (scene-change))
(define-event deregister (scene-change))
(defclass scene (bag event-loop)
((camera :initarg :camera :initform NIL :accessor camera)
(name-map :initform (make-hash-table :test 'equal) :accessor name-map)))
(defmethod enter :after ((camera camera) (scene scene))
(setf (camera scene) camera))
(defmethod unit (name (scene scene))
(gethash name (name-map scene)))
(trivial-deprecate:declaim-deprecated (function unit)
:software "trial"
:version "1.2.0"
:alternatives (node))
(defmethod node (name (scene scene))
(gethash name (name-map scene)))
(defmethod node (name (scene (eql T)))
(gethash name (name-map (scene +main+))))
(defmethod register ((entity entity) (scene scene))
(when (name entity)
(setf (gethash (name entity) (name-map scene)) entity))
(issue scene 'register :changed-node entity)
entity)
(defmethod register :after ((listener listener) (scene scene))
(add-listener listener scene))
(defmethod deregister ((entity entity) (scene scene))
(remhash (name entity) (name-map scene))
(issue scene 'deregister :changed-node entity)
entity)
(defmethod deregister :after ((listener listener) (scene scene))
(remove-listener listener scene))
(defmethod scene ((scene scene)) scene)
(defmethod apply-transforms progn ((scene scene)))