From 8995623b317c6c569d4305f64ed61efc136d4889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Krupi=C5=84ski?= Date: Mon, 16 Sep 2024 20:08:22 +0200 Subject: [PATCH] Implement different outline glow colors for different types of grenades --- .../Visuals/OutlineGlow/OutlineGlow.h | 2 +- .../Visuals/OutlineGlow/OutlineGlowContext.h | 4 +-- .../WeaponOutlineGlow/WeaponOutlineGlow.h | 26 ++++++++++++++----- .../WeaponOutlineGlowParams.h | 16 ++++++++++++ Source/Osiris.vcxproj | 1 + Source/Osiris.vcxproj.filters | 3 +++ 6 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 Source/Features/Visuals/OutlineGlow/WeaponOutlineGlow/WeaponOutlineGlowParams.h diff --git a/Source/Features/Visuals/OutlineGlow/OutlineGlow.h b/Source/Features/Visuals/OutlineGlow/OutlineGlow.h index 45c5adb15e2..0b5b9e173f8 100644 --- a/Source/Features/Visuals/OutlineGlow/OutlineGlow.h +++ b/Source/Features/Visuals/OutlineGlow/OutlineGlow.h @@ -20,7 +20,7 @@ class OutlineGlow { if (entityTypeInfo.typeIndex == utils::typeIndex()) context.applyGlowToPlayer(entity); else if (entityTypeInfo.isWeapon()) - context.applyGlowToWeapon(entity); + context.applyGlowToWeapon(entityTypeInfo, entity); } private: diff --git a/Source/Features/Visuals/OutlineGlow/OutlineGlowContext.h b/Source/Features/Visuals/OutlineGlow/OutlineGlowContext.h index 89f20189539..e69a5c52598 100644 --- a/Source/Features/Visuals/OutlineGlow/OutlineGlowContext.h +++ b/Source/Features/Visuals/OutlineGlow/OutlineGlowContext.h @@ -24,9 +24,9 @@ class OutlineGlowContext { hookContext.template make().applyGlowToPlayer(hookContext.template make(static_cast(&entity))); } - void applyGlowToWeapon(auto& entity) const noexcept + void applyGlowToWeapon(EntityTypeInfo entityTypeInfo, auto& entity) const noexcept { - hookContext.template make().applyGlowToWeapon(hookContext.template make(static_cast(&entity))); + hookContext.template make().applyGlowToWeapon(entityTypeInfo, hookContext.template make(static_cast(&entity))); } [[nodiscard]] auto& viewRenderHook() const noexcept diff --git a/Source/Features/Visuals/OutlineGlow/WeaponOutlineGlow/WeaponOutlineGlow.h b/Source/Features/Visuals/OutlineGlow/WeaponOutlineGlow/WeaponOutlineGlow.h index 7fd1f982b32..a2d56e47718 100644 --- a/Source/Features/Visuals/OutlineGlow/WeaponOutlineGlow/WeaponOutlineGlow.h +++ b/Source/Features/Visuals/OutlineGlow/WeaponOutlineGlow/WeaponOutlineGlow.h @@ -1,7 +1,7 @@ #pragma once -#include #include "WeaponOutlineGlowContext.h" +#include "WeaponOutlineGlowParams.h" template class WeaponOutlineGlow { @@ -12,19 +12,33 @@ class WeaponOutlineGlow { { } - void applyGlowToWeapon(auto&& weapon) const noexcept + void applyGlowToWeapon(EntityTypeInfo entityTypeInfo, auto&& weapon) const noexcept { auto&& condition = context.condition(); if (!condition.shouldRun() || !condition.shouldGlowWeapon(weapon)) return; - constexpr auto color = cs2::kColorWhite.setAlpha(102); - constexpr auto range = 800; - weapon.applyGlow(color, range); - weapon.forEachChild([color, range](auto&& entity) { entity.applyGlow(color, range); }); + using namespace weapon_outline_glow_params; + const auto color = getColor(entityTypeInfo).setAlpha(kColorAlpha); + weapon.applyGlow(color, kRange); + weapon.forEachChild([color](auto&& entity) { entity.applyGlow(color, kRange); }); } private: + [[nodiscard]] cs2::Color getColor(EntityTypeInfo entityTypeInfo) const noexcept + { + using namespace weapon_outline_glow_params; + + switch (entityTypeInfo.typeIndex) { + case utils::typeIndex(): + case utils::typeIndex(): return kMolotovColor; + case utils::typeIndex(): return kFlashbangColor; + case utils::typeIndex(): return kHEGrenadeColor; + case utils::typeIndex(): return kSmokeGrenadeColor; + default: return kWeaponColor; + } + } + Context context; }; diff --git a/Source/Features/Visuals/OutlineGlow/WeaponOutlineGlow/WeaponOutlineGlowParams.h b/Source/Features/Visuals/OutlineGlow/WeaponOutlineGlow/WeaponOutlineGlowParams.h new file mode 100644 index 00000000000..7d59e5977ec --- /dev/null +++ b/Source/Features/Visuals/OutlineGlow/WeaponOutlineGlow/WeaponOutlineGlowParams.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +namespace weapon_outline_glow_params +{ + constexpr auto kRange = 800; + constexpr auto kColorAlpha = 102; + + constexpr cs2::Color kWeaponColor{cs2::kColorWhite}; + constexpr cs2::Color kMolotovColor{255, 223, 128}; + constexpr cs2::Color kFlashbangColor{128, 172, 255}; + constexpr cs2::Color kHEGrenadeColor{255, 128, 128}; + constexpr cs2::Color kSmokeGrenadeColor{128, 255, 128}; +} diff --git a/Source/Osiris.vcxproj b/Source/Osiris.vcxproj index 134071c87cf..3822228ddd4 100644 --- a/Source/Osiris.vcxproj +++ b/Source/Osiris.vcxproj @@ -175,6 +175,7 @@ + diff --git a/Source/Osiris.vcxproj.filters b/Source/Osiris.vcxproj.filters index b75ab241e6c..ed689838053 100644 --- a/Source/Osiris.vcxproj.filters +++ b/Source/Osiris.vcxproj.filters @@ -1457,6 +1457,9 @@ CS2\Classes\Entities + + Features\Visuals\OutlineGlow\WeaponOutlineGlow +