From 6b46d9a9ddca8268d939fd543291362344a5081a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Krupi=C5=84ski?= Date: Thu, 23 Jan 2025 22:28:04 +0100 Subject: [PATCH] Implement player model glow preview (#4390) --- .../Classes/Entities/C_CSGO_PreviewPlayer.h | 11 ++ Source/CS2/Constants/EntityClasses.h | 4 +- .../CS2/Panorama/CUI_MapPlayerPreviewPanel.h | 15 ++ Source/Entities/BaseEntity.h | 19 +- Source/Entities/BaseWeapon.h | 2 + Source/Entities/C4.h | 1 + Source/Entities/GlowProperty.h | 1 + Source/Entities/HostageServices.h | 1 + Source/Entities/PlantedC4.h | 2 + Source/Entities/PlayerController.h | 5 + Source/Entities/PlayerPawn.h | 10 + Source/Entities/PreviewPlayer.h | 30 +++ Source/Entities/RenderComponent.h | 1 + Source/Entities/WeaponServices.h | 1 + .../FeatureHelpers/RenderingHookEntityLoop.h | 1 - Source/Features/Visuals/ModelGlow/ModelGlow.h | 6 + .../Visuals/ModelGlow/ModelGlowState.h | 1 + .../PlayerModelGlow/PlayerModelGlow.h | 48 ++++- .../Preview/BaseEntityForModelGlowPreview.h | 24 +++ .../PlayerControllerForModelGlowPreview.h | 21 ++ .../Preview/PlayerModelGlowPreview.h | 182 ++++++++++++++++++ .../Preview/PlayerModelGlowPreviewColorMode.h | 8 + .../Preview/PlayerModelGlowPreviewParams.h | 26 +++ .../Preview/PlayerModelGlowPreviewState.h | 17 ++ .../Preview/PlayerPawnForModelGlowPreview.h | 92 +++++++++ Source/GameClasses/EntityIdentity.h | 38 ++++ Source/GameClasses/EntitySystem.h | 41 ++-- Source/GameClasses/GameSceneNode.h | 1 + Source/GameClasses/GlobalVars.h | 1 + Source/GameClasses/MapPlayerPreviewPanel.h | 35 ++++ Source/GameClasses/SceneObjectAttributes.h | 2 + Source/GameClasses/SceneObjectUpdater.h | 2 + Source/GameClasses/SceneSystem.h | 2 + Source/GlobalContext/FullGlobalContext.h | 2 + Source/GlobalContext/GlobalContext.h | 15 +- Source/HookDependencies/HookDependencies.h | 5 + Source/MemoryPatterns/Linux/LinuxPatterns.h | 1 + .../MapPlayerPreviewPanelPatternsLinux.h | 12 ++ Source/MemoryPatterns/MemoryPatterns.h | 1 + .../MapPlayerPreviewPanelPatternTypes.h | 15 ++ .../MapPlayerPreviewPanelPatternsWindows.h | 12 ++ .../MemoryPatterns/Windows/WindowsPatterns.h | 1 + Source/Osiris.vcxproj | 14 ++ Source/Osiris.vcxproj.filters | 45 +++++ Source/OutlineGlow/GlowSceneObjectContext.h | 1 + Source/UI/Panorama/CreateGUI.js | 36 +++- Source/UI/Panorama/PanoramaGUI.h | 82 +++++++- Source/UI/Panorama/PanoramaGuiState.h | 2 + Source/Utils/Optional.h | 1 + 49 files changed, 864 insertions(+), 32 deletions(-) create mode 100644 Source/CS2/Classes/Entities/C_CSGO_PreviewPlayer.h create mode 100644 Source/CS2/Panorama/CUI_MapPlayerPreviewPanel.h create mode 100644 Source/Entities/PreviewPlayer.h create mode 100644 Source/Features/Visuals/ModelGlow/Preview/BaseEntityForModelGlowPreview.h create mode 100644 Source/Features/Visuals/ModelGlow/Preview/PlayerControllerForModelGlowPreview.h create mode 100644 Source/Features/Visuals/ModelGlow/Preview/PlayerModelGlowPreview.h create mode 100644 Source/Features/Visuals/ModelGlow/Preview/PlayerModelGlowPreviewColorMode.h create mode 100644 Source/Features/Visuals/ModelGlow/Preview/PlayerModelGlowPreviewParams.h create mode 100644 Source/Features/Visuals/ModelGlow/Preview/PlayerModelGlowPreviewState.h create mode 100644 Source/Features/Visuals/ModelGlow/Preview/PlayerPawnForModelGlowPreview.h create mode 100644 Source/GameClasses/EntityIdentity.h create mode 100644 Source/GameClasses/MapPlayerPreviewPanel.h create mode 100644 Source/MemoryPatterns/Linux/MapPlayerPreviewPanelPatternsLinux.h create mode 100644 Source/MemoryPatterns/PatternTypes/MapPlayerPreviewPanelPatternTypes.h create mode 100644 Source/MemoryPatterns/Windows/MapPlayerPreviewPanelPatternsWindows.h diff --git a/Source/CS2/Classes/Entities/C_CSGO_PreviewPlayer.h b/Source/CS2/Classes/Entities/C_CSGO_PreviewPlayer.h new file mode 100644 index 00000000000..c703f663902 --- /dev/null +++ b/Source/CS2/Classes/Entities/C_CSGO_PreviewPlayer.h @@ -0,0 +1,11 @@ +#pragma once + +#include "C_CSPlayerPawn.h" + +namespace cs2 +{ + +struct C_CSGO_PreviewPlayer : C_CSPlayerPawn { +}; + +} diff --git a/Source/CS2/Constants/EntityClasses.h b/Source/CS2/Constants/EntityClasses.h index db02fce3036..9f27f160e23 100644 --- a/Source/CS2/Constants/EntityClasses.h +++ b/Source/CS2/Constants/EntityClasses.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -58,7 +59,8 @@ constexpr auto kEntityClassNames = TypedStaticStringPool{} .add("C_C4") .add("C_PlantedC4") .add("C_Hostage") - .add("C_Item_Healthshot"); + .add("C_Item_Healthshot") + .add("C_CSGO_PreviewPlayer"); using EntityClasses = decltype(kEntityClassNames)::TypeList; diff --git a/Source/CS2/Panorama/CUI_MapPlayerPreviewPanel.h b/Source/CS2/Panorama/CUI_MapPlayerPreviewPanel.h new file mode 100644 index 00000000000..e77437fd7b2 --- /dev/null +++ b/Source/CS2/Panorama/CUI_MapPlayerPreviewPanel.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +#include "CPanel2D.h" + +namespace cs2 +{ + +struct CUI_MapPlayerPreviewPanel : CPanel2D { + using EntityHandles = CUtlVector; +}; + +} diff --git a/Source/Entities/BaseEntity.h b/Source/Entities/BaseEntity.h index 9230c61569a..3e8de18dba0 100644 --- a/Source/Entities/BaseEntity.h +++ b/Source/Entities/BaseEntity.h @@ -5,8 +5,10 @@ #include #include #include +#include #include +#include #include #include "RenderComponent.h" @@ -24,17 +26,20 @@ class BaseEntity { return *this; } - [[nodiscard]] EntityTypeInfo classify() const noexcept + [[nodiscard]] decltype(auto) entityIdentity() const noexcept { - if (entity) - return hookContext.entityClassifier().classifyEntity(entity->identity->entityClass); - return {}; + return hookContext.template make(entity ? entity->identity : nullptr); + } + + [[nodiscard]] decltype(auto) classify() const noexcept + { + return entityIdentity().classify(); } - template