Skip to content

Commit aa00a89

Browse files
committed
Add Attachable property AffectsRadius.
1 parent 0503ca1 commit aa00a89

5 files changed

Lines changed: 22 additions & 1 deletion

File tree

CHANGELOG.md

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

5151
- 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.
5252

53+
- New `Attachable` INI and Lua (R/W) property `AffectsRadius` which determines whether an attachable is liable to affect the radius of it's parent.
54+
5355
- 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.
5456

5557
- New hotkey bindings.

Source/Entities/Attachable.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ void Attachable::Clear() {
5555
m_CollidesWithTerrainWhileAttached = true;
5656
m_IgnoresParticlesWhileAttached = false;
5757

58+
m_AffectsRadius = true;
59+
5860
m_PieSlices.clear();
5961

6062
m_PrevParentOffset.Reset();
@@ -107,6 +109,8 @@ int Attachable::Create(const Attachable& reference) {
107109
m_CollidesWithTerrainWhileAttached = reference.m_CollidesWithTerrainWhileAttached;
108110
m_IgnoresParticlesWhileAttached = reference.m_IgnoresParticlesWhileAttached;
109111

112+
m_AffectsRadius = reference.m_AffectsRadius;
113+
110114
for (const std::unique_ptr<PieSlice>& pieSlice: reference.m_PieSlices) {
111115
m_PieSlices.emplace_back(std::unique_ptr<PieSlice>(dynamic_cast<PieSlice*>(pieSlice->Clone())));
112116
}
@@ -155,6 +159,7 @@ int Attachable::ReadProperty(const std::string_view& propName, Reader& reader) {
155159
MatchProperty("InheritsAngularVelWhenDetached", { reader >> m_InheritsAngularVelWhenDetached; });
156160
MatchProperty("CollidesWithTerrainWhileAttached", { reader >> m_CollidesWithTerrainWhileAttached; });
157161
MatchProperty("IgnoresParticlesWhileAttached", { reader >> m_IgnoresParticlesWhileAttached; });
162+
MatchProperty("AffectsRadius", { reader >> m_AffectsRadius; });
158163
MatchProperty("AddPieSlice", { m_PieSlices.emplace_back(std::unique_ptr<PieSlice>(dynamic_cast<PieSlice*>(g_PresetMan.ReadReflectedPreset(reader)))); });
159164

160165
EndPropertyList;
@@ -179,7 +184,7 @@ int Attachable::Save(Writer& writer) const {
179184
writer.NewPropertyWithValue("InheritsHFlipped", ((m_InheritsHFlipped == 0 || m_InheritsHFlipped == 1) ? m_InheritsHFlipped : 2));
180185
writer.NewPropertyWithValue("InheritsRotAngle", m_InheritsRotAngle);
181186
writer.NewPropertyWithValue("InheritedRotAngleOffset", m_InheritedRotAngleOffset);
182-
writer.NewPropertyWithValue("MountedRotAngleOffset", m_MountedRotAngleOffset);
187+
writer.NewPropertyWithValue("MountedRotAngleOffset", m_MountedRotAngleOffset);
183188
writer.NewPropertyWithValue("InheritsVelWhenDetached", m_InheritsVelWhenDetached);
184189
writer.NewPropertyWithValue("InheritsAngularVelWhenDetached", m_InheritsAngularVelWhenDetached);
185190

Source/Entities/Attachable.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,14 @@ namespace RTE {
324324
/// Sets whether this Attachable currently ignores collisions with single-atom particles.
325325
/// @param collidesWithTerrainWhileAttached Whether this attachable ignores collisions with single-atom particles.
326326
void SetIgnoresParticlesWhileAttached(bool ignoresParticlesWhileAttached) { m_IgnoresParticlesWhileAttached = ignoresParticlesWhileAttached; }
327+
328+
/// Gets whether this Attachable currently ignores collisions with single-atom particles.
329+
/// @return >Whether this attachable ignores collisions with single-atom particles.
330+
bool AffectsRadius() const { return m_AffectsRadius; }
331+
332+
/// Sets whether this Attachable currently ignores collisions with single-atom particles.
333+
/// @param collidesWithTerrainWhileAttached Whether this attachable ignores collisions with single-atom particles.
334+
void SetAffectsRadius(bool affectsRadius) { m_AffectsRadius = affectsRadius; }
327335
#pragma endregion
328336

329337
#pragma region Override Methods
@@ -470,6 +478,8 @@ namespace RTE {
470478
long m_AtomSubgroupID; //!< The Atom IDs this' atoms will have when attached and added to a parent's AtomGroup.
471479
bool m_CollidesWithTerrainWhileAttached; //!< Whether this attachable currently has terrain collisions enabled while it's attached to a parent.
472480
bool m_IgnoresParticlesWhileAttached; //!< Whether this Attachable should ignore collisions with single-atom MOs while attached.
481+
482+
bool m_AffectsRadius; //!< Whether this Attachable can be considered to increase the radius of it's parent.
473483

474484
std::vector<std::unique_ptr<PieSlice>> m_PieSlices; //!< The vector of PieSlices belonging to this Attachable. Added to and removed from the RootParent as appropriate, when a parent is set.
475485

Source/Entities/MOSRotating.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,9 @@ bool MOSRotating::HandlePotentialRadiusAffectingAttachable(const Attachable* att
17691769
if (!attachable->IsAttachedTo(this) && !attachable->IsWound()) {
17701770
return false;
17711771
}
1772+
if (!attachable->AffectsRadius()) {
1773+
return false;
1774+
}
17721775
const HDFirearm* thisAsFirearm = dynamic_cast<HDFirearm*>(this);
17731776
const AEmitter* thisAsEmitter = dynamic_cast<AEmitter*>(this);
17741777
if ((thisAsFirearm && attachable == thisAsFirearm->GetFlash()) || (thisAsEmitter && attachable == thisAsEmitter->GetFlash())) {

Source/Lua/LuaBindingsEntities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, Attachable) {
557557
.property("InheritsFrame", &Attachable::InheritsFrame, &Attachable::SetInheritsFrame)
558558
.property("InheritsVelWhenDetached", &Attachable::InheritsVelocityWhenDetached, &Attachable::SetInheritsVelocityWhenDetached)
559559
.property("InheritsAngularVelWhenDetached", &Attachable::InheritsAngularVelocityWhenDetached, &Attachable::SetInheritsAngularVelocityWhenDetached)
560+
.property("AffectsRadius", &Attachable::AffectsRadius, &Attachable::SetAffectsRadius)
560561

561562
.def("IsAttached", &Attachable::IsAttached)
562563
.def("IsAttachedTo", &Attachable::IsAttachedTo)

0 commit comments

Comments
 (0)