Skip to content

Attachables: Radius Effect #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion Source/Entities/Attachable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ void Attachable::Clear() {
m_CollidesWithTerrainWhileAttached = true;
m_IgnoresParticlesWhileAttached = false;

m_AffectsRadius = true;

m_PieSlices.clear();

m_PrevParentOffset.Reset();
Expand Down Expand Up @@ -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>& pieSlice: reference.m_PieSlices) {
m_PieSlices.emplace_back(std::unique_ptr<PieSlice>(dynamic_cast<PieSlice*>(pieSlice->Clone())));
}
Expand Down Expand Up @@ -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<PieSlice>(dynamic_cast<PieSlice*>(g_PresetMan.ReadReflectedPreset(reader)))); });

EndPropertyList;
Expand All @@ -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);

Expand Down
10 changes: 10 additions & 0 deletions Source/Entities/Attachable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<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.

Expand Down
3 changes: 3 additions & 0 deletions Source/Entities/MOSRotating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<HDFirearm*>(this);
const AEmitter* thisAsEmitter = dynamic_cast<AEmitter*>(this);
if ((thisAsFirearm && attachable == thisAsFirearm->GetFlash()) || (thisAsEmitter && attachable == thisAsEmitter->GetFlash())) {
Expand Down
1 change: 1 addition & 0 deletions Source/Lua/LuaBindingsEntities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down