Conversation
| export const radians = Angle.fromRadians; | ||
| export const randomAngle = Angle.random; | ||
|
|
||
| export class Vec2 { |
There was a problem hiding this comment.
Why are all classes in one file? Should be split.
There was a problem hiding this comment.
I wrote these classes originally in separate files, but for some reason when I added the angleTo method on the vec2, games were crashing before getting to the load screen (I think this means invalid Lua in the map's Lua). I spent some time trying to figure it out, but nothing solved the issue except moving them into the same file.
If you have some ideas on why this was happening, I'm all ears to try again.
I want to try and hold off on breaking changes at least until I publish the next version of w3ts, but you can start the PR in the meantime. Although I think using coordinates and Point should still be an option, so it shouldn't be a breaking change.
Check your log file in |
Add a math folder with types file to contain useful types for basic spatial mathematics.
The Angle type can be used to abstract the problem of degrees versus radians in the Warcraft III API, since it inconsistently uses angular units. Changing the type of
Unit.setFacing(value: number)toUnit.setFacing(value: Angle)would allow the library to know that theSetUnitFacing()takes an angle in degrees.The Vectors are useful as they can store a location, but not require explicit cleanup. Instead the Lua memory management will cleanup vectors, lowering the usage burden. They also have useful functionality and can have more WC3 specific functionality added.
I'd like to follow this PR up with another that replaces all usages of the
Pointclass, plain x&y number arguments, and raw number angles with these strongly typed alternatives, but this would be a big breaking change. What are your thoughts @cipherxof ?Having the well typed angles and vectors is something I've missed from Wurst, so I wanted to add them to this library 😄