Closed Nemesisprime closed 4 months ago
Suggestion: Could the argument label be omitted in the custom case?
@BindNode("MovementComponent") var customLabel: Node?
Normally I favor explicitness, but I think this reads nicely.
Oooh I agree, that looks really nice. Applied the change to the init and docs!
Was speaking in Slack and discovered @SceneTree
(https://github.com/migueldeicaza/SwiftGodot/pull/297) which more-or-less replaces bindNode with the optional safety behavior (and is tested!). Magic mapping TBD.
Just a few improvements to make
@BindNode
a little bit better to work with.Improved Lookup
Given a Scene Node named "MovementComponent":
All become valid ways to look up via BindNode.
Safe Lookup
Previously,
@BindNode
didn't include the ability to look-up via optional, but this now forces them to be defined as optionals. This prevents the chance that a misnamed or missing Node is going to cause a crash instead puts it on the programmer to handle the missing node.This has a backwards incompatible change to more-or-less force safety on BindNode which is primarily the reason why I marked it a proposal in the title here. Feel feel to object but thought I'd take the chance given the early-ish state of the project and how annoying that was to stumble on 🙂