Skip to content

Commit

Permalink
Implement outline glow for dropped bomb
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkrupinski committed Sep 23, 2024
1 parent 543678a commit c16b7f1
Show file tree
Hide file tree
Showing 16 changed files with 181 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Source/CS2/Classes/Entities/WeaponEntities.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,8 @@ struct C_DecoyGrenade : C_CSWeaponBase {
static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_DecoyGrenade@@", "14C_DecoyGrenade")};
};

struct C_C4 : C_CSWeaponBase {
static constexpr auto kMangledTypeName{WIN64_LINUX(".?AVC_C4@@", "4C_C4")};
};

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <utility>

#include "DroppedBombOutlineGlowContext.h"
#include "DroppedBombOutlineGlowParams.h"

template <typename Context>
class DroppedBombOutlineGlow {
public:
template <typename... Args>
DroppedBombOutlineGlow(Args&&... args) noexcept
: context{std::forward<Args>(args)...}
{
}

void applyGlowToBomb(auto&& bomb) const noexcept
{
auto&& condition = context.condition();
if (!condition.shouldRun() || !condition.shouldGlowBomb(bomb))
return;

using namespace dropped_bomb_outline_glow_params;
bomb.applyGlowRecursively(kColor);
}

private:
Context context;
};

template <typename HookContext>
DroppedBombOutlineGlow(HookContext&) -> DroppedBombOutlineGlow<DroppedBombOutlineGlowContext<HookContext>>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <utility>

template <typename Context>
class DroppedBombOutlineGlowCondition {
public:
template <typename... Args>
DroppedBombOutlineGlowCondition(Args&&... args) noexcept
: context{std::forward<Args>(args)...}
{
}

[[nodiscard]] bool shouldRun() const noexcept
{
return context.state().enabled;
}

[[nodiscard]] bool shouldGlowBomb(auto&& bomb) const noexcept
{
return !bomb.hasOwner().valueOr(true);
}

private:
Context context;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "DroppedBombOutlineGlowCondition.h"

template <typename HookContext>
class DroppedBombOutlineGlowContext {
public:
explicit DroppedBombOutlineGlowContext(HookContext& hookContext) noexcept
: hookContext{hookContext}
{
}

[[nodiscard]] auto& state() const noexcept
{
return hookContext.featuresStates().visualFeaturesStates.droppedBombOutlineGlowState;
}

[[nodiscard]] decltype(auto) condition() const noexcept
{
return hookContext.template make<DroppedBombOutlineGlowCondition<DroppedBombOutlineGlowContext>>();
}

private:
HookContext& hookContext;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include <CS2/Classes/Color.h>

namespace dropped_bomb_outline_glow_params
{
constexpr cs2::Color kColor{255, 255, 128, 102};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

struct DroppedBombOutlineGlowState {
bool enabled{true};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <utility>

#include <FeatureHelpers/FeatureToggle.h>
#include "DroppedBombOutlineGlowContext.h"

template <typename Context>
class DroppedBombOutlineGlowToggle : public FeatureToggle<DroppedBombOutlineGlowToggle<Context>> {
public:
template <typename... Args>
DroppedBombOutlineGlowToggle(Args&&... args) noexcept
: context{std::forward<Args>(args)...}
{
}

[[nodiscard]] auto& enabledVariable(typename DroppedBombOutlineGlowToggle::ToggleMethod) const noexcept
{
return context.state().enabled;
}

private:
Context context;
};

template <typename HookContext>
DroppedBombOutlineGlowToggle(HookContext&) -> DroppedBombOutlineGlowToggle<DroppedBombOutlineGlowContext<HookContext>>;
2 changes: 2 additions & 0 deletions Source/Features/Visuals/OutlineGlow/OutlineGlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class OutlineGlow {
context.applyGlowToPlayer(entity);
else if (entityTypeInfo.typeIndex == utils::typeIndex<cs2::CBaseAnimGraph, KnownEntityTypes>())
context.applyGlowToDefuseKit(entity);
else if (entityTypeInfo.is<cs2::C_C4>())
context.applyGlowToBomb(entity);
else if (entityTypeInfo.isGrenadeProjectile())
context.applyGlowToGrenadeProjectile(entityTypeInfo, entity);
else if (entityTypeInfo.isWeapon())
Expand Down
6 changes: 6 additions & 0 deletions Source/Features/Visuals/OutlineGlow/OutlineGlowContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <OutlineGlow/GlowSceneObjects.h>

#include "DefuseKitOutlineGlow/DefuseKitOutlineGlow.h"
#include "DroppedBombOutlineGlow/DroppedBombOutlineGlow.h"
#include "GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlow.h"
#include "PlayerOutlineGlow/PlayerOutlineGlow.h"
#include "WeaponOutlineGlow/WeaponOutlineGlow.h"
Expand Down Expand Up @@ -40,6 +41,11 @@ class OutlineGlowContext {
{
hookContext.template make<GrenadeProjectileOutlineGlow>().applyGlowToGrenadeProjectile(entityTypeInfo, hookContext.template make<BaseEntity>(static_cast<cs2::C_BaseCSGrenadeProjectile*>(&entity)));
}

void applyGlowToBomb(auto& entity) const noexcept
{
hookContext.template make<DroppedBombOutlineGlow>().applyGlowToBomb(hookContext.template make<BaseEntity>(static_cast<cs2::C_C4*>(&entity)));
}

[[nodiscard]] auto& viewRenderHook() const noexcept
{
Expand Down
6 changes: 6 additions & 0 deletions Source/Features/Visuals/VisualFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <FeatureHelpers/FeatureHelpers.h>
#include "PlayerInformationThroughWalls/PlayerInformationThroughWalls.h"
#include "OutlineGlow/DefuseKitOutlineGlow/DefuseKitOutlineGlowToggle.h"
#include "OutlineGlow/DroppedBombOutlineGlow/DroppedBombOutlineGlowToggle.h"
#include "OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowToggle.h"
#include "OutlineGlow/PlayerOutlineGlow/PlayerOutlineGlowToggle.h"
#include "OutlineGlow/WeaponOutlineGlow/WeaponOutlineGlowToggle.h"
Expand Down Expand Up @@ -100,6 +101,11 @@ struct VisualFeatures {
return hookContext.template make<GrenadeProjectileOutlineGlowToggle>();
}

[[nodiscard]] decltype(auto) droppedBombOutlineGlowToggle() const noexcept
{
return hookContext.template make<DroppedBombOutlineGlowToggle>();
}

HookContext& hookContext;
VisualFeaturesStates& states;
ViewRenderHook& viewRenderHook;
Expand Down
2 changes: 2 additions & 0 deletions Source/Features/Visuals/VisualFeaturesStates.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "PlayerInformationThroughWalls/PlayerInformationThroughWallsState.h"
#include "OutlineGlow/DefuseKitOutlineGlow/DefuseKitOutlineGlowState.h"
#include "OutlineGlow/DroppedBombOutlineGlow/DroppedBombOutlineGlowState.h"
#include "OutlineGlow/GrenadeProjectileOutlineGlow/GrenadeProjectileOutlineGlowState.h"
#include "OutlineGlow/PlayerOutlineGlow/PlayerOutlineGlowState.h"
#include "OutlineGlow/WeaponOutlineGlow/WeaponOutlineGlowState.h"
Expand All @@ -14,4 +15,5 @@ struct VisualFeaturesStates {
WeaponOutlineGlowState weaponOutlineGlowState;
DefuseKitOutlineGlowState defuseKitOutlineGlowState;
GrenadeProjectileOutlineGlowState grenadeProjectileOutlineGlowState;
DroppedBombOutlineGlowState droppedBombOutlineGlowState;
};
4 changes: 3 additions & 1 deletion Source/GameDependencies/EntitiesVMTs.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ using KnownEntityTypes = std::tuple<
cs2::C_HEGrenadeProjectile,
cs2::C_SmokeGrenadeProjectile,
cs2::C_MolotovProjectile,
cs2::C_FlashbangProjectile
cs2::C_FlashbangProjectile,

cs2::C_C4
>;

struct EntitiesVMTs {
Expand Down
6 changes: 6 additions & 0 deletions Source/Osiris.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@
<ClInclude Include="Features\Visuals\OutlineGlow\DefuseKitOutlineGlow\DefuseKitOutlineGlowParams.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\DefuseKitOutlineGlow\DefuseKitOutlineGlowState.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\DefuseKitOutlineGlow\DefuseKitOutlineGlowToggle.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlow.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlowCondition.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlowContext.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlowParams.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlowState.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlowToggle.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\GrenadeProjectileOutlineGlow\GrenadeProjectileOutlineGlow.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\GrenadeProjectileOutlineGlow\GrenadeProjectileOutlineGlowCondition.h" />
<ClInclude Include="Features\Visuals\OutlineGlow\GrenadeProjectileOutlineGlow\GrenadeProjectileOutlineGlowContext.h" />
Expand Down
21 changes: 21 additions & 0 deletions Source/Osiris.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
<Filter Include="Features\Visuals\OutlineGlow\GrenadeProjectileOutlineGlow">
<UniqueIdentifier>{88aa3de7-03b7-49bc-a280-76714e28a62a}</UniqueIdentifier>
</Filter>
<Filter Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow">
<UniqueIdentifier>{4cacd578-512d-4917-912c-c98f07a6d19b}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="CS2\Classes\C_CSGameRules.h">
Expand Down Expand Up @@ -1529,6 +1532,24 @@
<ClInclude Include="Features\Visuals\OutlineGlow\GrenadeProjectileOutlineGlow\GrenadeProjectileOutlineGlowCondition.h">
<Filter>Features\Visuals\OutlineGlow\GrenadeProjectileOutlineGlow</Filter>
</ClInclude>
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlow.h">
<Filter>Features\Visuals\OutlineGlow\DroppedBombOutlineGlow</Filter>
</ClInclude>
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlowCondition.h">
<Filter>Features\Visuals\OutlineGlow\DroppedBombOutlineGlow</Filter>
</ClInclude>
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlowContext.h">
<Filter>Features\Visuals\OutlineGlow\DroppedBombOutlineGlow</Filter>
</ClInclude>
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlowParams.h">
<Filter>Features\Visuals\OutlineGlow\DroppedBombOutlineGlow</Filter>
</ClInclude>
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlowState.h">
<Filter>Features\Visuals\OutlineGlow\DroppedBombOutlineGlow</Filter>
</ClInclude>
<ClInclude Include="Features\Visuals\OutlineGlow\DroppedBombOutlineGlow\DroppedBombOutlineGlowToggle.h">
<Filter>Features\Visuals\OutlineGlow\DroppedBombOutlineGlow</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="UI\Panorama\CreateGUI.js">
Expand Down
9 changes: 6 additions & 3 deletions Source/UI/Panorama/CreateGUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,15 @@ $.Osiris = (function () {
var weaponOutlineGlow = createSection(outlineGlowTab, 'Weapon Outline Glow');
createYesNoDropDown(weaponOutlineGlow, "Glow Weapons on Ground Nearby", 'visuals', 'weapon_outline_glow', 0);

var defuseKitOutlineGlow = createSection(outlineGlowTab, 'Defuse Kit Outline Glow');
createYesNoDropDown(defuseKitOutlineGlow, "Glow Defuse Kits on Ground Nearby", 'visuals', 'defuse_kit_outline_glow', 0);

var grenadeProjectileOutlineGlow = createSection(outlineGlowTab, 'Grenade Projectile Outline Glow');
createYesNoDropDown(grenadeProjectileOutlineGlow, "Glow Grenade Projectiles", 'visuals', 'grenade_proj_outline_glow', 0);

var bombOutlineGlow = createSection(outlineGlowTab, 'Bomb Outline Glow');
createYesNoDropDown(bombOutlineGlow, "Glow Dropped Bomb", 'visuals', 'dropped_bomb_outline_glow', 0);

var defuseKitOutlineGlow = createSection(outlineGlowTab, 'Defuse Kit Outline Glow');
createYesNoDropDown(defuseKitOutlineGlow, "Glow Defuse Kits on Ground Nearby", 'visuals', 'defuse_kit_outline_glow', 0);

$.Osiris.navigateToSubTab('visuals', 'player_info');

var sound = createTab('sound');
Expand Down
2 changes: 2 additions & 0 deletions Source/UI/Panorama/SetCommandHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ struct SetCommandHandler {
handleTogglableFeature(features.visualFeatures().defuseKitOutlineGlowToggle());
} else if (feature == "grenade_proj_outline_glow") {
handleTogglableFeature(features.visualFeatures().grenadeProjectileOutlineGlowToggle());
} else if (feature == "dropped_bomb_outline_glow") {
handleTogglableFeature(features.visualFeatures().droppedBombOutlineGlowToggle());
}
}

Expand Down

0 comments on commit c16b7f1

Please sign in to comment.