Skip to content

Commit b19eed9

Browse files
committed
2 parents 56b1041 + 1b6831f commit b19eed9

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

CHANGELOG.md

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

1717
- New `MovableObject` Lua functions `GetScreenEffectPath()` and `SetScreenEffectPath(string pathToFile)`, which get and set the file path to the object's screen effect.
1818

19+
- Exposed `MovableObject` INI properties `EffectStartStrength` and `EffectStopStrength` to Lua (R/W). Default range in Lua is a float from 0-1 (0%-100%), but going outside of this range is possible.
20+
21+
- New `MovableObject` Lua function `SetEffectStrength(float strength)`, which sets both `EffectStartStrength` and `EffectStopStrength` to the given value in order to simplify setting glow strength to a specific value.
22+
1923
</details>
2024

2125
<details><summary><b>Changed</b></summary>

Source/Entities/MovableObject.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,30 @@ namespace RTE {
405405
/// @return The starting strength of the effect, 0-255.
406406
int GetEffectStartStrength() const { return m_EffectStartStrength; }
407407

408+
/// Gets the starting strength of this MovableObject's effect as a float.
409+
/// @return The starting strength of the effect, 0.0-1.0.
410+
float GetEffectStartStrengthFloat() const { return static_cast<float>(m_EffectStartStrength) / 255.0f; }
411+
412+
/// Sets the starting strength of this MovableObject's effect.
413+
/// @param strength The new starting strength of the effect, 0.0-1.0.
414+
void SetEffectStartStrengthFloat(float strength) { m_EffectStartStrength = std::floor(255.0F * strength); }
415+
408416
/// Gets the stopping strength of this MovableObject's effect.
409417
/// @return The stopping strength of the effect, 0-255.
410418
int GetEffectStopStrength() const { return m_EffectStopStrength; }
411419

420+
/// Gets the stopping strength of this MovableObject's effect as a float.
421+
/// @return The stopping strength of the effect, 0.0-1.0.
422+
float GetEffectStopStrengthFloat() const { return static_cast<float>(m_EffectStopStrength) / 255.0f; }
423+
424+
/// Sets the stopping strength of this MovableObject's effect.
425+
/// @param strength The new stopping strength of the effect, 0.0-1.0.
426+
void SetEffectStopStrengthFloat(float strength) { m_EffectStopStrength = std::floor(255.0F * strength); }
427+
428+
/// Sets both strengths of this MovableObject's effect.
429+
/// @param strength The new strengths of the effect, 0.0-1.0.
430+
void SetEffectStrength(float strength) { m_EffectStartStrength = m_EffectStopStrength = std::floor(255.0F * strength); }
431+
412432
/// Gets whether or not this MovableObject's effect is drawn every frame.
413433
/// @return Boolean indicating whether or not the effect is drawn.
414434
bool GetPostEffectEnabled() const { return m_PostEffectEnabled; }

Source/Lua/LuaBindingsEntities.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,8 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MovableObject) {
890890
.property("Diameter", &MovableObject::GetDiameter)
891891
.property("Scale", &MovableObject::GetScale, &MovableObject::SetScale)
892892
.property("EffectRotAngle", &MovableObject::GetEffectRotAngle, &MovableObject::SetEffectRotAngle)
893+
.property("EffectStartStrength", &MovableObject::GetEffectStartStrengthFloat, &MovableObject::SetEffectStartStrengthFloat)
894+
.property("EffectStopStrength", &MovableObject::GetEffectStopStrengthFloat, &MovableObject::SetEffectStopStrengthFloat)
893895
.property("GlobalAccScalar", &MovableObject::GetGlobalAccScalar, &MovableObject::SetGlobalAccScalar)
894896
.property("AirResistance", &MovableObject::GetAirResistance, &MovableObject::SetAirResistance)
895897
.property("AirThreshold", &MovableObject::GetAirThreshold, &MovableObject::SetAirThreshold)
@@ -989,6 +991,7 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MovableObject) {
989991
.def("SendMessage", &LuaAdaptersMovableObject::SendMessage1)
990992
.def("SendMessage", &LuaAdaptersMovableObject::SendMessage2)
991993
.def("RequestSyncedUpdate", &MovableObject::RequestSyncedUpdate)
994+
.def("SetEffectStrength", &MovableObject::SetEffectStrength)
992995
.def("GetScreenEffectPath", &MovableObject::GetScreenEffectPath)
993996
.def("SetScreenEffectPath", &MovableObject::SetScreenEffectPath);
994997
}

0 commit comments

Comments
 (0)