Skip to content

Commit

Permalink
Final adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkrupinski committed Aug 31, 2024
1 parent 0effd93 commit 27f5914
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 90 deletions.
8 changes: 5 additions & 3 deletions Source/CS2/Classes/CRenderComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

namespace cs2
{
struct CRenderComponent {
using sceneObjectUpdaters = cs2::CUtlVector<SceneObjectUpdaterHandle_t*>;
};

struct CRenderComponent {
using sceneObjectUpdaters = cs2::CUtlVector<SceneObjectUpdaterHandle_t*>;
};

}
47 changes: 4 additions & 43 deletions Source/Features/Visuals/PlayerOutlineGlow/PlayerOutlineGlow.h
Original file line number Diff line number Diff line change
@@ -1,49 +1,10 @@
#pragma once

#include <OutlineGlow/GlowSceneObjects.h>
#include "PlayerOutlineGlowCondition.h"
#include <utility>

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;
};
#include <CS2/Constants/ColorConstants.h>
#include <FeatureHelpers/TeamNumber.h>
#include "PlayerOutlineGlowContext.h"

template <typename Context>
class PlayerOutlineGlow {
Expand Down
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;
};
14 changes: 14 additions & 0 deletions Source/Osiris.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,19 @@
<ClInclude Include="Features\Visuals\PlayerInformationThroughWalls\PlayerStateIcons\PlayerStateIconsToShow.h" />
<ClInclude Include="Features\Visuals\PlayerOutlineGlow\PlayerOutlineGlow.h" />
<ClInclude Include="Features\Visuals\PlayerOutlineGlow\PlayerOutlineGlowCondition.h" />
<ClInclude Include="Features\Visuals\PlayerOutlineGlow\PlayerOutlineGlowContext.h" />
<ClInclude Include="Features\Visuals\PlayerOutlineGlow\PlayerOutlineGlowState.h" />
<ClInclude Include="Features\Visuals\PlayerOutlineGlow\PlayerOutlineGlowToggle.h" />
<ClInclude Include="Features\Visuals\PlayerOutlineGlow\PlayerOutlineGlowUnloadHandler.h" />
<ClInclude Include="Features\Visuals\VisualFeatures.h" />
<ClInclude Include="Features\Visuals\VisualFeaturesStates.h" />
<ClInclude Include="FileUtils\FileSlice.h" />
<ClInclude Include="GameClasses\BaseEntity.h" />
<ClInclude Include="GameClasses\ClientPanel.h" />
<ClInclude Include="GameClasses\Hud\HudContext.h" />
<ClInclude Include="GameClasses\OffsetTypes\GlowSceneObjectOffset.h" />
<ClInclude Include="GameClasses\OffsetTypes\RenderComponentOffset.h" />
<ClInclude Include="GameClasses\OffsetTypes\SceneObjectUpdaterOffset.h" />
<ClInclude Include="GameClasses\PlayerController.h" />
<ClInclude Include="GameClasses\FileNameSymbolTable.h" />
<ClInclude Include="GameClasses\FileSystem.h" />
Expand Down Expand Up @@ -233,6 +238,8 @@
<ClInclude Include="GameClasses\PlantedC4.h" />
<ClInclude Include="GameClasses\PlayerPawn.h" />
<ClInclude Include="GameClasses\RenderComponent.h" />
<ClInclude Include="GameClasses\SceneObjectUpdater.h" />
<ClInclude Include="GameClasses\SceneObjectUpdaters.h" />
<ClInclude Include="GameClasses\SceneSystem.h" />
<ClInclude Include="GameClasses\TopLevelWindow.h" />
<ClInclude Include="GameDependencies\ConVarDeps.h" />
Expand All @@ -249,6 +256,7 @@
<ClInclude Include="GameDependencies\GameRulesDeps.h" />
<ClInclude Include="GameDependencies\GameSceneNodeDeps.h" />
<ClInclude Include="GameDependencies\GlobalVarsDeps.h" />
<ClInclude Include="GameDependencies\GlowSceneObjectDeps.h" />
<ClInclude Include="GameDependencies\HostageServicesDeps.h" />
<ClInclude Include="GameDependencies\HudDeps.h" />
<ClInclude Include="GameDependencies\MemAllocDeps.h" />
Expand All @@ -262,6 +270,8 @@
<ClInclude Include="GameDependencies\PlayerControllerDeps.h" />
<ClInclude Include="GameDependencies\PlayerPawnDeps.h" />
<ClInclude Include="GameDependencies\RenderComponentDeps.h" />
<ClInclude Include="GameDependencies\SceneObjectUpdaterDeps.h" />
<ClInclude Include="GameDependencies\SceneSystemDeps.h" />
<ClInclude Include="GameDependencies\TopLevelWindowDeps.h" />
<ClInclude Include="GameDependencies\WeaponDeps.h" />
<ClInclude Include="GameDependencies\WeaponServicesDeps.h" />
Expand Down Expand Up @@ -306,6 +316,7 @@
<ClInclude Include="MemoryPatterns\Windows\FileSystemPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\GameRulesPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\GameSceneNodePatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\GlowSceneObjectPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\HostageServicesPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\MemAllocPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\PanelPatternsWindows.h" />
Expand All @@ -318,6 +329,8 @@
<ClInclude Include="MemoryPatterns\Windows\PlayerControllerPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\PlayerPawnPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\RenderComponentPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\SceneObjectUpdaterPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\SceneSystemPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\SdlPatternWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\SoundSystemPatternsWindows.h" />
<ClInclude Include="MemoryPatterns\Windows\TopLevelWindowPatternsWindows.h" />
Expand All @@ -337,6 +350,7 @@
<ClInclude Include="MemorySearch\PatternStringWildcard.h" />
<ClInclude Include="MemorySearch\BytePatternView.h" />
<ClInclude Include="OutlineGlow\GlowSceneObject.h" />
<ClInclude Include="OutlineGlow\GlowSceneObjectContext.h" />
<ClInclude Include="OutlineGlow\GlowSceneObjectPointer.h" />
<ClInclude Include="OutlineGlow\GlowSceneObjects.h" />
<ClInclude Include="OutlineGlow\GlowSceneObjectsState.h" />
Expand Down
42 changes: 42 additions & 0 deletions Source/Osiris.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1373,6 +1373,48 @@
<ClInclude Include="Features\Visuals\PlayerOutlineGlow\PlayerOutlineGlowUnloadHandler.h">
<Filter>Features\Visuals\PlayerOutlineGlow</Filter>
</ClInclude>
<ClInclude Include="Features\Visuals\PlayerOutlineGlow\PlayerOutlineGlowContext.h">
<Filter>Features\Visuals\PlayerOutlineGlow</Filter>
</ClInclude>
<ClInclude Include="GameClasses\BaseEntity.h">
<Filter>GameClasses</Filter>
</ClInclude>
<ClInclude Include="GameClasses\OffsetTypes\GlowSceneObjectOffset.h">
<Filter>GameClasses\OffsetTypes</Filter>
</ClInclude>
<ClInclude Include="GameClasses\OffsetTypes\RenderComponentOffset.h">
<Filter>GameClasses\OffsetTypes</Filter>
</ClInclude>
<ClInclude Include="GameClasses\OffsetTypes\SceneObjectUpdaterOffset.h">
<Filter>GameClasses\OffsetTypes</Filter>
</ClInclude>
<ClInclude Include="GameClasses\SceneObjectUpdater.h">
<Filter>GameClasses</Filter>
</ClInclude>
<ClInclude Include="GameClasses\SceneObjectUpdaters.h">
<Filter>GameClasses</Filter>
</ClInclude>
<ClInclude Include="GameDependencies\GlowSceneObjectDeps.h">
<Filter>GameDependencies</Filter>
</ClInclude>
<ClInclude Include="GameDependencies\SceneObjectUpdaterDeps.h">
<Filter>GameDependencies</Filter>
</ClInclude>
<ClInclude Include="GameDependencies\SceneSystemDeps.h">
<Filter>GameDependencies</Filter>
</ClInclude>
<ClInclude Include="MemoryPatterns\Windows\GlowSceneObjectPatternsWindows.h">
<Filter>MemoryPatterns\Windows</Filter>
</ClInclude>
<ClInclude Include="MemoryPatterns\Windows\SceneObjectUpdaterPatternsWindows.h">
<Filter>MemoryPatterns\Windows</Filter>
</ClInclude>
<ClInclude Include="MemoryPatterns\Windows\SceneSystemPatternsWindows.h">
<Filter>MemoryPatterns\Windows</Filter>
</ClInclude>
<ClInclude Include="OutlineGlow\GlowSceneObjectContext.h">
<Filter>OutlineGlow</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="UI\Panorama\CreateGUI.js">
Expand Down
46 changes: 2 additions & 44 deletions Source/OutlineGlow/GlowSceneObject.h
Original file line number Diff line number Diff line change
@@ -1,50 +1,8 @@
#pragma once

#include "GlowSceneObjectPointer.h"
#include <utility>

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;
};
#include "GlowSceneObjectContext.h"

template <typename Context>
class GlowSceneObject {
Expand Down
51 changes: 51 additions & 0 deletions Source/OutlineGlow/GlowSceneObjectContext.h
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;
};

0 comments on commit 27f5914

Please sign in to comment.