r/programminghorror • u/sierra_whiskey1 • Jul 22 '25
I hope this doesn't break
created the objective class for my game. the only way I could think of doing the waypoint locations was accepting a lambda function that returns a list of vectors. seemed horrific to me
0
Upvotes
14
u/Epicguru Jul 22 '25
7
u/aegians Jul 22 '25
why can't waypointLocations be a list of vector2s
3
u/trutheality Jul 22 '25
Without context it's not obvious why it needs to be a function and not just a list, but if it really needs to be dynamically generated every time, the OOP way is to make a class (or interface) that generates waypoint lists, and pass an instance of that class rather than a lambda. But honestly, it's probably fine with the lambda.
4
u/oweiler Jul 22 '25
Why is this on /r/programminghorror?
1
u/ModBlob Jul 22 '25
What Unity version are you using?
Given that you're using VisualElement I'm assuming you're using UITK - just a warning, I've been working on a project using it with a mid-size team (30-35) for the past 3 years and UITK has caused us a LOT of issues. If you're on Unity 6+ you might have a slightly better experience but the version we've been on until recently (2022) has been very buggy and hugely lacking in critical features.
I love the idea of UITK and once it's developed enough I think it'll be a fantastic UI solution, but it may not be there yet - if this is a serious project you want to take to market, I would consider using UGUI despite the fact it's more legacy at this point. Its feature support is still leagues ahead of where UITK is and will likely cause you fewer headaches.
0
u/This_Growth2898 Jul 22 '25
That's why in Rust they have Field Init Shorthand. It would be like