-
Notifications
You must be signed in to change notification settings - Fork 1
Attach Added #14
base: master
Are you sure you want to change the base?
Attach Added #14
Conversation
Adds functionality for an attach command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a few common conventions used in Wurst (and in YARP2) that are missing. There's a few written down in Wurst's manual - https://wurstlang.org/manual.html#coding-conventions
Overall, I highly recommend you to skim over the manual in whole, so that you can get a better grasp on the language. It's very different from both JASS and vJASS and the paradigms are not at all the same.
Prefer to use existing Wurst functionality over writing everything from scratch like you would in vJASS, it's really much easier.
There's a lot of things I skimmed over, as well, but here are some general points:
- Prefer to use
var
/let
notation over explicit type annotations. - Prefer to use
vec2
andvec3
tuples for storing positional data vs storing each component individually. Not only is it more compact, but there's a whole lot of extension functions and utilities already built-in. - Try to avoid using JASS natives directly. Most natives already have a Wurst wrapper around them. If you're not sure, you can do a file search in the stdlib directory for the native name, and find which wrappers there are for it.
I'll do a more thorough review when the points above are implemented. Sorry for so many change requests, but it's very important to me that the code is both consistent in style and is idiomatic. Thanks for participating!
let b = arguments.getReal(2) | ||
let c = arguments.getReal(3) | ||
let d = arguments.getReal(4) | ||
let e = arguments.getBool(5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use better variable names.
|
||
|
||
|
||
function g_Destroy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this? Why not ondestroy
?
AttachLink is the link which holds the host and guest aUnits as well as their metadata | ||
|
||
*/ | ||
public class aUnit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use CapitalCamelCase for class names.
@@ -0,0 +1,72 @@ | |||
package aUnit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use CapitalCamelCase for package names.
static HashSet<AttachLink> ConnectionStorage | ||
HashSet<AttachLink> guestConnections | ||
//run in miscinit | ||
static function init_Connection_Storage(timer clock, real timeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use lowerCamelCase for functions/methods.
TimerStart(clock, timeout, true, function updateStoredConnections) | ||
|
||
static function updateStoredConnections() | ||
HLIterator<AttachLink> iterator = ConnectionStorage.iterator() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use let iterator = ...
vs explicit type annotations.
xNew = x + Cos(currentLink.angle * DEGTORAD + f * DEGTORAD) * currentLink.distance | ||
yNew = y + Sin(currentLink.angle * DEGTORAD + f * DEGTORAD) * currentLink.distance | ||
zNew = z | ||
SetUnitX(guest, xNew) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use unit.setXY(vec2)
vs natives.
real yNew | ||
real zNew | ||
if(currentLink.staticAngle) | ||
xNew = x + Cos(currentLink.angle * DEGTORAD) * currentLink.distance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the angle
tuple for representing angles vs manual degrees/radians conversions. More can be found in stdlib's Angle.wurst
Adds functionality for an attach command