src/caves/entities/aspects/receiver.clj @ d8b58bf5f166
Radial messages, and styling.
author |
Steve Losh <steve@stevelosh.com> |
date |
Wed, 18 Jul 2012 14:00:55 -0400 |
parents |
88091919d482 |
children |
1a3a4f8d5d85 |
(ns caves.entities.aspects.receiver
(:use [caves.entities.core :only [defaspect]]
[caves.world :only [get-entities-around]]))
(defaspect Receiver
(receive-message [this message world]
(update-in world [:entities (:id this) :messages] conj message)))
(defn send-message [entity message args world]
(if (satisfies? Receiver entity)
(receive-message entity (apply format message args) world)
world))
(defn send-message-nearby [coord message world]
(let [entities (get-entities-around world coord 7)
sm #(send-message %2 message [] %1)]
(reduce sm world entities)))