-
Notifications
You must be signed in to change notification settings - Fork 961
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement outline glow for grenade projectiles
- Loading branch information
1 parent
02cf76b
commit 8f7ba72
Showing
17 changed files
with
232 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include "C_BaseEntity.h" | ||
|
||
namespace cs2 | ||
{ | ||
|
||
struct C_BaseCSGrenadeProjectile : C_BaseEntity { | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "C_BaseCSGrenadeProjectile.h" | ||
#include <Platform/Macros/PlatformSpecific.h> | ||
|
||
namespace cs2 | ||
{ | ||
|
||
struct C_HEGrenadeProjectile : C_BaseCSGrenadeProjectile { | ||
static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_HEGrenadeProjectile@@", "21C_HEGrenadeProjectile")}; | ||
}; | ||
|
||
struct C_SmokeGrenadeProjectile : C_BaseCSGrenadeProjectile { | ||
static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_SmokeGrenadeProjectile@@", "24C_SmokeGrenadeProjectile")}; | ||
}; | ||
|
||
struct C_MolotovProjectile : C_BaseCSGrenadeProjectile { | ||
static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_MolotovProjectile@@", "19C_MolotovProjectile")}; | ||
}; | ||
|
||
struct C_FlashbangProjectile : C_BaseCSGrenadeProjectile { | ||
static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_FlashbangProjectile@@", "21C_FlashbangProjectile")}; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../Features/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlow.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#pragma once | ||
|
||
#include <utility> | ||
|
||
#include <CS2/Constants/ColorConstants.h> | ||
|
||
#include "GrenadeProjectileOutlineGlowContext.h" | ||
#include "GrenadeProjectileOutlineGlowParams.h" | ||
|
||
template <typename Context> | ||
class GrenadeProjectileOutlineGlow { | ||
public: | ||
template <typename... Args> | ||
GrenadeProjectileOutlineGlow(Args&&... args) noexcept | ||
: context{std::forward<Args>(args)...} | ||
{ | ||
} | ||
|
||
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)); | ||
} | ||
} | ||
|
||
private: | ||
[[nodiscard]] cs2::Color getColor(EntityTypeInfo entityTypeInfo) const noexcept | ||
{ | ||
using namespace grenade_projectile_outline_glow_params; | ||
|
||
switch (entityTypeInfo.typeIndex) { | ||
case EntityTypeInfo::indexOf<cs2::C_FlashbangProjectile>(): return kFlashbangColor; | ||
case EntityTypeInfo::indexOf<cs2::C_HEGrenadeProjectile>(): return kHEGrenadeColor; | ||
case EntityTypeInfo::indexOf<cs2::C_MolotovProjectile>(): return kMolotovColor; | ||
case EntityTypeInfo::indexOf<cs2::C_SmokeGrenadeProjectile>(): return kSmokeGrenadeColor; | ||
default: return kFallbackColor; | ||
} | ||
} | ||
|
||
Context context; | ||
}; | ||
|
||
template <typename HookContext> | ||
GrenadeProjectileOutlineGlow(HookContext&) -> GrenadeProjectileOutlineGlow<GrenadeProjectileOutlineGlowContext<HookContext>>; |
18 changes: 18 additions & 0 deletions
18
...es/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowContext.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
template <typename HookContext> | ||
class GrenadeProjectileOutlineGlowContext { | ||
public: | ||
explicit GrenadeProjectileOutlineGlowContext(HookContext& hookContext) noexcept | ||
: hookContext{hookContext} | ||
{ | ||
} | ||
|
||
[[nodiscard]] auto& state() const noexcept | ||
{ | ||
return hookContext.featuresStates().visualFeaturesStates.grenadeProjectileOutlineGlowState; | ||
} | ||
|
||
private: | ||
HookContext& hookContext; | ||
}; |
14 changes: 14 additions & 0 deletions
14
...res/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowParams.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include <CS2/Classes/Color.h> | ||
|
||
namespace grenade_projectile_outline_glow_params | ||
{ | ||
constexpr auto kColorAlpha = 102; | ||
|
||
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}; | ||
constexpr cs2::Color kFallbackColor{cs2::kColorWhite}; | ||
} |
5 changes: 5 additions & 0 deletions
5
...ures/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowState.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
struct GrenadeProjectileOutlineGlowState { | ||
bool enabled{true}; | ||
}; |
25 changes: 25 additions & 0 deletions
25
...res/Visuals/OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowToggle.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <FeatureHelpers/FeatureToggle.h> | ||
#include "GrenadeProjectileOutlineGlowContext.h" | ||
|
||
template <typename Context> | ||
class GrenadeProjectileOutlineGlowToggle : public FeatureToggle<GrenadeProjectileOutlineGlowToggle<Context>> { | ||
public: | ||
template <typename... Args> | ||
GrenadeProjectileOutlineGlowToggle(Args&&... args) noexcept | ||
: context{std::forward<Args>(args)...} | ||
{ | ||
} | ||
|
||
[[nodiscard]] auto& enabledVariable(typename GrenadeProjectileOutlineGlowToggle::ToggleMethod) const noexcept | ||
{ | ||
return context.state().enabled; | ||
} | ||
|
||
private: | ||
Context context; | ||
}; | ||
|
||
template <typename HookContext> | ||
GrenadeProjectileOutlineGlowToggle(HookContext&) -> GrenadeProjectileOutlineGlowToggle<GrenadeProjectileOutlineGlowContext<HookContext>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters