|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <sourcepp/Math.h> |
| 4 | + |
| 5 | +namespace vmtpp { |
| 6 | + |
| 7 | +/// Expose an interface to read values from the entity the VMT is attached to for material proxies. |
| 8 | +class IEntityAccess { |
| 9 | +public: |
| 10 | + virtual ~IEntityAccess() = default; |
| 11 | + |
| 12 | + /// "The number of seconds the current map has been running on the server for." |
| 13 | + [[nodiscard]] virtual uint64_t getCurrentTime() const = 0; |
| 14 | + |
| 15 | + [[nodiscard]] virtual float getRenderAlpha() const = 0; |
| 16 | + |
| 17 | + [[nodiscard]] virtual float getAnimationProgress() const = 0; |
| 18 | + |
| 19 | + /// "The distance in units between the current player and the origin of the entity that the material is applied to." |
| 20 | + [[nodiscard]] virtual float getDistanceToCurrentPlayer() const = 0; |
| 21 | + |
| 22 | + [[nodiscard]] virtual int getCurrentPlayerTeam() const = 0; |
| 23 | + |
| 24 | + [[nodiscard]] virtual int getTeam() const = 0; |
| 25 | + |
| 26 | + /// "The dot product of the current player's view angle and the relative origin of the material's entity." |
| 27 | + [[nodiscard]] virtual float getCurrentPlayerViewDotProduct() const = 0; |
| 28 | + |
| 29 | + [[nodiscard]] virtual float getCurrentPlayerSpeed() const = 0; |
| 30 | + |
| 31 | + [[nodiscard]] virtual sourcepp::math::Vec3f getCurrentPlayerPosition() const = 0; |
| 32 | + |
| 33 | + [[nodiscard]] virtual float getSpeed() const = 0; |
| 34 | + |
| 35 | + [[nodiscard]] virtual sourcepp::math::Vec3f getOrigin() const = 0; |
| 36 | + |
| 37 | + /// "A static random number associated with the entity the material is applied to." |
| 38 | + [[nodiscard]] virtual float getRandomNumber() const = 0; |
| 39 | + |
| 40 | + [[nodiscard]] virtual float getHealth() const = 0; |
| 41 | + |
| 42 | + [[nodiscard]] virtual bool isNPC() const = 0; |
| 43 | + |
| 44 | + [[nodiscard]] virtual bool isViewModel() const = 0; |
| 45 | + |
| 46 | + [[nodiscard]] virtual sourcepp::math::Vec3f getWorldDimensionsMinimum() const = 0; |
| 47 | + |
| 48 | + [[nodiscard]] virtual sourcepp::math::Vec3f getWorldDimensionsMaximum() const = 0; |
| 49 | + |
| 50 | + [[nodiscard]] virtual sourcepp::math::Vec3f getCurrentPlayerCrosshairColor() const = 0; |
| 51 | +}; |
| 52 | + |
| 53 | +class EntityAccessEmpty : public IEntityAccess { |
| 54 | +public: |
| 55 | + EntityAccessEmpty(); |
| 56 | + |
| 57 | + [[nodiscard]] uint64_t getCurrentTime() const override; |
| 58 | + |
| 59 | + [[nodiscard]] float getRenderAlpha() const override; |
| 60 | + |
| 61 | + [[nodiscard]] float getAnimationProgress() const override; |
| 62 | + |
| 63 | + [[nodiscard]] float getDistanceToCurrentPlayer() const override; |
| 64 | + |
| 65 | + [[nodiscard]] int getCurrentPlayerTeam() const override; |
| 66 | + |
| 67 | + [[nodiscard]] int getTeam() const override; |
| 68 | + |
| 69 | + [[nodiscard]] float getCurrentPlayerViewDotProduct() const override; |
| 70 | + |
| 71 | + [[nodiscard]] float getCurrentPlayerSpeed() const override; |
| 72 | + |
| 73 | + [[nodiscard]] sourcepp::math::Vec3f getCurrentPlayerPosition() const override; |
| 74 | + |
| 75 | + [[nodiscard]] float getSpeed() const override; |
| 76 | + |
| 77 | + [[nodiscard]] sourcepp::math::Vec3f getOrigin() const override; |
| 78 | + |
| 79 | + [[nodiscard]] float getRandomNumber() const override; |
| 80 | + |
| 81 | + [[nodiscard]] float getHealth() const override; |
| 82 | + |
| 83 | + [[nodiscard]] bool isNPC() const override; |
| 84 | + |
| 85 | + [[nodiscard]] bool isViewModel() const override; |
| 86 | + |
| 87 | + [[nodiscard]] sourcepp::math::Vec3f getWorldDimensionsMinimum() const override; |
| 88 | + |
| 89 | + [[nodiscard]] sourcepp::math::Vec3f getWorldDimensionsMaximum() const override; |
| 90 | + |
| 91 | + [[nodiscard]] sourcepp::math::Vec3f getCurrentPlayerCrosshairColor() const override; |
| 92 | + |
| 93 | +private: |
| 94 | + float random; |
| 95 | +}; |
| 96 | + |
| 97 | +} // namespace vmtpp |
0 commit comments