item interactions.
This commit is contained in:
@@ -27,14 +27,17 @@
|
||||
(cursor-override [this]))
|
||||
|
||||
(defprotocol IInteractable
|
||||
(get-script [this location]))
|
||||
(get-script [this cursor location]))
|
||||
|
||||
(def default-interaction
|
||||
(reify
|
||||
IInteractable
|
||||
(get-script [_ [x y]]
|
||||
(actions/get-script entities
|
||||
(actions/walk-to entities :ego [x y] true)))))
|
||||
(get-script [_ cursor [x y]]
|
||||
(if (= :main cursor)
|
||||
(actions/get-script entities
|
||||
(actions/walk-to entities :ego [x y] true))
|
||||
(actions/get-script entities
|
||||
(actions/talk entities :ego "I don't know what to do with that."))))))
|
||||
|
||||
|
||||
(defn find-override [screen entities [x y]]
|
||||
@@ -68,8 +71,8 @@
|
||||
(if current-action
|
||||
entities
|
||||
((or (when interaction
|
||||
(get-script interaction [x y]))
|
||||
(get-script default-interaction [x y])) entities))
|
||||
(get-script interaction (get-in entities [:cursor :current]) [x y]))
|
||||
(get-script default-interaction (get-in entities [:cursor :current]) [x y])) entities))
|
||||
entities))))
|
||||
|
||||
(defn flip [anim]
|
||||
@@ -145,8 +148,10 @@
|
||||
(mouse-in? [_ location]
|
||||
(apply (apply zone/box (:box spec)) location))
|
||||
IInteractable
|
||||
(get-script [_ location]
|
||||
(:script spec))
|
||||
(get-script [_ cursor location]
|
||||
(if (= :main cursor)
|
||||
(:script spec)
|
||||
(get-in spec [:scripts cursor])))
|
||||
ICursorOverridable
|
||||
(cursor-override [this] (:cursor spec)))
|
||||
)]
|
||||
@@ -315,7 +320,9 @@
|
||||
(if ((get-in @entities [:state :inventory]) :wool)
|
||||
(actions/talk entities :ego "The sheep has given me enough wool.")
|
||||
(do (actions/give entities :wool)
|
||||
(actions/talk entities :ego "I guess his wool is shedding."))))}
|
||||
(actions/talk entities :ego "I guess her wool is shedding."))))
|
||||
:scripts {:wool (actions/get-script entities
|
||||
(actions/talk entities :ego "She doesn't need it back."))}}
|
||||
:right-dir {:box [300 131 320 224]
|
||||
:script (actions/get-script
|
||||
entities
|
||||
|
||||
Reference in New Issue
Block a user