-
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
e9f4f37
commit 0effd93
Showing
64 changed files
with
1,164 additions
and
7 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 "CUtlVector.h" | ||
#include "SceneObjectUpdaterHandle_t.h" | ||
|
||
namespace cs2 | ||
{ | ||
struct CRenderComponent { | ||
using sceneObjectUpdaters = cs2::CUtlVector<SceneObjectUpdaterHandle_t*>; | ||
}; | ||
} |
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,9 @@ | ||
#pragma once | ||
|
||
namespace cs2 | ||
{ | ||
|
||
struct CSceneObject { | ||
}; | ||
|
||
} |
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,12 @@ | ||
#pragma once | ||
|
||
namespace cs2 | ||
{ | ||
|
||
struct CSceneObject; | ||
|
||
struct CSceneSystem { | ||
using DeleteSceneObject = void(CSceneSystem* sceneSystem, CSceneObject* sceneObject); | ||
}; | ||
|
||
} |
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 |
---|---|---|
@@ -1,10 +1,16 @@ | ||
#pragma once | ||
|
||
#include <Utils/Pad.h> | ||
|
||
namespace cs2 | ||
{ | ||
|
||
struct CEntityIdentity; | ||
|
||
struct CEntityInstance { | ||
const void* vmt; | ||
PAD(8); | ||
CEntityIdentity* identity; | ||
}; | ||
|
||
} |
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,40 @@ | ||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
#include "CSceneObject.h" | ||
|
||
#include <Platform/Macros/IsPlatform.h> | ||
|
||
namespace cs2 | ||
{ | ||
|
||
enum SceneObjectFlags { | ||
SceneObjectFlag_IsDeleted = 0x20 | ||
}; | ||
|
||
struct CGlowHelperSceneObject : CSceneObject { | ||
using entity = C_BaseEntity*; | ||
using flags = std::uint8_t; | ||
}; | ||
|
||
#if IS_WIN64() | ||
|
||
using ManageGlowSceneObject = void( | ||
CGlowHelperSceneObject** glowHelperSceneObject, | ||
CGlowHelperSceneObject** unused, | ||
CSceneObject* sceneObject, | ||
float color[4], float glowRangeMin, float glowRange, int glowType, float glowBackfaceMult); | ||
|
||
#elif IS_LINUX() | ||
|
||
using ManageGlowSceneObject = void( | ||
CGlowHelperSceneObject** glowHelperSceneObject, | ||
CGlowHelperSceneObject** unused, | ||
CSceneObject* sceneObject, | ||
int glowType, | ||
double colorGA, double colorRG, float glowRangeMin, float glowRange, float glowBackfaceMult); | ||
|
||
#endif | ||
|
||
} |
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,12 @@ | ||
#pragma once | ||
|
||
namespace cs2 | ||
{ | ||
|
||
struct CSceneObject; | ||
|
||
struct SceneObjectUpdaterHandle_t { | ||
using sceneObject = CSceneObject*; | ||
}; | ||
|
||
} |
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
85 changes: 85 additions & 0 deletions
85
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#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; | ||
}; | ||
|
||
template <typename Context> | ||
class PlayerOutlineGlow { | ||
public: | ||
template <typename... Args> | ||
PlayerOutlineGlow(Args&&... args) noexcept | ||
: context{std::forward<Args>(args)...} | ||
{ | ||
} | ||
|
||
void applyGlowToPlayer(auto&& playerPawn) const noexcept | ||
{ | ||
auto&& condition = context.condition(); | ||
if (!condition.shouldRun() || !condition.shouldGlowPlayer(playerPawn)) | ||
return; | ||
|
||
applyGlow(playerPawn.baseEntity(), getColor(playerPawn)); | ||
} | ||
|
||
private: | ||
void applyGlow(auto&& baseEntity, cs2::Color color) const noexcept | ||
{ | ||
context.getGlowSceneObjectFor(baseEntity).apply(baseEntity, color.setAlpha(102)); | ||
} | ||
|
||
[[nodiscard]] cs2::Color getColor(auto&& playerPawn) const noexcept | ||
{ | ||
switch (playerPawn.teamNumber()) { | ||
case TeamNumber::TT: return cs2::kColorTeamTT; | ||
case TeamNumber::CT: return cs2::kColorTeamCT; | ||
default: return cs2::kColorWhite; | ||
} | ||
} | ||
|
||
Context context; | ||
}; | ||
|
||
template <typename HookContext> | ||
PlayerOutlineGlow(HookContext&) -> PlayerOutlineGlow<PlayerOutlineGlowContext<HookContext>>; |
37 changes: 37 additions & 0 deletions
37
Source/Features/Visuals/PlayerOutlineGlow/PlayerOutlineGlowCondition.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,37 @@ | ||
#pragma once | ||
|
||
#include <utility> | ||
|
||
template <typename Context> | ||
class PlayerOutlineGlowCondition { | ||
public: | ||
template <typename... Args> | ||
explicit PlayerOutlineGlowCondition(Args&&... args) noexcept | ||
: context{std::forward<Args>(args)...} | ||
{ | ||
} | ||
|
||
[[nodiscard]] bool shouldRun() const noexcept | ||
{ | ||
return context.state().enabled; | ||
} | ||
|
||
[[nodiscard]] bool shouldGlowPlayer(auto&& playerPawn) const noexcept | ||
{ | ||
return context.isLocalPlayerAlive() | ||
&& playerPawn.isAlive().value_or(true) | ||
&& !(playerPawn.health() <= 0) | ||
&& !playerPawn.isControlledByLocalPlayer() | ||
&& playerPawn.isTTorCT() | ||
&& (!context.state().showOnlyEnemies || playerPawn.isEnemy().value_or(true)); | ||
} | ||
|
||
private: | ||
Context context; | ||
}; | ||
|
||
template <typename HookContext> | ||
class PlayerOutlineGlowContext; | ||
|
||
template <typename HookContext> | ||
PlayerOutlineGlowCondition(HookContext&) -> PlayerOutlineGlowCondition<PlayerOutlineGlowContext<HookContext>>; |
6 changes: 6 additions & 0 deletions
6
Source/Features/Visuals/PlayerOutlineGlow/PlayerOutlineGlowState.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,6 @@ | ||
#pragma once | ||
|
||
struct PlayerOutlineGlowState { | ||
bool enabled{false}; | ||
bool showOnlyEnemies{false}; | ||
}; |
46 changes: 46 additions & 0 deletions
46
Source/Features/Visuals/PlayerOutlineGlow/PlayerOutlineGlowToggle.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 <FeatureHelpers/FeatureToggle.h> | ||
|
||
template <typename Context> | ||
struct PlayerOutlineGlowToggle : FeatureToggleOnOff<PlayerOutlineGlowToggle<Context>> { | ||
template <typename... Args> | ||
PlayerOutlineGlowToggle(Args&&... args) noexcept | ||
: context{std::forward<Args>(args)...} | ||
{ | ||
} | ||
|
||
void update(char option) noexcept | ||
{ | ||
switch (option) { | ||
case '0': this->enable(); context.state().showOnlyEnemies = true; break; | ||
case '1': this->enable(); context.state().showOnlyEnemies = false; break; | ||
case '2': this->disable(); break; | ||
} | ||
} | ||
|
||
[[nodiscard]] auto& enabledVariable(typename PlayerOutlineGlowToggle::ToggleMethod) const noexcept | ||
{ | ||
return context.state().enabled; | ||
} | ||
|
||
void onEnable(typename PlayerOutlineGlowToggle::ToggleMethod) noexcept | ||
{ | ||
context.viewRenderHook().incrementReferenceCount(); | ||
} | ||
|
||
void onDisable(typename PlayerOutlineGlowToggle::ToggleMethod) noexcept | ||
{ | ||
context.viewRenderHook().decrementReferenceCount(); | ||
context.clearGlowSceneObjects(); | ||
} | ||
|
||
private: | ||
Context context; | ||
}; | ||
|
||
template <typename HookContext> | ||
class PlayerOutlineGlowContext; | ||
|
||
template <typename HookContext> | ||
PlayerOutlineGlowToggle(HookContext&) -> PlayerOutlineGlowToggle<PlayerOutlineGlowContext<HookContext>>; |
26 changes: 26 additions & 0 deletions
26
Source/Features/Visuals/PlayerOutlineGlow/PlayerOutlineGlowUnloadHandler.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,26 @@ | ||
#pragma once | ||
|
||
#include <utility> | ||
|
||
#include "PlayerOutlineGlow.h" | ||
|
||
template <typename Context> | ||
class PlayerOutlineGlowUnloadHandler { | ||
public: | ||
template <typename... Args> | ||
PlayerOutlineGlowUnloadHandler(Args&&... args) noexcept | ||
: context{std::forward<Args>(args)...} | ||
{ | ||
} | ||
|
||
void handleUnload() const noexcept | ||
{ | ||
context.clearGlowSceneObjects(); | ||
} | ||
|
||
private: | ||
Context context; | ||
}; | ||
|
||
template <typename HookContext> | ||
PlayerOutlineGlowUnloadHandler(HookContext&) -> PlayerOutlineGlowUnloadHandler<PlayerOutlineGlowContext<HookContext>>; |
Oops, something went wrong.