Open dt-rush opened 1 year ago
This will also apply to item/itemarchetype creation.
If your game takes only a little while to build, it's fine to panic, but really, for a complicated game that takes a while to build, panic at runtime due to a typo is maddening. So a verification tool becomes really important.
Why do we have this problem at all? Can't we just use runtime type checking on regular func params instead of spec map[string]any
objects? Yes, we could, but the readability gain of having the params named and optional is worth it.
if you have
"componnets"
, for example, it'll currently fail silently and just allocate no components.Really, we should have an expected list of keys,
[]string{"active", "components", "customComponents", "logics", "funcs", "mind", "tags", "uniqueTag"}
, and for each key in the spec, if it's not in this list, panic.Optional: write a verification tool that will scan all
.go
files in your game, find all instances ofSpawn
, and ensure no typos are being passed (this only works if the map literal is supplied directly. If it's built up over a series of lines and then passed as a var, it's much harder to detect).