-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package AttachLink | ||
|
||
import public HashSet | ||
import public initlater aUnit | ||
|
||
public class AttachLink | ||
|
||
|
||
real cooldown | ||
real cooldownReset | ||
trigger turretTrigger | ||
boolean dynamicFacing | ||
boolean updateFacing | ||
boolean isHidden | ||
real distance | ||
real angle | ||
real zOffset | ||
real offsetFix | ||
real angleRate | ||
real facing | ||
real idleAngle | ||
boolean staticAngle | ||
aUnit host | ||
aUnit guest | ||
effect fx | ||
|
||
|
||
|
||
|
||
|
||
|
||
function g_Destroy() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this? Why not |
||
this.staticAngle = false | ||
this.dynamicFacing = false | ||
this.updateFacing = false | ||
this.isHidden = false | ||
this.angleRate = 0 | ||
this.idleAngle = 0 | ||
|
||
construct(unit guest, effect fx, unit host, real angle, real distance, real zOffset, bool staticAngle) | ||
this.guest = new aUnit() | ||
this.host = new aUnit() | ||
this.guest.u = guest | ||
this.fx = fx | ||
this.host.u = host | ||
this.angle = angle | ||
this.distance = distance | ||
this.zOffset = zOffset | ||
this.staticAngle = staticAngle | ||
print("New linked formed with..") | ||
print("distance: " + distance.toString()) | ||
print("angle: " + angle.toString()) | ||
print("zOffset: " + zOffset.toString()) | ||
print("staticAngle: " + staticAngle.toString()) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package aUnit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use CapitalCamelCase for package names. |
||
|
||
import public HashSet | ||
import public initlater AttachLink | ||
import public Maths | ||
import public Angle | ||
|
||
/* | ||
|
||
A Unit is the unit that is in the ConnectionStorage container that is periodically updated | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Please use CapitalCamelCase for class names. |
||
unit u | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Please use lowerCamelCase for functions/methods. |
||
ConnectionStorage = new HashSet<AttachLink>() | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
while iterator.hasNext() | ||
AttachLink currentLink = iterator.next() | ||
unit guest = currentLink.guest.u | ||
unit host = currentLink.host.u | ||
real x = host.getX() | ||
real y = host.getY() | ||
real z = BlzGetLocalUnitZ(host) | ||
real f = GetUnitFacing(host) | ||
real xNew | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Use the |
||
yNew = y + Sin(currentLink.angle * DEGTORAD) * currentLink.distance | ||
zNew = z | ||
else | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
SetUnitY(guest, yNew) | ||
SetUnitFlyHeight(guest, zNew, 0) | ||
|
||
/*function update_Guests() | ||
//update guests | ||
HLIterator<AttachLink> iterator = guestConnections.iterator() | ||
while iterator.hasNext() | ||
AttachLink currentLink = iterator.next() | ||
aUnit guest = currentLink.guest | ||
aUnit host = currentLink.host | ||
if(currentLink.staticAngle) | ||
guest.u.setX(host.u.getX() + currentLink.distance * Cos(currentLink.angle * DEGTORAD)) | ||
guest.u.setY(host.u.getY() + currentLink.distance * Sin(currentLink.angle * DEGTORAD)) | ||
else | ||
real angle = currentLink.angle + host.u.getFacingAngle().radians() | ||
guest.u.setX(host.u.getX() + currentLink.distance * Cos(currentLink.angle * DEGTORAD + host.u.getFacingAngle().radians())) | ||
guest.u.setY(host.u.getY() + currentLink.distance * Sin(currentLink.angle * DEGTORAD + host.u.getFacingAngle().radians())) */ | ||
|
||
static function AttachObject(unit g, effect fx, unit h, real angle, real distance, real zOffset, real offsetFix, boolean staticAngle) returns AttachLink | ||
if h == null or (g == null and fx == null) | ||
return null | ||
AttachLink rVal = new AttachLink(g,fx,h,angle,distance,zOffset,staticAngle) | ||
ConnectionStorage.add(rVal) | ||
return rVal | ||
|
||
|
||
static function AttachUnit(unit guest, effect fx, unit u, real angle, real distance, real zOffset, real offsetFix, boolean staticAngle) returns AttachLink | ||
return AttachObject(guest, fx, u, angle, distance, zOffset, offsetFix, staticAngle) |
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.