preparing for quittable scripts.

This commit is contained in:
Bryce Covert
2015-08-13 12:48:11 -07:00
parent 919695de81
commit ac3b8665ef
6 changed files with 66 additions and 66 deletions

View File

@@ -23,7 +23,7 @@
(done? [this screen entities])
(continue [this screen entities])
(terminate [this screen entities])
(can-skip? [this screen entities])
(skip-type [this screen entities])
(get-channel [this]))
(defn has-item? [entities item]
@@ -68,8 +68,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defmacro get-script [entities & forms]
`(fn [starting-entities#]
@@ -171,8 +171,8 @@
(done? [this screen entities] true)
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
@@ -223,8 +223,8 @@
(if (or (nil? stop?) stop?)
(stop screen entities target-id :face face)
entities))
(can-skip? [this screen entities]
false))))
(skip-type [this screen entities]
:none))))
(defn play-animation [entities target-id anim & {:keys [stop? continue?]}]
(run-action entities
@@ -244,8 +244,8 @@
(if (or (nil? stop?) stop?)
(stop screen entities target-id)
(assoc-in entities [:room :entities target-id :anim] nil))))
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn update-entity [entities target-id f]
(run-action entities
@@ -257,7 +257,7 @@
(done? [this screen entities] true)
(terminate [this screen entities] entities)
(can-skip? [this screen entities] false)))
(skip-type [this screen entities] :none)))
(defn stop-walking [entities target-id & {:keys [face]}]
(run-action entities
@@ -269,9 +269,9 @@
(done? [this screen entities] true)
(terminate [this screen entities] entities)
(can-skip? [this screen entities] false)))
(skip-type [this screen entities] :none)))
(defn walk-to [entities target-id [final-x final-y] & {:keys [can-skip? face force-dir]}]
(defn walk-to [entities target-id [final-x final-y] & {:keys [skip-type face force-dir]}]
(let [{start-x :x start-y :y} (get-in @entities [:room :entities target-id])
final-x (int final-x)
final-y (int final-y)
@@ -331,8 +331,8 @@
(terminate [this screen entities]
(stop screen entities target-id :face face))
(can-skip? [this screen entities]
(or can-skip? false)))
(skip-type [this screen entities]
(or skip-type :none)))
(do-stop entities :ego :face face))))
(defn get-text-duration [text]
@@ -385,8 +385,8 @@
(stop screen entities target-id)
entities))
entities))
(can-skip? [this screen entities]
true))))
(skip-type [this screen entities]
:skip))))
(defn something-else [zipper]
(-> zipper zip/up zip/up))
@@ -424,8 +424,8 @@
(terminate [this screen entities]
(screen! @(resolve 'advent.screens.scene/scene) :on-reactivate)
entities)
(can-skip? [this screen entities]
false))
(skip-type [this screen entities]
:none))
(let [zipper (nth-child zipper @selected-index)
node (zip/node zipper)]
@@ -448,8 +448,8 @@
(done? [this screen entities] true)
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn pause-camera [entities]
(update-entities entities #(-> %
@@ -468,8 +468,8 @@
(done? [this screen entities] true)
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
@@ -489,8 +489,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn play-sound [entities sound-file]
(let [m (music sound-file)]
@@ -506,8 +506,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false))))
(skip-type [this screen entities]
:none))))
(defn give [entities item]
(run-action entities
@@ -525,8 +525,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn remove-entity [entities entity]
(run-action entities
@@ -539,8 +539,8 @@
(terminate [this screen entities] entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none )))
(defn add-entity [entities id entity]
(run-action entities
@@ -553,8 +553,8 @@
(terminate [this screen entities] entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn get-music [music time]
(if (keyword? music)
@@ -586,8 +586,8 @@
(music! (utils/get-current-music entities) :play)
entities))
(can-skip? [this screen entities]
false))))
(skip-type [this screen entities]
:none))))
(defn transition-background [entities new-background [x y] & {:keys [transition-music? between time face]}]
@@ -624,8 +624,8 @@
(if-let [stop-fn (get-in entities [:room :stop-fn])]
(stop-fn screen entities)
entities)))
(can-skip? [this screen entities]
false))
(skip-type [this screen entities]
:none))
(run-action entities
(begin [this screen entities]
(let [ego (get-in entities [:room :entities :ego])
@@ -674,8 +674,8 @@
(add-timer! screen k start time))
entities)
(can-skip? [this screen entities]
false))))
(skip-type [this screen entities]
:none))))
(defn do-dialogue [entities & pairs]
(loop [pairs (partition 2 pairs)]
@@ -739,8 +739,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false))
(skip-type [this screen entities]
:none))
(Thread/sleep 800)
(actions/run-action entities
(begin [this screen entities]
@@ -759,8 +759,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn in-love [entities]

View File

@@ -140,8 +140,8 @@
(-> entities
(update-in [:room :entities] dissoc :bloodclot)
(assoc-in [:tweens :flash] (tween/tween :flash screen [:white-fade :opacity] 0.0 1.0 0.2 :ease tween/ease-in-cubic))))
(can-skip? [this screen entities]
false))
(skip-type [this screen entities]
:none))
(actions/run-action entities
(begin [this screen entities]
entities)
@@ -154,8 +154,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false))
(skip-type [this screen entities]
:none))
(actions/run-action entities
(begin [this screen entities]
@@ -169,8 +169,8 @@
(terminate [this screen entities]
(update-in entities [:room :entities :ego] dissoc :stand-override))
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn win []
(actions/get-script entities

View File

@@ -52,8 +52,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn fade-in-tools [entities]
(actions/run-action entities
(begin [this screen entities]
@@ -69,8 +69,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn face-fairy [entities]
@@ -255,8 +255,8 @@
(terminate [this screen entities]
(actions/stop screen entities :ego))
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn return-from-island [screen entities]
(when (and (not (get-in entities [:actions :script-running?]))

View File

@@ -69,8 +69,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn nice-trophy-dialogue [entities]

View File

@@ -72,8 +72,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false)))
(skip-type [this screen entities]
:none)))
(defn swing-at-blergh [entities]
(let [jump-path (bezier (map #(apply vector-2* %) [[35 45] [110 145] [195 180]]))
@@ -127,8 +127,8 @@
(terminate [this screen entities]
(assoc-in entities [:room :entities :ego :move-pct] 0.0))
(can-skip? [this screen entities]
false))
(skip-type [this screen entities]
:none))
(actions/run-action entities
(begin [this screen entities]
@@ -153,9 +153,9 @@
(-> entities
(assoc-in [:room :entities :ego :move-pct] 0.0)
(update-in [:room :entities :ego] #(actions/start-animation screen % :pant))))
(can-skip? [this screen entities]
(skip-type [this screen entities]
false))
:none))
(actions/run-action entities
(begin [this screen entities]
(assoc-in entities [:tweens :flash] (tween/tween :flash screen [:white-fade :opacity] 1.0 0.0 3.0 :ease tween/ease-in-quadratic)))
@@ -168,8 +168,8 @@
(terminate [this screen entities]
entities)
(can-skip? [this screen entities]
false))))
(skip-type [this screen entities]
:none))))

View File

@@ -204,7 +204,7 @@ void main()
(def default-interaction
{:get-script (fn [cursor [x y]] (if (= :main cursor)
(actions/get-script entities
(actions/walk-to entities :ego [x y] :can-skip? true))
(actions/walk-to entities :ego [x y] :skip-type :skip))
(actions/get-script entities
(actions/talk entities :ego "I don't know what to do with that."))))})
@@ -238,7 +238,7 @@ void main()
current-action (get-in entities [:actions :current])
;; TODO - hacky way of resetting queue
entities (if (and current-action (actions/can-skip? current-action screen entities))
entities (if (and current-action (= :skip (actions/skip-type current-action screen entities)))
(let [terminated-entities (actions/terminate current-action screen entities)]
(do (put! (actions/get-channel current-action) terminated-entities)
(-> terminated-entities