Skip to content

Commit 9617de5

Browse files
authored
Merge pull request #102 from cortex-command-community/add-ejectionoffset-bindings
Add missing HDFirearm EjectionOffset and EjectionPos bindings
2 parents a5517b0 + 1260622 commit 9617de5

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1212

1313
- `Lerp` can now be used on Vectors and Matrices/Rotations, not just numbers.
1414

15+
- Added `HDFirearm` lua bindings `EjectionOffset` (R/W) and `EjectionPos` (R). Work similarly to their Muzzle variants.
16+
1517
</details>
1618

1719
<details><summary><b>Changed</b></summary>

Source/Entities/HDFirearm.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,10 @@ Vector HDFirearm::GetMuzzlePos() const {
531531
return m_Pos + RotateOffset(m_MuzzleOff);
532532
}
533533

534+
Vector HDFirearm::GetEjectionPos() const {
535+
return m_Pos + RotateOffset(m_EjectOff);
536+
}
537+
534538
void HDFirearm::RestDetection() {
535539
HeldDevice::RestDetection();
536540

Source/Entities/HDFirearm.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,23 @@ namespace RTE {
273273

274274
/// Sets the unrotated relative offset from the position to the muzzle or
275275
/// other equivalent point of this.
276-
/// @param newOffset Bew ofsset value.
276+
/// @param newOffset New offset value.
277277
void SetMuzzleOffset(Vector newOffset) override { m_MuzzleOff = newOffset; }
278278

279+
/// Gets the absolute position of the Shell ejection point.
280+
/// @return A vector describing the absolute world coordinates for the Shell
281+
/// ejection point of this
282+
Vector GetEjectionPos() const;
283+
284+
/// Gets the unrotated relative offset from the position to the Shell ejection point.
285+
/// @return A unrotated vector describing the relative for the Shell ejection point of
286+
/// this from this' position.
287+
Vector GetEjectionOffset() const { return m_EjectOff; }
288+
289+
/// Sets the unrotated relative offset from the position to the Shell ejection point.
290+
/// @param newOffset New offset value.
291+
void SetEjectionOffset(Vector newOffset) { m_EjectOff = newOffset; }
292+
279293
/// Gets this HDFirearm's pre fire sound. Ownership is NOT transferred!
280294
/// @return The SoundContainer for this HDFirearm's pre fire sound.
281295
SoundContainer* GetPreFireSound() const { return m_PreFireSound; }

Source/Lua/LuaBindingsEntities.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, HDFirearm) {
607607
return ConcreteTypeLuaClassDefinition(HDFirearm, HeldDevice)
608608

609609
.property("ReloadEndOffset", &HDFirearm::GetReloadEndOffset, &HDFirearm::SetReloadEndOffset)
610+
.property("EjectionPos", &HDFirearm::GetEjectionPos)
611+
.property("EjectionOffset", &HDFirearm::GetEjectionOffset, &HDFirearm::SetEjectionOffset)
610612
.property("RateOfFire", &HDFirearm::GetRateOfFire, &HDFirearm::SetRateOfFire)
611613
.property("MSPerRound", &HDFirearm::GetMSPerRound)
612614
.property("FullAuto", &HDFirearm::IsFullAuto, &HDFirearm::SetFullAuto)

0 commit comments

Comments
 (0)