godot-extended-libraries / godot-next

Godot Node Extensions - Basic Node Extensions for Godot Engine
MIT License
957 stars 61 forks source link

Add Vector2/3 extensions with many constants #89

Closed aaronfranke closed 3 years ago

aaronfranke commented 3 years ago

This was made in response to https://github.com/godotengine/godot-proposals/issues/566. I included every possibly useful constant I could think of.

They can be used like this:

    var a = Vec2.DOWN_LEFT
    var b = Vec2.DIR_16[7]
    var c = Vec3.DOWN_BACK_RIGHT_NORM
Xrayez commented 3 years ago

I'd rename to Vec2 and Vec3, since one of the ideas behind having those constants is convenience and ease of use, I believe. Although anyone who'd like to use a shorter name could just rename the class themselves easily. 😛

willnationsdev commented 3 years ago

I'd recommend extending Reference rather than Object. It shouldn't matter, but if someone wasn't paying attention and decided to create an instance of it, we don't want them to suddenly end up with a memory leak just because of it. Other than that, it looks great!

aaronfranke commented 3 years ago

@willnationsdev Done. It would be nice if there was some way to mark a class as uninstanceable.

Also, I have no idea why I didn't think of this until now... but I also amended this PR with the same constants for C#.

willnationsdev commented 3 years ago

Thanks!