# HG changeset patch # User Steve Losh # Date 1470512546 0 # Node ID f473d02894107afd2313add2bd007fce76176fc4 # Parent 8c46ebe7e71250ecb0a5231cd02c5d7268043f2d Name the little critters diff -r 8c46ebe7e712 -r f473d0289410 silt.lisp --- a/silt.lisp Sat Aug 06 19:24:57 2016 +0000 +++ b/silt.lisp Sat Aug 06 19:42:26 2016 +0000 @@ -286,6 +286,17 @@ heightmap) +;;;; Name Generation ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defparameter *name-syllable-lists* + '(#(snarf glor snorri) + #(able amble bur blur chand))) + +(defun random-name () + (format nil "~:(~{~A~}~)" + (mapcar (lambda (syllables) (random-elt syllables)) + *name-syllable-lists*))) + + ;;;; Roll-Your-Own-ECS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Entities are stored in an {id -> entity} hash table. ;;; @@ -617,7 +628,8 @@ ;;; Fauna -(define-entity creature (coords visible sentient flavor metabolizing)) +(define-entity creature (coords visible sentient flavor metabolizing) + (name :initform (random-name) :accessor creature-name)) (defparameter *directions* @@ -671,6 +683,9 @@ "It likes food."))) +(defmethod starve :after ((c creature)) + (log-message "~A has starved!" (creature-name c))) + ;;;; Profiling ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (sb-sprof::profile-call-counts "SILT")