make NAT printouts optional with compile flags
This commit is contained in:
@@ -3,13 +3,16 @@
|
||||
|
||||
// External programs can load Lib.kiss with (loadFrom "nat-archive-tool" "src/nat/Lib.kiss")
|
||||
|
||||
(function log [msg]
|
||||
(#when (or test debug) (print msg)))
|
||||
|
||||
(defMacro hasComponent [e componentType]
|
||||
`(.exists .components ,e ,(symbolName componentType)))
|
||||
|
||||
// Changes to the object returned by (readComponent) will not be saved! Use (withWritableComponents) for making changes
|
||||
(defMacro readComponent [e componentType]
|
||||
`(let [componentData (dictGet (the Map<String,String> .components ,e) ,(symbolName componentType))]
|
||||
(print (+ "reading " componentData " as " ,(symbolName componentType) " for " .id ,e))
|
||||
(log (+ "reading " componentData " as " ,(symbolName componentType) " for " .id ,e))
|
||||
(the nat.components ,componentType
|
||||
// TODO add to the documentation a hint that macros should use fully qualified type paths so macro caller classes don't need to import everything
|
||||
(tink.Json.parse componentData))))
|
||||
@@ -17,12 +20,12 @@
|
||||
// TODO check not overwriting a component
|
||||
(defMacro addComponent [archive e componentType c]
|
||||
`(withWritableEntry ,archive ,e
|
||||
(print (+ "adding " (the nat.components ,componentType ,c) " as " ,(symbolName componentType) " for " .id ,e))
|
||||
(log (+ "adding " (the nat.components ,componentType ,c) " as " ,(symbolName componentType) " for " .id ,e))
|
||||
(dictSet .components ,e ,(symbolName componentType) (tink.Json.stringify (the nat.components ,componentType ,c)))))
|
||||
|
||||
(defMacro removeComponent [archive e componentType]
|
||||
`(withWritableEntry ,archive ,e
|
||||
(print (+ "removing " ,(symbolName componentType) " component from " .id ,e))
|
||||
(log (+ "removing " ,(symbolName componentType) " component from " .id ,e))
|
||||
(.remove .components ,e ,(symbolName componentType))))
|
||||
|
||||
// Retrieve multiple components from an Entity with mutable access.
|
||||
|
Reference in New Issue
Block a user