mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 06:57:28 +00:00
fix: controllable physics prediction
This commit is contained in:
parent
0ddd20e2b5
commit
1e9d7a20e6
@ -68,7 +68,10 @@ ControllablePhysicsComponent::~ControllablePhysicsComponent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::Update(float deltaTime) {
|
void ControllablePhysicsComponent::Update(float deltaTime) {
|
||||||
|
if (m_Static || m_Velocity == NiPoint3::ZERO) return;
|
||||||
|
m_Position += m_Velocity * deltaTime;
|
||||||
|
m_DirtyPosition = true;
|
||||||
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
|
void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
|
||||||
@ -101,14 +104,14 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
outBitStream->Write(m_GravityScale);
|
outBitStream->Write(m_GravityScale);
|
||||||
outBitStream->Write(m_SpeedMultiplier);
|
outBitStream->Write(m_SpeedMultiplier);
|
||||||
|
|
||||||
m_DirtyCheats = false;
|
if (!bIsInitialUpdate) m_DirtyCheats = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
outBitStream->Write(m_DirtyEquippedItemInfo);
|
outBitStream->Write(m_DirtyEquippedItemInfo);
|
||||||
if (m_DirtyEquippedItemInfo) {
|
if (m_DirtyEquippedItemInfo) {
|
||||||
outBitStream->Write(m_PickupRadius);
|
outBitStream->Write(m_PickupRadius);
|
||||||
outBitStream->Write(m_InJetpackMode);
|
outBitStream->Write(m_InJetpackMode);
|
||||||
m_DirtyEquippedItemInfo = false;
|
if (!bIsInitialUpdate) m_DirtyEquippedItemInfo = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
outBitStream->Write(m_DirtyBubble);
|
outBitStream->Write(m_DirtyBubble);
|
||||||
@ -118,7 +121,7 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
outBitStream->Write(m_BubbleType);
|
outBitStream->Write(m_BubbleType);
|
||||||
outBitStream->Write(m_SpecialAnims);
|
outBitStream->Write(m_SpecialAnims);
|
||||||
}
|
}
|
||||||
m_DirtyBubble = false;
|
if (!bIsInitialUpdate) m_DirtyBubble = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
outBitStream->Write(m_DirtyPosition || bIsInitialUpdate);
|
outBitStream->Write(m_DirtyPosition || bIsInitialUpdate);
|
||||||
@ -150,12 +153,13 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
outBitStream->Write0();
|
outBitStream->Write0();
|
||||||
}
|
|
||||||
|
|
||||||
if (!bIsInitialUpdate) {
|
if (!bIsInitialUpdate) {
|
||||||
|
m_DirtyPosition = false;
|
||||||
outBitStream->Write(m_IsTeleporting);
|
outBitStream->Write(m_IsTeleporting);
|
||||||
m_IsTeleporting = false;
|
m_IsTeleporting = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
||||||
@ -309,7 +313,7 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) {
|
|||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims){
|
void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims) {
|
||||||
if (m_IsInBubble) {
|
if (m_IsInBubble) {
|
||||||
LOG("Already in bubble");
|
LOG("Already in bubble");
|
||||||
return;
|
return;
|
||||||
@ -321,7 +325,7 @@ void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bo
|
|||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControllablePhysicsComponent::DeactivateBubbleBuff(){
|
void ControllablePhysicsComponent::DeactivateBubbleBuff() {
|
||||||
m_DirtyBubble = true;
|
m_DirtyBubble = true;
|
||||||
m_IsInBubble = false;
|
m_IsInBubble = false;
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
@ -336,9 +340,9 @@ void ControllablePhysicsComponent::SetStunImmunity(
|
|||||||
const bool bImmuneToStunJump,
|
const bool bImmuneToStunJump,
|
||||||
const bool bImmuneToStunMove,
|
const bool bImmuneToStunMove,
|
||||||
const bool bImmuneToStunTurn,
|
const bool bImmuneToStunTurn,
|
||||||
const bool bImmuneToStunUseItem){
|
const bool bImmuneToStunUseItem) {
|
||||||
|
|
||||||
if (state == eStateChangeType::POP){
|
if (state == eStateChangeType::POP) {
|
||||||
if (bImmuneToStunAttack && m_ImmuneToStunAttackCount > 0) m_ImmuneToStunAttackCount -= 1;
|
if (bImmuneToStunAttack && m_ImmuneToStunAttackCount > 0) m_ImmuneToStunAttackCount -= 1;
|
||||||
if (bImmuneToStunEquip && m_ImmuneToStunEquipCount > 0) m_ImmuneToStunEquipCount -= 1;
|
if (bImmuneToStunEquip && m_ImmuneToStunEquipCount > 0) m_ImmuneToStunEquipCount -= 1;
|
||||||
if (bImmuneToStunInteract && m_ImmuneToStunInteractCount > 0) m_ImmuneToStunInteractCount -= 1;
|
if (bImmuneToStunInteract && m_ImmuneToStunInteractCount > 0) m_ImmuneToStunInteractCount -= 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user