forked from Shirakumo/trial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscene.lisp
More file actions
66 lines (48 loc) · 1.91 KB
/
scene.lisp
File metadata and controls
66 lines (48 loc) · 1.91 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#|
This file is a part of trial
(c) 2016 Shirakumo http://tymoon.eu (shinmera@tymoon.eu)
Author: Nicolas Hafner <shinmera@tymoon.eu>
|#
(in-package #:org.shirakumo.fraf.trial)
(defvar *scene*)
(defclass scene (flare:scene event-loop entity)
())
(defclass scene-event (event)
((scene :initarg :scene :accessor scene)))
(defclass enter (scene-event)
((entity :initarg :entity :accessor entity)))
(defmethod print-object ((enter enter) stream)
(print-unreadable-object (enter stream :type T)
(format stream "~a => ~a" (entity enter) (scene enter))))
(defclass leave (scene-event)
((entity :initarg :entity :accessor entity)))
(defmethod print-object ((leave leave) stream)
(print-unreadable-object (leave stream :type T)
(format stream "~a => ~a" (scene leave) (entity leave))))
(defmethod register :after ((entity entity) (scene scene))
(issue scene 'enter :scene scene :entity entity))
(defmethod deregister :after ((entity entity) (scene scene))
(issue scene 'leave :scene scene :entity entity))
(defmethod register :after ((container handler-container) (scene scene))
(add-handler container scene))
(defmethod deregister :after (thing (scene scene))
(remove-handler thing scene))
(defmethod paint :around ((scene scene) target)
(let ((*scene* scene))
(call-next-method)))
(defmethod process :around ((scene scene))
(let ((*scene* scene))
(call-next-method)))
(defmethod banned-slots append ((object scene))
'(queue handlers))
;; Since we have a tick event, we don't want to dupe that here.
;; animations and clock update are already handled by the method
;; combination, but defining a noop primary method prevents update
;; from being called on the children.
(defmethod flare:update ((scene scene)))
;; But we still need to call it in tick.
(defmethod handle :before ((event tick) (scene scene))
(flare:update scene))
(defmethod finalize :after ((scene scene))
(stop scene)
(clear scene))