Skip to content

Commit

Permalink
Update annotations of engine projectile methods (#6399)
Browse files Browse the repository at this point in the history
## Description of the proposed changes

Document the support for method chaining of the projectile engine
methods. I noticed this behavior as I was working on #6398.

## Testing done on the proposed changes

I called every function and checked the output of the log with logging
the instance. If the references match then the function supports method
chaining.

```
LOG(self) -- returns memory reference
LOG("ChangeDetonateAboveHeight", self:ChangeDetonateAboveHeight(0)) -- returns nil
LOG("SetLifetime", self:SetLifetime(10)) -- returns memory reference
```

## Checklist
- [x] Changes are annotated, including comments where useful
- [x] Changes are documented in the changelog for the next game version
  • Loading branch information
Garanas authored Aug 9, 2024
1 parent 7baad99 commit f39f8cc
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 15 deletions.
1 change: 1 addition & 0 deletions changelog/snippets/other.6399.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6399) Document method chaining of projectile engine functions
67 changes: 52 additions & 15 deletions engine/Sim/Projectile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,31 @@ function Projectile:GetBlueprint()
end

--- Change the detonate above height for the projectile, relative to the terrain
---
--- Note: does **not** support method chaining
---@param height number
function Projectile:ChangeDetonateAboveHeight(height)
end

--- Change the detonate below height for the projectile, relative to the terrain
---
--- Note: does **not** support method chaining
---@param height number
function Projectile:ChangeDetonateBelowHeight(height)
end

--- Change the amount of zig-zag in degrees per second
---
--- You can use `Projectile:GetMaxZigZag()` to retrieve the current zig zag distance.
--- Note: does **not** support method chaining
---@param max number
function Projectile:ChangeMaxZigZag(max)
end

--- Change the frequency of the zig-zag
---
--- You can use `Projectile:GetZigZagFrequency()` to retrieve the current zig zag frequency.
--- Note: does **not** support method chaining
---@param freq number
function Projectile:ChangeZigZagFrequency(freq)
end
Expand Down Expand Up @@ -86,110 +92,141 @@ function Projectile:GetVelocity()
end

--- Override the acceleration value in the blueprint.
---@generic T
---@param self T
---@param accel number
---@return T
function Projectile:SetAcceleration(accel)
end

--- Set the vertical (gravitational) acceleration of the projectile. Default is -4.9, which is expected by the engine's weapon targeting and firing
---@generic T
---@param self T
---@param accel number
---@return T
function Projectile:SetBallisticAcceleration(accel)
end

--- Whether or not this projecile collides with units and shields, should not be used for dummy projectiles as this is expensive
---@generic T
---@param self T
---@param collide boolean
---@return T
function Projectile:SetCollideEntity(collide)
end

--- Whether or not this projectile collides with the terrain and water surface
---@generic T
---@param self T
---@param collide boolean
---@return T
function Projectile:SetCollideSurface(collide)
end

---
---@generic T
---@param self T
---@param collide boolean
---@return Projectile
---@return T
function Projectile:SetCollision(collide)
end

---
--- Note: does **not** support method chaining
---@param flag boolean
function Projectile:SetDestroyOnWater(flag)
end

---
---@generic T
---@param self T
---@param seconds number
---@return T
function Projectile:SetLifetime(seconds)
end

---
---@generic T
---@param self T
---@param x number
---@param y number
---@param z number
---@return T
function Projectile:SetLocalAngularVelocity(x, y, z)
end

---
---@generic T
---@param self T
---@param speed number
---@return T
function Projectile:SetMaxSpeed(speed)
end

---
--- Note: does **not** support method chaining
---@param object Blip | Entity | Unit | Projectile
function Projectile:SetNewTarget(object)
end

---
--- Note: does **not** support method chaining
---@param location Vector
function Projectile:SetNewTargetGround(location)
end

--- Note: does **not** support method chaining
---@param x number
---@param y number
---@param z number
function Projectile:SetNewTargetGroundXYZ(x, y, z)
end

---
---@generic T
---@param self T
---@param svx number
---@param svy number
---@param svz number
---@return T
function Projectile:SetScaleVelocity(svx, svy, svz)
end

---
--- Note: does **not** support method chaining
---@param upright boolean
function Projectile:SetStayUpright(upright)
end

---
---@generic T
---@param self T
---@param degreesPerSecond number
---@return T
function Projectile:SetTurnRate(degreesPerSecond)
end

---
---@generic T
---@param self T
---@param velX number
---@param velY? number
---@param velZ? number
---@return Projectile
---@return T
function Projectile:SetVelocity(velX, velY, velZ)
end

---
--- Note: does **not** support method chaining
---@param align boolean
function Projectile:SetVelocityAlign(align)
end

--- Note: does **not** support method chaining
---@unknown
function Projectile:SetVelocityRandomUpVector()
end

---
---@generic T
---@param self T
---@param stay boolean
---@return T
function Projectile:StayUnderwater(stay)
end

---
---@generic T
---@param self T
---@param track boolean
---@return T
function Projectile:TrackTarget(track)
end

Expand Down

0 comments on commit f39f8cc

Please sign in to comment.