VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
BoneFollow.cpp
Go to the documentation of this file.
2
3namespace VoltMod
4{
5
6void BoneFollow::Attach(const Pawn& pawn, const Entity& parent)
7{
8 // Attaching twice would capture the following collision as the one to give back.
9 if (_pawn || !pawn || !parent)
10 {
11 return;
12 }
13
14 const Schema::CCollisionProperty collision = pawn.Collision();
15 _mask = collision.CollisionAttribute().CollisionFunctionMask();
16 _surround = collision.SurroundType();
17 _pawn = pawn.Ref();
18 pawn.Follow(parent, true);
19 // Following makes traces pass through, as with worn gear.
21}
22
23void BoneFollow::Detach(const Pawn& pawn)
24{
25 if (!_pawn)
26 {
27 return;
28 }
29
30 if (pawn && pawn.Ref() == _pawn)
31 {
32 pawn.AcceptInput("ClearParent");
33 // ClearParent leaves the following collision behind.
34 const Schema::CCollisionProperty collision = pawn.Collision();
36 collision.SetSurroundType(_surround);
37 }
38 _pawn = {};
39}
40
41} // namespace VoltMod
void Detach(const Pawn &pawn)
void Attach(const Pawn &pawn, const Entity &parent)
Definition BoneFollow.cpp:6
A live entity, valid for this frame only.
Definition Entity.hpp:40
void Follow(const Entity &parent, bool copyBones) const
Definition Entity.cpp:215
void AcceptInput(std::string_view input, std::string_view value={}, const Entity &activator={}) const
Definition Entity.cpp:143
EntityRef Ref() const
Definition Entity.cpp:70
A player's body: health, armor, movement, aim, weapons. The engine replaces it on every spawn; the Co...
Definition Pawn.hpp:35
SurroundingBoundsType_t SurroundType() const
void SetSurroundType(SurroundingBoundsType_t value) const
VPhysicsCollisionAttribute_t CollisionAttribute() const