Commits

Steve Losh  committed ae4e6a9

Fix Silverfish walking out of the world.

  • Participants
  • Parent commits 16038f1

Comments (0)

Files changed (1)

File src/caves/entities/silverfish.clj

   (:use [caves.entities.core :only [Entity get-id add-aspect]]
         [caves.entities.aspects.destructible :only [Destructible]]
         [caves.entities.aspects.mobile :only [Mobile move can-move?]]
-        [caves.world :only [get-entity-at]]
+        [caves.world :only [get-entity-at get-tile-kind]]
         [caves.coords :only [neighbors]]))
 
 
 (extend-type Silverfish Entity
   (tick [this world]
     (let [target (rand-nth (neighbors (:location this)))]
-      (if (get-entity-at world target)
-        world
-        (move this target world)))))
+      (if (can-move? this target world)
+        (move this target world)
+        world))))
 
 (add-aspect Silverfish Mobile
   (can-move? [this dest world]
-    (not (get-entity-at world dest))))
+    (and (#{:floor :wall} (get-tile-kind world dest))
+         (not (get-entity-at world dest)))))
 
 (add-aspect Silverfish Destructible)