From 6c0acd1ae62f590c3969aefb595bbb4ff03c70a6 Mon Sep 17 00:00:00 2001 From: Remington Covert Date: Wed, 1 Oct 2014 20:42:26 -0700 Subject: [PATCH] item interactions. --- desktop/src-common/advent/screens/scene.clj | 25 +++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/desktop/src-common/advent/screens/scene.clj b/desktop/src-common/advent/screens/scene.clj index c70082c2..2302adce 100644 --- a/desktop/src-common/advent/screens/scene.clj +++ b/desktop/src-common/advent/screens/scene.clj @@ -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