progress on multiple scripts.

This commit is contained in:
Bryce Covert
2015-11-19 18:29:54 -08:00
parent 624688524b
commit 5b12127ae3
3 changed files with 31 additions and 8 deletions

View File

@@ -100,6 +100,13 @@
(change-script-state ~entities false) (change-script-state ~entities false)
(utils/save @~entities :autosave "Autosave")))))))) (utils/save @~entities :autosave "Autosave"))))))))
(defn force-end [entities current-action key]
(do (put! (get-channel current-action) :end)
(-> entities
(assoc-in [key :script-running?] false)
(assoc-in [key :current] nil)
(assoc-in [key :started?] false))))
(defmacro get-unsaved-script [entities & forms] (defmacro get-unsaved-script [entities & forms]
`(fn [starting-entities#] `(fn [starting-entities#]
(put! (get-in starting-entities# [:fg-actions :script-chan]) (put! (get-in starting-entities# [:fg-actions :script-chan])
@@ -197,6 +204,19 @@
(skip-type [this screen entities] (skip-type [this screen entities]
:skip))) :skip)))
(defn do-force-end [entities key]
(run-action entities
(begin [this screen entities]
(if (get-in entities [key :script-running?])
(force-end entities (get-in entities [key :current]) key)
entities))
(continue [this screen entities] entities)
(done? [this screen entities] true)
(terminate [this screen entities]
entities)
(skip-type [this screen entities]
:none)))
(defn walk-straight-to [entities target-id [final-x final-y] & {:keys [update-baseline? face speed anim override-dir stop?]}] (defn walk-straight-to [entities target-id [final-x final-y] & {:keys [update-baseline? face speed anim override-dir stop?]}]
@@ -662,12 +682,16 @@
(assoc-in [:state :next-time] nil)) (assoc-in [:state :next-time] nil))
entities) entities)
:ego :ego
:face face)] :face face)
entities (if (get-in entities [:bg-actions :script-running?])
(force-end entities (get-in entities [:bg-actions :current]) :bg-actions)
entities)]
(if-let [stop-fn (get-in entities [:room :stop-fn])] (if-let [stop-fn (get-in entities [:room :stop-fn])]
(stop-fn screen entities) (stop-fn screen entities)
entities))) entities)))
(skip-type [this screen entities] (skip-type [this screen entities]
:none)) :none))
(screen! dialogue/talking-screen :stop-talk)
(run-action entities (run-action entities
(begin [this screen entities] (begin [this screen entities]
(utils/stop-all-sounds! entities) (utils/stop-all-sounds! entities)

View File

@@ -15,7 +15,6 @@
[play-clj.g2d :refer :all])) [play-clj.g2d :refer :all]))
(defn brian [screen entities] (defn brian [screen entities]
(when (and (not (get-in entities [:fg-actions :script-running?])) (when (and (not (get-in entities [:fg-actions :script-running?]))
(not (get-in entities [:bg-actions :script-running?])) (not (get-in entities [:bg-actions :script-running?]))
(get-in entities [:state :active?]) (get-in entities [:state :active?])
@@ -116,7 +115,8 @@
{:run #(actions/respond entities % :game-player "Fine by me.")}]}) {:run #(actions/respond entities % :game-player "Fine by me.")}]})
(defn walk-to-player [entities] (defn walk-to-player [entities]
(actions/walk-to entities :ego [209 74] :face :right)) (actions/walk-to entities :ego [209 74] :face :right)
(actions/do-force-end entities :bg-actions))
(defn brian-pause-from-work [entities] (defn brian-pause-from-work [entities]
(actions/play-animation entities :game-player :pause-from-work :stop? false) (actions/play-animation entities :game-player :pause-from-work :stop? false)

View File

@@ -189,6 +189,8 @@ void main ()
(assoc-in [:cursor :override] nil))) (assoc-in [:cursor :override] nil)))
(assoc-in entities [:cursor :current] :main)))) (assoc-in entities [:cursor :current] :main))))
(defn skip-action [screen entities] (defn skip-action [screen entities]
(let [current-action (get-in entities [:fg-actions :current])] (let [current-action (get-in entities [:fg-actions :current])]
(cond (= :skip (actions/skip-type current-action screen entities)) (cond (= :skip (actions/skip-type current-action screen entities))
@@ -201,11 +203,8 @@ void main ()
(= :end (actions/skip-type current-action screen entities)) (= :end (actions/skip-type current-action screen entities))
(let [terminated-entities (actions/terminate current-action screen entities)] (let [terminated-entities (actions/terminate current-action screen entities)]
(println "trying to end") (println "trying to end")
(do (put! (actions/get-channel current-action) :end) (actions/force-end terminated-entities current-action :fg-actions)
(-> terminated-entities )
(assoc-in [:fg-actions :script-running?] false)
(assoc-in [:fg-actions :current] nil)
(assoc-in [:fg-actions :started?] false))))
:else :else
entities))) entities)))