Skip to content
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

Implement different outline glow colors for different types of grenades #4337

Merged
merged 1 commit into from
Sep 16, 2024
Merged
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: 1 addition & 1 deletion Source/Features/Visuals/OutlineGlow/OutlineGlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class OutlineGlow {
if (entityTypeInfo.typeIndex == utils::typeIndex<cs2::C_CSPlayerPawn, KnownEntityTypes>())
context.applyGlowToPlayer(entity);
else if (entityTypeInfo.isWeapon())
context.applyGlowToWeapon(entity);
context.applyGlowToWeapon(entityTypeInfo, entity);
}

private:
Expand Down
4 changes: 2 additions & 2 deletions Source/Features/Visuals/OutlineGlow/OutlineGlowContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class OutlineGlowContext {
hookContext.template make<PlayerOutlineGlow>().applyGlowToPlayer(hookContext.template make<PlayerPawn>(static_cast<cs2::C_CSPlayerPawn*>(&entity)));
}

void applyGlowToWeapon(auto& entity) const noexcept
void applyGlowToWeapon(EntityTypeInfo entityTypeInfo, auto& entity) const noexcept
{
hookContext.template make<WeaponOutlineGlow>().applyGlowToWeapon(hookContext.template make<BaseEntity>(static_cast<cs2::C_CSWeaponBase*>(&entity)));
hookContext.template make<WeaponOutlineGlow>().applyGlowToWeapon(entityTypeInfo, hookContext.template make<BaseEntity>(static_cast<cs2::C_CSWeaponBase*>(&entity)));
}

[[nodiscard]] auto& viewRenderHook() const noexcept
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <CS2/Constants/ColorConstants.h>
#include "WeaponOutlineGlowContext.h"
#include "WeaponOutlineGlowParams.h"

template <typename Context>
class WeaponOutlineGlow {
Expand All @@ -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<cs2::C_MolotovGrenade, KnownEntityTypes>():
case utils::typeIndex<cs2::C_IncendiaryGrenade, KnownEntityTypes>(): return kMolotovColor;
case utils::typeIndex<cs2::C_Flashbang, KnownEntityTypes>(): return kFlashbangColor;
case utils::typeIndex<cs2::C_HEGrenade, KnownEntityTypes>(): return kHEGrenadeColor;
case utils::typeIndex<cs2::C_SmokeGrenade, KnownEntityTypes>(): return kSmokeGrenadeColor;
default: return kWeaponColor;
}
}

Context context;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <CS2/Classes/Color.h>
#include <CS2/Constants/ColorConstants.h>

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};
}
1 change: 1 addition & 0 deletions Source/Osiris.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
<ClInclude Include="Features\Visuals\OutlineGlow\WeaponOutlineGlow\WeaponOutlineGlow.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\WeaponOutlineGlow\WeaponOutlineGlowCondition.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\WeaponOutlineGlow\WeaponOutlineGlowContext.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\WeaponOutlineGlow\WeaponOutlineGlowParams.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\WeaponOutlineGlow\WeaponOutlineGlowState.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\WeaponOutlineGlow\WeaponOutlineGlowToggle.h" />
<ClInclude Include="Features\Visuals\PlayerInformationThroughWalls\ActiveWeaponAmmo\ActiveWeaponAmmoPanelParams.h" />
Expand Down
3 changes: 3 additions & 0 deletions Source/Osiris.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,9 @@
<ClInclude Include="CS2\Classes\Entities\WeaponEntities.h">
<Filter>CS2\Classes\Entities</Filter>
</ClInclude>
<ClInclude Include="Features\Visuals\OutlineGlow\WeaponOutlineGlow\WeaponOutlineGlowParams.h">
<Filter>Features\Visuals\OutlineGlow\WeaponOutlineGlow</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="UI\Panorama\CreateGUI.js">
Expand Down