damn / core

Endless Vampire Roguelike
295 stars 11 forks source link

Could remove component dependencies #81

Open damn opened 1 week ago

damn commented 1 week ago

Component namespaces could define public vars/functions for component metadata/methods and tagged methods for txs/protocol methods.

That would remove the need for component dependency, maybe make understanding/testing easier, but I am not sure about disadvantages. Maybe understandability?

The component loader would check ns-publics and load them into multimethod (could use vars itself for repl development).

The question is if we want to do that as for example related components like op/inc or op/mult are nice in one ns file.

(ns components.entity.faction)

(def ^:private this :entity/faction)

(def data [:enum [:good :evil]])

(defn info-text [[_ faction] _ctx]
  (str "[SLATE]Faction: " (name faction) "[]"))

(defn ^:method enemy-faction [entity*]
  (case (this entity*)
    :evil :good
    :good :evil))

(def ^:method friendly-faction this)
(ns-publics *ns*)
(filter #(and (namespace %)
              (= (namespace %) "tx"))
        (keys (meta #'send-event!)))
damn commented 1 week ago

Effects/tx fns separate ns can be tested without tx handler . Separate logic from wiring . https://youtu.be/XcT4yYu_TTs?si=2AhnNGKrZgkOn8HQ