|
Botcraft 26.3
|
#include <PhysicsManager.hpp>
Public Member Functions | |
| PhysicsManager ()=delete | |
| PhysicsManager (const std::shared_ptr< InventoryManager > &inventory_manager_, const std::shared_ptr< EntityManager > &entity_manager_, const std::shared_ptr< NetworkManager > &network_manager_, const std::shared_ptr< World > &world_) | |
| ~PhysicsManager () | |
| void | StartPhysics () |
| void | StopPhysics () |
| void | SetDoubleTapCauseSprint (const bool b) |
| Enable/disable auto triggering of sprint when press/unpress/press forward key in less than 7 ticks (enabled by default) | |
| double | GetMsPerTick () const |
Protected Member Functions | |
| virtual void | Handle (ProtocolCraft::ClientboundPlayerPositionPacket &packet) override |
| virtual void | Handle (ProtocolCraft::ClientboundTickingStatePacket &packet) override |
| virtual void | Handle (ProtocolCraft::ClientboundPlayerRotationPacket &packet) override |
Private Member Functions | |
| void | Physics () |
| void | PhysicsTick () |
| Follow minecraft physics related flow in LocalPlayer tick function. | |
| void | UpdateSwimming () const |
| void | FluidPhysics (const bool water) |
| Perform fluid physics on the player, and set in_water/lava boolean accordingly. | |
| void | InputsToCrouch () const |
| void | InputsToSprint () const |
| void | SetSprinting (const bool b) const |
| void | InputsToFly () const |
| void | InputsToJump () const |
| void | JumpFromGround () const |
| void | ApplyInputs (const float strength) const |
| void | SendPosition () |
| Send position/rotation/on_ground to server. | |
| Vector3< double > | CollideBoundingBox (const AABB &aabb, const Vector3< double > &movement) const |
| Check collisions of an AABB with a given movement. | |
| void | CollideOneAxis (AABB &aabb, Vector3< double > &movement, const unsigned int axis, const std::vector< AABB > &colliders) const |
| bool | IsSwimmingAndNotFlying () const |
| bool | IsInClimbable () const |
| void | MovePlayer () const |
| void | ApplyMovement () const |
| void | OnUpdateAbilities () const |
| void | CheckInsideBlocks () const |
| Position | GetBlockBelowAffectingMovement () const |
Private Attributes | |
| std::shared_ptr< EntityManager > | entity_manager |
| std::shared_ptr< InventoryManager > | inventory_manager |
| std::shared_ptr< LocalPlayer > | player |
| std::shared_ptr< NetworkManager > | network_manager |
| std::shared_ptr< World > | world |
| std::atomic< bool > | should_run |
| int | ticks_since_last_position_sent |
| std::thread | thread_physics |
| const Item * | elytra_item |
| std::atomic< double > | ms_per_tick = 50.0 |
| std::atomic< bool > | double_tap_cause_sprint |
Definition at line 22 of file PhysicsManager.hpp.
|
delete |
| Botcraft::PhysicsManager::PhysicsManager | ( | const std::shared_ptr< InventoryManager > & | inventory_manager_, |
| const std::shared_ptr< EntityManager > & | entity_manager_, | ||
| const std::shared_ptr< NetworkManager > & | network_manager_, | ||
| const std::shared_ptr< World > & | world_ | ||
| ) |
Definition at line 22 of file PhysicsManager.cpp.
References double_tap_cause_sprint, elytra_item, entity_manager, Botcraft::AssetsManager::getInstance(), Botcraft::AssetsManager::GetItem(), inventory_manager, network_manager, player, should_run, ticks_since_last_position_sent, and world.
| Botcraft::PhysicsManager::~PhysicsManager | ( | ) |
Definition at line 45 of file PhysicsManager.cpp.
References StopPhysics().
|
private |
Definition at line 927 of file PhysicsManager.cpp.
References CosLUT(), Botcraft::Vector3< T >::Normalize(), player, SinLUT(), Botcraft::Vector3< T >::SqrNorm(), Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
Referenced by MovePlayer().
|
private |
Definition at line 1366 of file PhysicsManager.cpp.
References Botcraft::Vector3< T >::Abs(), CheckInsideBlocks(), CollideBoundingBox(), GetBlockBelowAffectingMovement(), Botcraft::AABB::GetCenter(), Botcraft::Utilities::GetEnchantmentLvl(), Botcraft::AABB::GetHalfSize(), Botcraft::Window::INVENTORY_FEET_ARMOR, inventory_manager, Botcraft::Blockstate::IsBed(), Botcraft::Blockstate::IsHoney(), Botcraft::Blockstate::IsShelfMushroom(), Botcraft::Blockstate::IsSlime(), Botcraft::Blockstate::IsSoulSand(), player, Botcraft::SlowFalling, Botcraft::SoulSpeed, Botcraft::Spectator, Botcraft::Vector3< T >::SqrNorm(), world, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
Referenced by MovePlayer().
|
private |
Definition at line 1633 of file PhysicsManager.cpp.
References Botcraft::AABB::GetMax(), Botcraft::AABB::GetMin(), Botcraft::AABB::Inflate(), Botcraft::Blockstate::IsAir(), Botcraft::Blockstate::IsBerryBush(), Botcraft::Blockstate::IsBubbleColumn(), Botcraft::Blockstate::IsCobweb(), Botcraft::Blockstate::IsDownBubbleColumn(), Botcraft::Blockstate::IsHoney(), Botcraft::Blockstate::IsPowderSnow(), player, world, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
Referenced by ApplyMovement().
|
private |
Check collisions of an AABB with a given movement.
Definition at line 1082 of file PhysicsManager.cpp.
References CollideOneAxis(), world, Botcraft::Vector3< T >::x, and Botcraft::Vector3< T >::z.
Referenced by ApplyMovement().
|
private |
Definition at line 1113 of file PhysicsManager.cpp.
References Botcraft::AABB::GetMax(), Botcraft::AABB::GetMin(), and Botcraft::AABB::Translate().
Referenced by CollideBoundingBox().
|
private |
Perform fluid physics on the player, and set in_water/lava boolean accordingly.
| water | If true, will push with water, lava otherwise |
Definition at line 529 of file PhysicsManager.cpp.
References Botcraft::Blockstate::GetFluidHeight(), Botcraft::AABB::GetMax(), Botcraft::AABB::GetMin(), Botcraft::AABB::Inflate(), Botcraft::Blockstate::IsFluid(), Botcraft::Blockstate::IsLava(), Botcraft::Blockstate::IsWater(), player, Botcraft::Vector3< T >::SqrNorm(), world, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
Referenced by PhysicsTick().
|
private |
Definition at line 1709 of file PhysicsManager.cpp.
References player, and Botcraft::Vector3< T >::y.
Referenced by ApplyMovement(), JumpFromGround(), and MovePlayer().
| double Botcraft::PhysicsManager::GetMsPerTick | ( | ) | const |
Definition at line 79 of file PhysicsManager.cpp.
References ms_per_tick.
|
overrideprotectedvirtual |
Definition at line 85 of file PhysicsManager.cpp.
References entity_manager, LOG_WARNING, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
|
overrideprotectedvirtual |
Definition at line 192 of file PhysicsManager.cpp.
References entity_manager, and LOG_WARNING.
|
overrideprotectedvirtual |
Definition at line 176 of file PhysicsManager.cpp.
References ms_per_tick.
|
private |
Definition at line 640 of file PhysicsManager.cpp.
References Botcraft::Blindness, Botcraft::Crouching, Botcraft::FallFlying, Botcraft::Utilities::GetEnchantmentLvl(), Botcraft::Window::INVENTORY_LEGS_ARMOR, inventory_manager, IsSwimmingAndNotFlying(), player, SetSprinting(), Botcraft::Standing, Botcraft::SwiftSneak, Botcraft::Swimming, and world.
Referenced by PhysicsTick().
|
private |
Definition at line 784 of file PhysicsManager.cpp.
References elytra_item, Botcraft::FallFlying, Botcraft::Utilities::GetDamageCount(), Botcraft::Item::GetId(), Botcraft::Item::GetMaxDurability(), Botcraft::Window::INVENTORY_CHEST_ARMOR, inventory_manager, ProtocolCraft::Slot::IsEmptySlot(), IsSwimmingAndNotFlying(), JumpFromGround(), Botcraft::Levitation, network_manager, OnUpdateAbilities(), player, Botcraft::Spectator, and Botcraft::StartFallFlying.
Referenced by PhysicsTick().
|
private |
Definition at line 853 of file PhysicsManager.cpp.
References JumpFromGround(), and player.
Referenced by PhysicsTick().
|
private |
Definition at line 696 of file PhysicsManager.cpp.
References Botcraft::Blindness, double_tap_cause_sprint, Botcraft::FallFlying, IsSwimmingAndNotFlying(), player, SetSprinting(), Botcraft::Sprinting, and Botcraft::Swimming.
Referenced by PhysicsTick().
|
private |
Definition at line 1155 of file PhysicsManager.cpp.
References Botcraft::Blockstate::IsClimbable(), player, Botcraft::Spectator, and world.
Referenced by PhysicsTick().
|
private |
Definition at line 1148 of file PhysicsManager.cpp.
References player, Botcraft::Spectator, and Botcraft::Swimming.
Referenced by InputsToCrouch(), InputsToFly(), InputsToSprint(), and PhysicsTick().
|
private |
Definition at line 875 of file PhysicsManager.cpp.
References CosLUT(), GetBlockBelowAffectingMovement(), Botcraft::Blockstate::IsHoney(), Botcraft::JumpBoost, player, SinLUT(), Botcraft::Sprinting, and world.
Referenced by InputsToFly(), and InputsToJump().
|
private |
Definition at line 1169 of file PhysicsManager.cpp.
References ApplyInputs(), ApplyMovement(), Botcraft::DepthStrider, Botcraft::DolphinsGrace, Botcraft::FallFlying, GetBlockBelowAffectingMovement(), Botcraft::Utilities::GetEnchantmentLvl(), Botcraft::Blockstate::GetFriction(), Botcraft::Window::INVENTORY_FEET_ARMOR, inventory_manager, Botcraft::Blockstate::IsScaffolding(), Botcraft::Levitation, player, Botcraft::SlowFalling, Botcraft::Sprinting, world, Botcraft::Vector3< T >::x, Botcraft::Vector3< T >::y, and Botcraft::Vector3< T >::z.
Referenced by PhysicsTick().
|
private |
Definition at line 1621 of file PhysicsManager.cpp.
References network_manager, and player.
Referenced by InputsToFly(), and PhysicsTick().
|
private |
Definition at line 214 of file PhysicsManager.cpp.
References entity_manager, Botcraft::Logger::GetInstance(), ms_per_tick, network_manager, PhysicsTick(), player, Botcraft::Logger::RegisterThread(), should_run, and Botcraft::Utilities::SleepUntil().
Referenced by StartPhysics().
|
private |
Follow minecraft physics related flow in LocalPlayer tick function.
Definition at line 289 of file PhysicsManager.cpp.
References Botcraft::Crouching, entity_manager, Botcraft::FallFlying, Botcraft::FireworkRocketEntity, FluidPhysics(), InputsToCrouch(), InputsToFly(), InputsToJump(), InputsToSprint(), Botcraft::Blockstate::IsFluid(), IsInClimbable(), IsSwimmingAndNotFlying(), MovePlayer(), OnUpdateAbilities(), player, SendPosition(), Botcraft::Sleeping, Botcraft::Spectator, Botcraft::SpinAttack, Botcraft::Standing, Botcraft::Swimming, Botcraft::Vector3< T >::ToBlockPos(), UpdateSwimming(), and world.
Referenced by Physics().
|
private |
Send position/rotation/on_ground to server.
Definition at line 948 of file PhysicsManager.cpp.
References network_manager, player, Botcraft::Sprinting, Botcraft::StartSprinting, Botcraft::StopSprinting, and ticks_since_last_position_sent.
Referenced by PhysicsTick().
| void Botcraft::PhysicsManager::SetDoubleTapCauseSprint | ( | const bool | b | ) |
Enable/disable auto triggering of sprint when press/unpress/press forward key in less than 7 ticks (enabled by default)
| b | Double tap will start sprinting if b is true |
Definition at line 67 of file PhysicsManager.cpp.
References double_tap_cause_sprint, and entity_manager.
|
private |
Definition at line 769 of file PhysicsManager.cpp.
References Botcraft::EntityAttribute::MovementSpeed, Botcraft::EntityAttribute::Modifier::MultiplyTotal, player, Botcraft::LivingEntity::speed_modifier_sprinting_key, and Botcraft::Sprinting.
Referenced by InputsToCrouch(), and InputsToSprint().
| void Botcraft::PhysicsManager::StartPhysics | ( | ) |
Definition at line 50 of file PhysicsManager.cpp.
References Physics(), should_run, and thread_physics.
| void Botcraft::PhysicsManager::StopPhysics | ( | ) |
Definition at line 58 of file PhysicsManager.cpp.
References should_run, and thread_physics.
Referenced by ~PhysicsManager().
|
private |
Definition at line 503 of file PhysicsManager.cpp.
References Botcraft::Blockstate::IsWater(), player, Botcraft::Sprinting, Botcraft::Swimming, and world.
Referenced by PhysicsTick().
|
private |
Definition at line 110 of file PhysicsManager.hpp.
Referenced by InputsToSprint(), PhysicsManager(), and SetDoubleTapCauseSprint().
|
private |
Definition at line 102 of file PhysicsManager.hpp.
Referenced by InputsToFly(), and PhysicsManager().
|
private |
Definition at line 90 of file PhysicsManager.hpp.
Referenced by Handle(), Handle(), Physics(), PhysicsManager(), PhysicsTick(), and SetDoubleTapCauseSprint().
|
private |
Definition at line 91 of file PhysicsManager.hpp.
Referenced by ApplyMovement(), InputsToCrouch(), InputsToFly(), MovePlayer(), and PhysicsManager().
|
private |
Definition at line 105 of file PhysicsManager.hpp.
Referenced by GetMsPerTick(), Handle(), and Physics().
|
private |
Definition at line 93 of file PhysicsManager.hpp.
Referenced by InputsToFly(), OnUpdateAbilities(), Physics(), PhysicsManager(), and SendPosition().
|
private |
Definition at line 92 of file PhysicsManager.hpp.
Referenced by ApplyInputs(), ApplyMovement(), CheckInsideBlocks(), FluidPhysics(), GetBlockBelowAffectingMovement(), InputsToCrouch(), InputsToFly(), InputsToJump(), InputsToSprint(), IsInClimbable(), IsSwimmingAndNotFlying(), JumpFromGround(), MovePlayer(), OnUpdateAbilities(), Physics(), PhysicsManager(), PhysicsTick(), SendPosition(), SetSprinting(), and UpdateSwimming().
|
private |
Definition at line 96 of file PhysicsManager.hpp.
Referenced by Physics(), PhysicsManager(), StartPhysics(), and StopPhysics().
|
private |
Definition at line 100 of file PhysicsManager.hpp.
Referenced by StartPhysics(), and StopPhysics().
|
private |
Definition at line 98 of file PhysicsManager.hpp.
Referenced by PhysicsManager(), and SendPosition().
|
private |
Definition at line 94 of file PhysicsManager.hpp.
Referenced by ApplyMovement(), CheckInsideBlocks(), CollideBoundingBox(), FluidPhysics(), InputsToCrouch(), IsInClimbable(), JumpFromGround(), MovePlayer(), PhysicsManager(), PhysicsTick(), and UpdateSwimming().