rooms are beginning to be affected by state.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
[clojure.pprint]
|
||||
[clojure.string :as s]
|
||||
[clojure.zip :as zip]
|
||||
[clojure.set :as set]
|
||||
[advent.pathfind]
|
||||
[advent.actions :as actions]
|
||||
[advent.screens.dialogue :as dialogue]
|
||||
@@ -26,6 +27,9 @@
|
||||
(defn has-item? [entities item]
|
||||
((set (get-in entities [:state :inventory])) item))
|
||||
|
||||
(defn has-one-of? [entities items]
|
||||
(seq (set/intersection (set (get-in entities [:state :inventory])) (set items))))
|
||||
|
||||
(defmacro get-script [entities & forms]
|
||||
`(fn [starting-entities#]
|
||||
(let [~entities (atom starting-entities#)]
|
||||
@@ -407,7 +411,11 @@
|
||||
entities (-> entities
|
||||
(assoc-in [:room] (get-in entities [:rooms new-background]))
|
||||
(assoc-in [:room :entities :ego] ego))
|
||||
new-music (get-in entities [:room :music])]
|
||||
new-music (get-in entities [:room :music])
|
||||
apply-state (get-in entities [:room :apply-state])
|
||||
entities (if apply-state
|
||||
(apply-state entities)
|
||||
entities)]
|
||||
(when (not= new-music old-music)
|
||||
(doseq [[k v] (:musics entities)
|
||||
:when (and v (not= new-music k))]
|
||||
|
||||
@@ -68,4 +68,12 @@
|
||||
(actions/update-entity entities :peeling #(assoc % :opacity 0))
|
||||
(actions/update-state entities (fn [state] (assoc state :opened-crack? true)))))))}
|
||||
:collision "behindhouse/collision.png"
|
||||
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)))
|
||||
:scale-fn (utils/scaler-fn-with-baseline 110 0.10 1.00)
|
||||
:apply-state (fn [entities]
|
||||
(as-> entities entities
|
||||
(if (get-in entities [:state :opened-crack?])
|
||||
(assoc-in entities [:room :entities :peeling :opacity] 0)
|
||||
entities)
|
||||
(if (actions/has-one-of? entities [items/stick items/cat-toy])
|
||||
(update-in entities [:room :entities] #(dissoc % :stick))
|
||||
entities)))))
|
||||
|
||||
@@ -226,7 +226,7 @@
|
||||
:inside-fangald (make-music "inside-fangald.ogg")}
|
||||
:state {:object nil
|
||||
:active? true
|
||||
:inventory [items/grass ]
|
||||
:inventory [items/grass]
|
||||
:clues #{}
|
||||
:mints-eaten 0}
|
||||
:actions {:object nil
|
||||
|
||||
Reference in New Issue
Block a user