diff --git a/Source/CS2/Classes/Entities/GrenadeProjectiles.h b/Source/CS2/Classes/Entities/GrenadeProjectiles.h index 366da6a882d..e282537a517 100644 --- a/Source/CS2/Classes/Entities/GrenadeProjectiles.h +++ b/Source/CS2/Classes/Entities/GrenadeProjectiles.h @@ -12,6 +12,8 @@ struct C_HEGrenadeProjectile : C_BaseCSGrenadeProjectile { struct C_SmokeGrenadeProjectile : C_BaseCSGrenadeProjectile { static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_SmokeGrenadeProjectile@@", "24C_SmokeGrenadeProjectile")}; + + using m_bDidSmokeEffect = bool; }; struct C_MolotovProjectile : C_BaseCSGrenadeProjectile { diff --git a/Source/FeatureHelpers/EntityClassifier.h b/Source/FeatureHelpers/EntityClassifier.h index 613009f862d..633ddd20258 100644 --- a/Source/FeatureHelpers/EntityClassifier.h +++ b/Source/FeatureHelpers/EntityClassifier.h @@ -21,6 +21,12 @@ struct EntityTypeInfo { return EntityBaseTypeInfo::isBaseOf(typeIndex); } + template + [[nodiscard]] constexpr bool is() const noexcept + { + return typeIndex == indexOf(); + } + template [[nodiscard]] static constexpr auto indexOf() noexcept { diff --git a/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlow.h b/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlow.h index 4a8333a0f05..70c361bc166 100644 --- a/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlow.h +++ b/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlow.h @@ -18,10 +18,12 @@ class GrenadeProjectileOutlineGlow { void applyGlowToGrenadeProjectile(EntityTypeInfo entityTypeInfo, auto&& grenadeProjectile) const noexcept { - if (context.state().enabled) { - using namespace grenade_projectile_outline_glow_params; - grenadeProjectile.applyGlowRecursively(getColor(entityTypeInfo).setAlpha(kColorAlpha)); - } + auto&& condition = context.condition(); + if (!condition.shouldRun() || !condition.shouldGlowGrenadeProjectile(entityTypeInfo, grenadeProjectile)) + return; + + using namespace grenade_projectile_outline_glow_params; + grenadeProjectile.applyGlowRecursively(getColor(entityTypeInfo).setAlpha(kColorAlpha)); } private: diff --git a/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowCondition.h b/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowCondition.h new file mode 100644 index 00000000000..8b19d4d1240 --- /dev/null +++ b/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowCondition.h @@ -0,0 +1,29 @@ +#pragma once + +#include + +#include +#include + +template +class GrenadeProjectileOutlineGlowCondition { +public: + template + explicit GrenadeProjectileOutlineGlowCondition(Args&&... args) noexcept + : context{std::forward(args)...} + { + } + + [[nodiscard]] bool shouldRun() const noexcept + { + return context.state().enabled; + } + + [[nodiscard]] bool shouldGlowGrenadeProjectile(EntityTypeInfo entityTypeInfo, auto&& grenadeProjectile) const noexcept + { + return !entityTypeInfo.is() || !grenadeProjectile.template as().didSmokeEffect().valueOr(false); + } + +private: + Context context; +}; diff --git a/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowContext.h b/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowContext.h index c1f815c7b18..44244ada141 100644 --- a/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowContext.h +++ b/Source/Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowContext.h @@ -1,5 +1,7 @@ #pragma once +#include "GrenadeProjectileOutlineGlowCondition.h" + template class GrenadeProjectileOutlineGlowContext { public: @@ -13,6 +15,11 @@ class GrenadeProjectileOutlineGlowContext { return hookContext.featuresStates().visualFeaturesStates.grenadeProjectileOutlineGlowState; } + [[nodiscard]] decltype(auto) condition() const noexcept + { + return hookContext.template make>(); + } + private: HookContext& hookContext; }; diff --git a/Source/GameClasses/BaseEntity.h b/Source/GameClasses/BaseEntity.h index a59392e5e99..5713184ed81 100644 --- a/Source/GameClasses/BaseEntity.h +++ b/Source/GameClasses/BaseEntity.h @@ -15,6 +15,12 @@ class BaseEntity { { } + template