-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0effd93
commit 27f5914
Showing
7 changed files
with
164 additions
and
90 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
47 changes: 4 additions & 43 deletions
47
Source/Features/Visuals/PlayerOutlineGlow/PlayerOutlineGlow.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
46 changes: 46 additions & 0 deletions
46
Source/Features/Visuals/PlayerOutlineGlow/PlayerOutlineGlowContext.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,46 @@ | ||
#pragma once | ||
|
||
#include <OutlineGlow/GlowSceneObjects.h> | ||
#include "PlayerOutlineGlowCondition.h" | ||
|
||
template <typename HookContext> | ||
class PlayerOutlineGlowContext { | ||
public: | ||
explicit PlayerOutlineGlowContext(HookContext& hookContext) noexcept | ||
: hookContext{hookContext} | ||
{ | ||
} | ||
|
||
[[nodiscard]] auto& state() const noexcept | ||
{ | ||
return hookContext.featuresStates().visualFeaturesStates.playerOutlineGlowState; | ||
} | ||
|
||
[[nodiscard]] decltype(auto) condition() const noexcept | ||
{ | ||
return hookContext.template make<PlayerOutlineGlowCondition>(); | ||
} | ||
|
||
[[nodiscard]] decltype(auto) getGlowSceneObjectFor(auto&& baseEntity) const noexcept | ||
{ | ||
return hookContext.template make<GlowSceneObjects>().getGlowSceneObject(baseEntity.handle()); | ||
} | ||
|
||
[[nodiscard]] auto& viewRenderHook() const noexcept | ||
{ | ||
return hookContext.hooks().viewRenderHook; | ||
} | ||
|
||
void clearGlowSceneObjects() const noexcept | ||
{ | ||
hookContext.template make<GlowSceneObjects>().clearObjects(); | ||
} | ||
|
||
[[nodiscard]] bool isLocalPlayerAlive() const noexcept | ||
{ | ||
return hookContext.localPlayerController2().playerPawn().isAlive().value_or(true); | ||
} | ||
|
||
private: | ||
HookContext& 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include <CS2/Classes/Entities/C_BaseEntity.h> | ||
#include <CS2/Classes/Color.h> | ||
#include <Platform/Macros/IsPlatform.h> | ||
|
||
#include "GlowSceneObjectPointer.h" | ||
|
||
template <typename HookContext> | ||
class GlowSceneObjectContext { | ||
public: | ||
GlowSceneObjectContext(HookContext& hookContext, GlowSceneObjectPointer* glowSceneObjectPointer) noexcept | ||
: hookContext{hookContext} | ||
, glowSceneObjectPointer{glowSceneObjectPointer} | ||
{ | ||
} | ||
|
||
void applyGlow(auto&& sceneObject, cs2::Color color) const noexcept | ||
{ | ||
if (!sceneObject || !glowSceneObjectPointer) | ||
return; | ||
|
||
if (const auto manageGlowSceneObject = hookContext.gameDependencies().manageGlowSceneObject) { | ||
cs2::CGlowHelperSceneObject* glowSceneObject{glowSceneObjectPointer->value()}; | ||
cs2::CGlowHelperSceneObject* dummy{nullptr}; | ||
float colorFloat[4]{color.r() / 255.0f, color.g() / 255.0f, color.b() / 255.0f, color.a() / 255.0f}; | ||
|
||
#if IS_WIN64() | ||
manageGlowSceneObject(&glowSceneObject, &dummy, sceneObject, colorFloat, 0, 0, 3, 1.0f); | ||
#elif IS_LINUX() | ||
double colorDouble[2]; | ||
static_assert(sizeof(colorFloat) == sizeof(colorDouble)); | ||
std::memcpy(colorDouble, colorFloat, sizeof(colorFloat)); | ||
manageGlowSceneObject(&glowSceneObject, &dummy, sceneObject, 3, colorDouble[0], colorDouble[1], 0.0f, 0.0f, 1.0f); | ||
#endif | ||
|
||
glowSceneObjectPointer->setValue(glowSceneObject); | ||
} | ||
} | ||
|
||
void setGlowEntity(auto&& entity) const noexcept | ||
{ | ||
if (glowSceneObjectPointer && glowSceneObjectPointer->value()) { | ||
hookContext.gameDependencies().glowSceneObjectDeps.offsetToGlowSceneObjectEntity.of(glowSceneObjectPointer->value()) = static_cast<cs2::C_BaseEntity*>(entity); | ||
} | ||
} | ||
|
||
private: | ||
HookContext& hookContext; | ||
GlowSceneObjectPointer* glowSceneObjectPointer; | ||
}; |