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

Commit be7a504

Browse files
authored
Merge pull request #213 from cortex-command-community/lua-pemitter
Lua PEmitter
2 parents 97a8333 + ea8dcd8 commit be7a504

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

CHANGELOG.md

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

138138
- GUI sliders (like for music volume) can now be adjusted with the mouse scroll wheel.
139139

140+
- Exposed PEmitter to lua. Bindings are identical to AEmitter's bindings, except that damage-related bindings don't exist for PEmitter.
141+
140142
### Changed
141143

142144
- Codebase now uses the C++17 standard.

Entities/PEmitter.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace RTE
2525
//////////////////////////////////////////////////////////////////////////////////////////
2626
// Class: PEmitter
2727
//////////////////////////////////////////////////////////////////////////////////////////
28-
// Description:
28+
// Description: A particle MO that creates and emits particle MOs.
2929
// Parent(s): MOSParticle.
3030
// Class history: 02/29/2004 PEmitter created.
3131

@@ -39,6 +39,7 @@ class PEmitter :
3939

4040
public:
4141

42+
friend class LuaMan;
4243

4344
// Concrete allocation and cloning definitions
4445
EntityAllocation(PEmitter)
@@ -328,6 +329,13 @@ class PEmitter :
328329
void SetFlashScale(float flashScale = 1.0f) { m_FlashScale = flashScale; }
329330

330331

332+
/// <summary>
333+
/// Gets the display scale factor of the flash effect. This is purely visual.
334+
/// </summary>
335+
/// <returns>The scale factor of the flash draw.</returns>
336+
float GetFlashScale() const { return m_FlashScale; }
337+
338+
331339
//////////////////////////////////////////////////////////////////////////////////////////
332340
// Method: SetEmitAngle
333341
//////////////////////////////////////////////////////////////////////////////////////////
@@ -464,6 +472,18 @@ class PEmitter :
464472

465473
void Draw(BITMAP *pTargetBitmap, const Vector &targetPos = Vector(), DrawMode mode = g_DrawColor, bool onlyPhysical = false) const override;
466474

475+
/// <summary>
476+
/// Gets the number of emissions left before emitter is disabled.
477+
/// </summary>
478+
/// <returns>The number of emissions left before emitter is disabled.</returns>
479+
long GetEmitCountLimit() const { return m_EmitCountLimit; }
480+
481+
/// <summary>
482+
/// Sets the number of emissions left before emitter is disabled.
483+
/// </summary>
484+
/// <param name="newValue">New number of emissions left.</param>
485+
void SetEmitCountLimit(long newValue) { m_EmitCountLimit = newValue; }
486+
467487
//////////////////////////////////////////////////////////////////////////////////////////
468488
// Protected member variable and method declarations
469489

Managers/LuaMan.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "TDExplosive.h"
3232
#include "ThrownDevice.h"
3333
#include "Turret.h"
34+
#include "PEmitter.h"
3435

3536
#include "DataModule.h"
3637
#include "GAScripted.h"
@@ -206,6 +207,7 @@ LUAENTITYCREATE(HDFirearm)
206207
LUAENTITYCREATE(ThrownDevice)
207208
LUAENTITYCREATE(TDExplosive)
208209
LUAENTITYCREATE(TerrainObject)
210+
LUAENTITYCREATE(PEmitter)
209211

210212

211213
//////////////////////////////////////////////////////////////////////////////////////////
@@ -250,6 +252,7 @@ LUAENTITYCLONE(HDFirearm)
250252
LUAENTITYCLONE(ThrownDevice)
251253
LUAENTITYCLONE(TDExplosive)
252254
LUAENTITYCLONE(TerrainObject)
255+
LUAENTITYCLONE(PEmitter)
253256

254257
//////////////////////////////////////////////////////////////////////////////////////////
255258
// Explicit deletion of any Entity instance that Lua owns.. it will probably be handled
@@ -316,6 +319,7 @@ LUAENTITYCAST(HDFirearm)
316319
LUAENTITYCAST(ThrownDevice)
317320
LUAENTITYCAST(TDExplosive)
318321
LUAENTITYCAST(TerrainObject)
322+
LUAENTITYCAST(PEmitter)
319323

320324

321325
//////////////////////////////////////////////////////////////////////////////////////////
@@ -837,6 +841,24 @@ int LuaMan::Create() {
837841
.def("CanTriggerBurst", &AEmitter::CanTriggerBurst)
838842
.def_readwrite("Emissions", &AEmitter::m_EmissionList, return_stl_iterator),
839843

844+
CONCRETELUABINDING(PEmitter, MOSParticle)
845+
.def("IsEmitting", &PEmitter::IsEmitting)
846+
.def("EnableEmission", &PEmitter::EnableEmission)
847+
.property("BurstScale", &PEmitter::GetBurstScale, &PEmitter::SetBurstScale)
848+
.property("EmitAngle", &PEmitter::GetEmitAngle, &PEmitter::SetEmitAngle)
849+
.property("GetThrottle", &PEmitter::GetThrottle, &PEmitter::SetThrottle)
850+
.property("Throttle", &PEmitter::GetThrottle, &PEmitter::SetThrottle)
851+
.property("BurstSpacing", &PEmitter::GetBurstSpacing, &PEmitter::SetBurstSpacing)
852+
.property("EmitCountLimit", &PEmitter::GetEmitCountLimit, &PEmitter::SetEmitCountLimit)
853+
.property("FlashScale", &PEmitter::GetFlashScale, &PEmitter::SetFlashScale)
854+
.def("GetEmitVector", &PEmitter::GetEmitVector)
855+
.def("GetRecoilVector", &PEmitter::GetRecoilVector)
856+
.def("EstimateImpulse", &PEmitter::EstimateImpulse)
857+
.def("TriggerBurst", &PEmitter::TriggerBurst)
858+
.def("IsSetToBurst", &PEmitter::IsSetToBurst)
859+
.def("CanTriggerBurst", &PEmitter::CanTriggerBurst)
860+
.def_readwrite("Emissions", &PEmitter::m_EmissionList, return_stl_iterator),
861+
840862
CONCRETELUABINDING(Actor, MOSRotating)
841863
.enum_("Status")[
842864
value("STABLE", Actor::Status::STABLE),

0 commit comments

Comments
 (0)