diff --git a/CHANGELOG.md b/CHANGELOG.md index 641471455..3f1b9bbcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - New `AEmitter` and `PEmitter` INI and Lua (R/W) property `PlayBurstSound` which denotes whether the BurstSound should play when appropriate. This should not be confused for a trigger - it's just a enable/disable toggle to avoid having to remove and add BurstSound altogether. +- New `Attachable` INI and Lua (R/W) property `AffectsRadius` which determines whether an attachable is liable to affect the radius of it's parent. + - New `MOSprite` INI and Lua (R/W) integer property `ForcedHFlip` which forces a certain flippedness and disallows anything else from ever changing it without clearing the forced value first. 0 is forced not flipped, 1 forced flipped, and -1 is no force. - New hotkey bindings. diff --git a/Source/Entities/Attachable.cpp b/Source/Entities/Attachable.cpp index 702614ef9..7d9d1da86 100644 --- a/Source/Entities/Attachable.cpp +++ b/Source/Entities/Attachable.cpp @@ -55,6 +55,8 @@ void Attachable::Clear() { m_CollidesWithTerrainWhileAttached = true; m_IgnoresParticlesWhileAttached = false; + m_AffectsRadius = true; + m_PieSlices.clear(); m_PrevParentOffset.Reset(); @@ -107,6 +109,8 @@ int Attachable::Create(const Attachable& reference) { m_CollidesWithTerrainWhileAttached = reference.m_CollidesWithTerrainWhileAttached; m_IgnoresParticlesWhileAttached = reference.m_IgnoresParticlesWhileAttached; + m_AffectsRadius = reference.m_AffectsRadius; + for (const std::unique_ptr& pieSlice: reference.m_PieSlices) { m_PieSlices.emplace_back(std::unique_ptr(dynamic_cast(pieSlice->Clone()))); } @@ -155,6 +159,7 @@ int Attachable::ReadProperty(const std::string_view& propName, Reader& reader) { MatchProperty("InheritsAngularVelWhenDetached", { reader >> m_InheritsAngularVelWhenDetached; }); MatchProperty("CollidesWithTerrainWhileAttached", { reader >> m_CollidesWithTerrainWhileAttached; }); MatchProperty("IgnoresParticlesWhileAttached", { reader >> m_IgnoresParticlesWhileAttached; }); + MatchProperty("AffectsRadius", { reader >> m_AffectsRadius; }); MatchProperty("AddPieSlice", { m_PieSlices.emplace_back(std::unique_ptr(dynamic_cast(g_PresetMan.ReadReflectedPreset(reader)))); }); EndPropertyList; @@ -179,7 +184,7 @@ int Attachable::Save(Writer& writer) const { writer.NewPropertyWithValue("InheritsHFlipped", ((m_InheritsHFlipped == 0 || m_InheritsHFlipped == 1) ? m_InheritsHFlipped : 2)); writer.NewPropertyWithValue("InheritsRotAngle", m_InheritsRotAngle); writer.NewPropertyWithValue("InheritedRotAngleOffset", m_InheritedRotAngleOffset); - writer.NewPropertyWithValue("MountedRotAngleOffset", m_MountedRotAngleOffset); + writer.NewPropertyWithValue("MountedRotAngleOffset", m_MountedRotAngleOffset); writer.NewPropertyWithValue("InheritsVelWhenDetached", m_InheritsVelWhenDetached); writer.NewPropertyWithValue("InheritsAngularVelWhenDetached", m_InheritsAngularVelWhenDetached); diff --git a/Source/Entities/Attachable.h b/Source/Entities/Attachable.h index 0584e494c..8826cf92e 100644 --- a/Source/Entities/Attachable.h +++ b/Source/Entities/Attachable.h @@ -324,6 +324,14 @@ namespace RTE { /// Sets whether this Attachable currently ignores collisions with single-atom particles. /// @param collidesWithTerrainWhileAttached Whether this attachable ignores collisions with single-atom particles. void SetIgnoresParticlesWhileAttached(bool ignoresParticlesWhileAttached) { m_IgnoresParticlesWhileAttached = ignoresParticlesWhileAttached; } + + /// Gets whether this Attachable currently ignores collisions with single-atom particles. + /// @return >Whether this attachable ignores collisions with single-atom particles. + bool AffectsRadius() const { return m_AffectsRadius; } + + /// Sets whether this Attachable currently ignores collisions with single-atom particles. + /// @param collidesWithTerrainWhileAttached Whether this attachable ignores collisions with single-atom particles. + void SetAffectsRadius(bool affectsRadius) { m_AffectsRadius = affectsRadius; } #pragma endregion #pragma region Override Methods @@ -470,6 +478,8 @@ namespace RTE { long m_AtomSubgroupID; //!< The Atom IDs this' atoms will have when attached and added to a parent's AtomGroup. bool m_CollidesWithTerrainWhileAttached; //!< Whether this attachable currently has terrain collisions enabled while it's attached to a parent. bool m_IgnoresParticlesWhileAttached; //!< Whether this Attachable should ignore collisions with single-atom MOs while attached. + + bool m_AffectsRadius; //!< Whether this Attachable can be considered to increase the radius of it's parent. std::vector> m_PieSlices; //!< The vector of PieSlices belonging to this Attachable. Added to and removed from the RootParent as appropriate, when a parent is set. diff --git a/Source/Entities/MOSRotating.cpp b/Source/Entities/MOSRotating.cpp index 20fc63d2f..0f55d4807 100644 --- a/Source/Entities/MOSRotating.cpp +++ b/Source/Entities/MOSRotating.cpp @@ -1790,6 +1790,9 @@ bool MOSRotating::HandlePotentialRadiusAffectingAttachable(const Attachable* att if (!attachable->IsAttachedTo(this) && !attachable->IsWound()) { return false; } + if (!attachable->AffectsRadius()) { + return false; + } const HDFirearm* thisAsFirearm = dynamic_cast(this); const AEmitter* thisAsEmitter = dynamic_cast(this); if ((thisAsFirearm && attachable == thisAsFirearm->GetFlash()) || (thisAsEmitter && attachable == thisAsEmitter->GetFlash())) { diff --git a/Source/Lua/LuaBindingsEntities.cpp b/Source/Lua/LuaBindingsEntities.cpp index a71c476cb..97aa6f8fe 100644 --- a/Source/Lua/LuaBindingsEntities.cpp +++ b/Source/Lua/LuaBindingsEntities.cpp @@ -558,6 +558,7 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Attachable) { .property("InheritsFrame", &Attachable::InheritsFrame, &Attachable::SetInheritsFrame) .property("InheritsVelWhenDetached", &Attachable::InheritsVelocityWhenDetached, &Attachable::SetInheritsVelocityWhenDetached) .property("InheritsAngularVelWhenDetached", &Attachable::InheritsAngularVelocityWhenDetached, &Attachable::SetInheritsAngularVelocityWhenDetached) + .property("AffectsRadius", &Attachable::AffectsRadius, &Attachable::SetAffectsRadius) .def("IsAttached", &Attachable::IsAttached) .def("IsAttachedTo", &Attachable::IsAttachedTo)