Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 5d294fd

Browse files
committed
Added emitter property ThrottleFactor
1 parent fd4d475 commit 5d294fd

File tree

6 files changed

+23
-30
lines changed

6 files changed

+23
-30
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
260260

261261
- New `Attachable` Lua (R) property `JointPos`, which gets the position of the object's joint in scene coordinates.
262262

263-
- New `AHuman` Lua (R) Property `IsClimbing`, which indicates whether the actor is currently climbing using either of the arms.
263+
- New `AHuman` Lua (R) property `IsClimbing`, which indicates whether the actor is currently climbing using either of the arms.
264264

265265
- New `AHuman` Lua functions `UnequipFGArm()` and `UnequipArms()` which unequip the currently held item(s) and put them into the actor's inventory.
266266

@@ -273,6 +273,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
273273

274274
- New `PrimitiveMan` Lua functions `DrawIconPrimitive(player, pos, entity)` and `DrawIconPrimitive(pos, entity)` which can be used to draw the GUI representation of the passed in entity.
275275

276+
- New `AEmitter` and `PEmitter` Lua (R) property `ThrottleFactor`, which gets the throttle strength as a multiplier value that factors in either the positive or negative throttle multiplier according to throttle.
277+
276278
</details>
277279

278280
<details><summary><b>Changed</b></summary>

Entities/AEmitter.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,7 @@ float AEmitter::EstimateImpulse(bool burst)
345345
}
346346

347347
// Scale the emission rate up or down according to the appropriate throttle multiplier.
348-
float throttleFactor = 1.0F;
349-
float absThrottle = std::abs(m_Throttle);
350-
if (m_Throttle < 0) {
351-
throttleFactor = throttleFactor * (1 - absThrottle) + (m_NegativeThrottleMultiplier * absThrottle);
352-
} else if (m_Throttle > 0) {
353-
throttleFactor = throttleFactor * (1 - absThrottle) + (m_PositiveThrottleMultiplier * absThrottle);
354-
}
348+
float throttleFactor = GetThrottleFactor();
355349
// Apply the throttle factor to the emission rate per update
356350
if (burst) { return m_AvgBurstImpulse * throttleFactor; }
357351

@@ -433,14 +427,7 @@ void AEmitter::Update()
433427
// TODO: Potentially get this once outside instead, like in attach/detach")
434428
MovableObject *pRootParent = GetRootParent();
435429

436-
// Scale the emission rate up or down according to the appropriate throttle multiplier.
437-
float throttleFactor = 1.0F;
438-
float absThrottle = std::abs(m_Throttle);
439-
if (m_Throttle < 0) {
440-
throttleFactor = throttleFactor * (1 - absThrottle) + (m_NegativeThrottleMultiplier * absThrottle);
441-
} else if (m_Throttle > 0) {
442-
throttleFactor = throttleFactor * (1 - absThrottle) + (m_PositiveThrottleMultiplier * absThrottle);
443-
}
430+
float throttleFactor = GetThrottleFactor();
444431
m_FlashScale = throttleFactor;
445432
// Check burst triggering against whether the spacing is fulfilled
446433
if (m_BurstTriggered && (m_BurstSpacing <= 0 || m_BurstTimer.IsPastSimMS(m_BurstSpacing)))

Entities/AEmitter.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ ClassInfoGetters;
260260

261261
float GetThrottle() const { return m_Throttle; }
262262

263+
/// <summary>
264+
/// Gets the adjusted throttle multiplier that is factored into the emission rate of this AEmitter.
265+
/// </summary>
266+
/// <returns>The throttle strength as a multiplier.</returns>
267+
float GetThrottleFactor() const { return 1.0F - std::abs(m_Throttle) + (m_Throttle < 0 ? m_NegativeThrottleMultiplier : m_PositiveThrottleMultiplier) * std::abs(m_Throttle); }
268+
263269
/// <summary>
264270
/// Gets the negative throttle multiplier of this AEmitter.
265271
/// </summary>

Entities/PEmitter.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,7 @@ namespace RTE {
340340
}
341341

342342
// Scale the emission rate up or down according to the appropriate throttle multiplier.
343-
float throttleFactor = 1.0F;
344-
float absThrottle = std::abs(m_Throttle);
345-
if (m_Throttle < 0) {
346-
throttleFactor = throttleFactor * (1 - absThrottle) + (m_NegativeThrottleMultiplier * absThrottle);
347-
} else if (m_Throttle > 0) {
348-
throttleFactor = throttleFactor * (1 - absThrottle) + (m_PositiveThrottleMultiplier * absThrottle);
349-
}
343+
float throttleFactor = GetThrottleFactor();
350344
// Apply the throttle factor to the emission rate per update
351345
if (burst)
352346
return m_AvgBurstImpulse * throttleFactor;
@@ -399,13 +393,7 @@ namespace RTE {
399393
MovableObject *pRootParent = GetRootParent();
400394

401395
// Scale the emission rate up or down according to the appropriate throttle multiplier.
402-
float throttleFactor = 1.0F;
403-
float absThrottle = std::abs(m_Throttle);
404-
if (m_Throttle < 0) {
405-
throttleFactor = throttleFactor * (1 - absThrottle) + (m_NegativeThrottleMultiplier * absThrottle);
406-
} else if (m_Throttle > 0) {
407-
throttleFactor = throttleFactor * (1 - absThrottle) + (m_PositiveThrottleMultiplier * absThrottle);
408-
}
396+
float throttleFactor = GetThrottleFactor();
409397
m_FlashScale = throttleFactor;
410398
// Check burst triggering against whether the spacing is fulfilled
411399
if (m_BurstTriggered && (m_BurstSpacing <= 0 || m_BurstTimer.IsPastSimMS(m_BurstSpacing)))

Entities/PEmitter.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,14 @@ class PEmitter : public MOSParticle {
272272
// 0 means normal, -1.0 means least emission rate.
273273

274274
float GetThrottle() const { return m_Throttle; }
275+
276+
277+
/// <summary>
278+
/// Gets the adjusted throttle multiplier that is factored into the emission rate of this PEmitter.
279+
/// </summary>
280+
/// <returns>The throttle strength as a multiplier.</returns>
281+
float GetThrottleFactor() const { return 1.0F - std::abs(m_Throttle) + (m_Throttle < 0 ? m_NegativeThrottleMultiplier : m_PositiveThrottleMultiplier) * std::abs(m_Throttle); }
282+
275283
/*
276284
//////////////////////////////////////////////////////////////////////////////////////////
277285
// Method: SetEmitRate

Lua/LuaBindingsEntities.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ namespace RTE {
371371
.property("EmitAngle", &AEmitter::GetEmitAngle, &AEmitter::SetEmitAngle)
372372
.property("GetThrottle", &AEmitter::GetThrottle, &AEmitter::SetThrottle)
373373
.property("Throttle", &AEmitter::GetThrottle, &AEmitter::SetThrottle)
374+
.property("ThrottleFactor", &AEmitter::GetThrottleFactor)
374375
.property("NegativeThrottleMultiplier", &AEmitter::GetNegativeThrottleMultiplier, &AEmitter::SetNegativeThrottleMultiplier)
375376
.property("PositiveThrottleMultiplier", &AEmitter::GetPositiveThrottleMultiplier, &AEmitter::SetPositiveThrottleMultiplier)
376377
.property("BurstSpacing", &AEmitter::GetBurstSpacing, &AEmitter::SetBurstSpacing)
@@ -984,6 +985,7 @@ namespace RTE {
984985
.property("EmitAngle", &PEmitter::GetEmitAngle, &PEmitter::SetEmitAngle)
985986
.property("GetThrottle", &PEmitter::GetThrottle, &PEmitter::SetThrottle)
986987
.property("Throttle", &PEmitter::GetThrottle, &PEmitter::SetThrottle)
988+
.property("ThrottleFactor", &PEmitter::GetThrottleFactor)
987989
.property("BurstSpacing", &PEmitter::GetBurstSpacing, &PEmitter::SetBurstSpacing)
988990
.property("EmitCountLimit", &PEmitter::GetEmitCountLimit, &PEmitter::SetEmitCountLimit)
989991
.property("FlashScale", &PEmitter::GetFlashScale, &PEmitter::SetFlashScale)

0 commit comments

Comments
 (0)