# HG changeset patch # User Steve Losh # Date 1342647466 14400 # Node ID ae4e6a9fa90659af758f7ea88f58760efade55df # Parent 16038f1308d87da605078b04ec46df2bec1405c7 Fix Silverfish walking out of the world. diff -r 16038f1308d8 -r ae4e6a9fa906 src/caves/entities/silverfish.clj --- a/src/caves/entities/silverfish.clj Wed Jul 18 17:32:49 2012 -0400 +++ b/src/caves/entities/silverfish.clj Wed Jul 18 17:37:46 2012 -0400 @@ -2,7 +2,7 @@ (: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]])) @@ -20,12 +20,13 @@ (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)