mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 09:48:20 +00:00
Implement bubble seriliaztion in controllable physics (#942)
* bubble * "Correct" serialization and enum * Enum update * figured out what things do * accurate types and cleanup * add sanity check add getter add slash command for testing * fix default * cleanup slash command * handle game message probably remove funny slash command add all bubble GM's Co-authored-by: Jett <55758076+Jettford@users.noreply.github.com>
This commit is contained in:
parent
80f8dd8003
commit
5374c555f5
@ -374,6 +374,8 @@ enum GAME_MSG : unsigned short {
|
||||
GAME_MSG_PET_TAMING_TRY_BUILD_RESULT = 668,
|
||||
GAME_MSG_NOTIFY_TAMING_BUILD_SUCCESS = 673,
|
||||
GAME_MSG_NOTIFY_TAMING_MODEL_LOADED_ON_SERVER = 674,
|
||||
GAME_MSG_ACTIVATE_BUBBLE_BUFF = 678,
|
||||
GAME_MSG_DEACTIVATE_BUBBLE_BUFF = 679,
|
||||
GAME_MSG_ADD_PET_TO_PLAYER = 681,
|
||||
GAME_MSG_REQUEST_SET_PET_NAME = 683,
|
||||
GAME_MSG_SET_PET_NAME = 684,
|
||||
@ -386,7 +388,10 @@ enum GAME_MSG : unsigned short {
|
||||
GAME_MSG_QUERY_PROPERTY_DATA = 717,
|
||||
GAME_MSG_PROPERTY_EDITOR_BEGIN = 724,
|
||||
GAME_MSG_PROPERTY_EDITOR_END = 725,
|
||||
GAME_MSG_START_PATHING = 735,
|
||||
GAME_MSG_IS_MINIFIG_IN_A_BUBBLE = 729,
|
||||
GAME_MSG_START_PATHING = 733,
|
||||
GAME_MSG_ACTIVATE_BUBBLE_BUFF_FROM_SERVER = 734,
|
||||
GAME_MSG_DEACTIVATE_BUBBLE_BUFF_FROM_SERVER = 735,
|
||||
GAME_MSG_NOTIFY_CLIENT_ZONE_OBJECT = 737,
|
||||
GAME_MSG_UPDATE_REPUTATION = 746,
|
||||
GAME_MSG_PROPERTY_RENTAL_RESPONSE = 750,
|
||||
|
14
dCommon/dEnums/eBubbleType.h
Normal file
14
dCommon/dEnums/eBubbleType.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef __EBUBBLETYPE__H__
|
||||
#define __EBUBBLETYPE__H__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
enum class eBubbleType : uint32_t {
|
||||
DEFAULT = 0,
|
||||
ENERGY = 1,
|
||||
SKUNK = 2,
|
||||
};
|
||||
|
||||
#endif //!__EBUBBLETYPE__H__
|
@ -31,8 +31,15 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Com
|
||||
m_GravityScale = 1;
|
||||
m_DirtyCheats = false;
|
||||
m_IgnoreMultipliers = false;
|
||||
|
||||
m_DirtyEquippedItemInfo = true;
|
||||
m_PickupRadius = 0.0f;
|
||||
m_DirtyPickupRadiusScale = true;
|
||||
|
||||
m_DirtyBubble = false;
|
||||
m_IsInBubble = false;
|
||||
m_SpecialAnims = false;
|
||||
m_BubbleType = eBubbleType::DEFAULT;
|
||||
|
||||
m_IsTeleporting = false;
|
||||
|
||||
m_ImmuneToStunAttackCount = 0;
|
||||
@ -99,14 +106,22 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
||||
m_DirtyCheats = false;
|
||||
}
|
||||
|
||||
outBitStream->Write(m_DirtyPickupRadiusScale);
|
||||
if (m_DirtyPickupRadiusScale) {
|
||||
outBitStream->Write(m_DirtyEquippedItemInfo);
|
||||
if (m_DirtyEquippedItemInfo) {
|
||||
outBitStream->Write(m_PickupRadius);
|
||||
outBitStream->Write0(); //No clue what this is so im leaving it false.
|
||||
m_DirtyPickupRadiusScale = false;
|
||||
outBitStream->Write(m_InJetpackMode);
|
||||
m_DirtyEquippedItemInfo = false;
|
||||
}
|
||||
|
||||
outBitStream->Write0();
|
||||
outBitStream->Write(m_DirtyBubble);
|
||||
if (m_DirtyBubble) {
|
||||
outBitStream->Write(m_IsInBubble);
|
||||
if (m_IsInBubble) {
|
||||
outBitStream->Write(m_BubbleType);
|
||||
outBitStream->Write(m_SpecialAnims);
|
||||
}
|
||||
m_DirtyBubble = false;
|
||||
}
|
||||
|
||||
outBitStream->Write(m_DirtyPosition || bIsInitialUpdate);
|
||||
if (m_DirtyPosition || bIsInitialUpdate) {
|
||||
@ -263,7 +278,7 @@ void ControllablePhysicsComponent::AddPickupRadiusScale(float value) {
|
||||
m_ActivePickupRadiusScales.push_back(value);
|
||||
if (value > m_PickupRadius) {
|
||||
m_PickupRadius = value;
|
||||
m_DirtyPickupRadiusScale = true;
|
||||
m_DirtyEquippedItemInfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,7 +294,7 @@ void ControllablePhysicsComponent::RemovePickupRadiusScale(float value) {
|
||||
|
||||
// Recalculate pickup radius since we removed one by now
|
||||
m_PickupRadius = 0.0f;
|
||||
m_DirtyPickupRadiusScale = true;
|
||||
m_DirtyEquippedItemInfo = true;
|
||||
for (uint32_t i = 0; i < m_ActivePickupRadiusScales.size(); i++) {
|
||||
auto candidateRadius = m_ActivePickupRadiusScales[i];
|
||||
if (m_PickupRadius < candidateRadius) m_PickupRadius = candidateRadius;
|
||||
@ -314,6 +329,24 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) {
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims){
|
||||
if (m_IsInBubble) {
|
||||
Game::logger->Log("ControllablePhysicsComponent", "Already in bubble");
|
||||
return;
|
||||
}
|
||||
m_BubbleType = bubbleType;
|
||||
m_IsInBubble = true;
|
||||
m_DirtyBubble = true;
|
||||
m_SpecialAnims = specialAnims;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::DeactivateBubbleBuff(){
|
||||
m_DirtyBubble = true;
|
||||
m_IsInBubble = false;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
};
|
||||
|
||||
void ControllablePhysicsComponent::SetStunImmunity(
|
||||
const eStateChangeType state,
|
||||
const LWOOBJID originator,
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "Component.h"
|
||||
#include "dpCollisionChecks.h"
|
||||
#include "PhantomPhysicsComponent.h"
|
||||
#include "eBubbleType.h"
|
||||
|
||||
class Entity;
|
||||
class dpEntity;
|
||||
@ -257,14 +258,40 @@ public:
|
||||
*/
|
||||
std::vector<float> GetActivePickupRadiusScales() { return m_ActivePickupRadiusScales; };
|
||||
|
||||
|
||||
/**
|
||||
* Add a Speed boost to the entity
|
||||
* This will recalculate the speed boost based on what is being added
|
||||
*/
|
||||
void AddSpeedboost(float value);
|
||||
|
||||
/**
|
||||
* Remove speed boost from entity
|
||||
* This will recalculate the speed boost based on what is the last one in te vector
|
||||
*/
|
||||
void RemoveSpeedboost(float value);
|
||||
|
||||
/**
|
||||
* The speed boosts of this component.
|
||||
* @return All active Speed boosts for this component.
|
||||
*/
|
||||
std::vector<float> GetActiveSpeedboosts() { return m_ActivePickupRadiusScales; };
|
||||
|
||||
/**
|
||||
* Activates the Bubble Buff
|
||||
*/
|
||||
void ActivateBubbleBuff(eBubbleType bubbleType = eBubbleType::DEFAULT, bool specialAnims = true);
|
||||
|
||||
/**
|
||||
* Deactivates the Bubble Buff
|
||||
*/
|
||||
void DeactivateBubbleBuff();
|
||||
|
||||
/**
|
||||
* Gets if the Entity is in a bubble
|
||||
*/
|
||||
bool GetIsInBubble(){ return m_IsInBubble; };
|
||||
|
||||
/**
|
||||
* Push or Pop a layer of stun immunity to this entity
|
||||
*/
|
||||
void SetStunImmunity(
|
||||
@ -387,7 +414,7 @@ private:
|
||||
/**
|
||||
* Whether the pickup scale is dirty.
|
||||
*/
|
||||
bool m_DirtyPickupRadiusScale;
|
||||
bool m_DirtyEquippedItemInfo;
|
||||
|
||||
/**
|
||||
* The list of pickup radius scales for this entity
|
||||
@ -414,7 +441,27 @@ private:
|
||||
*/
|
||||
float m_SpeedBoost;
|
||||
|
||||
/**
|
||||
/*
|
||||
* If Bubble info is dirty
|
||||
*/
|
||||
bool m_DirtyBubble;
|
||||
|
||||
/*
|
||||
* If the entity is in a bubble
|
||||
*/
|
||||
bool m_IsInBubble;
|
||||
|
||||
/*
|
||||
* The type of bubble the entity has
|
||||
*/
|
||||
eBubbleType m_BubbleType;
|
||||
|
||||
/*
|
||||
* If the entity should be using the special animations
|
||||
*/
|
||||
bool m_SpecialAnims;
|
||||
|
||||
/**
|
||||
* stun immunity counters
|
||||
*/
|
||||
int32_t m_ImmuneToStunAttackCount;
|
||||
|
@ -665,9 +665,14 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
case GAME_MSG_DISMOUNT_COMPLETE:
|
||||
GameMessages::HandleDismountComplete(inStream, entity, sysAddr);
|
||||
break;
|
||||
|
||||
case GAME_MSG_DEACTIVATE_BUBBLE_BUFF:
|
||||
GameMessages::HandleDeactivateBubbleBuff(inStream, entity);
|
||||
break;
|
||||
case GAME_MSG_ACTIVATE_BUBBLE_BUFF:
|
||||
GameMessages::HandleActivateBubbleBuff(inStream, entity);
|
||||
break;
|
||||
default:
|
||||
//Game::logger->Log("GameMessageHandler", "Unknown game message ID: %X", messageID);
|
||||
// Game::logger->Log("GameMessageHandler", "Unknown game message ID: %i", messageID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -6084,3 +6084,43 @@ void GameMessages::HandleUpdatePlayerStatistic(RakNet::BitStream* inStream, Enti
|
||||
characterComponent->UpdatePlayerStatistic((StatisticID)updateID, (uint64_t)std::max(updateValue, int64_t(0)));
|
||||
}
|
||||
}
|
||||
|
||||
void GameMessages::HandleDeactivateBubbleBuff(RakNet::BitStream* inStream, Entity* entity) {
|
||||
auto controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
||||
if (controllablePhysicsComponent) controllablePhysicsComponent->DeactivateBubbleBuff();
|
||||
}
|
||||
|
||||
void GameMessages::HandleActivateBubbleBuff(RakNet::BitStream* inStream, Entity* entity) {
|
||||
bool specialAnimations;
|
||||
if (!inStream->Read(specialAnimations)) return;
|
||||
|
||||
std::u16string type = GeneralUtils::ReadWString(inStream);
|
||||
auto bubbleType = eBubbleType::DEFAULT;
|
||||
if (type == u"skunk") bubbleType = eBubbleType::SKUNK;
|
||||
else if (type == u"energy") bubbleType = eBubbleType::ENERGY;
|
||||
|
||||
auto controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
||||
if (controllablePhysicsComponent) controllablePhysicsComponent->ActivateBubbleBuff(bubbleType, specialAnimations);
|
||||
}
|
||||
|
||||
void GameMessages::SendActivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
bitStream.Write(objectId);
|
||||
bitStream.Write(GAME_MSG::GAME_MSG_ACTIVATE_BUBBLE_BUFF_FROM_SERVER);
|
||||
|
||||
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST;
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void GameMessages::SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
bitStream.Write(objectId);
|
||||
bitStream.Write(GAME_MSG::GAME_MSG_DEACTIVATE_BUBBLE_BUFF_FROM_SERVER);
|
||||
|
||||
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST;
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
@ -617,6 +617,15 @@ namespace GameMessages {
|
||||
void HandleReportBug(RakNet::BitStream* inStream, Entity* entity);
|
||||
|
||||
void SendRemoveBuff(Entity* entity, bool fromUnEquip, bool removeImmunity, uint32_t buffId);
|
||||
|
||||
// bubble
|
||||
void HandleDeactivateBubbleBuff(RakNet::BitStream* inStream, Entity* entity);
|
||||
|
||||
void HandleActivateBubbleBuff(RakNet::BitStream* inStream, Entity* entity);
|
||||
|
||||
void SendActivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr);
|
||||
|
||||
void SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const SystemAddress& sysAddr);
|
||||
};
|
||||
|
||||
#endif // GAMEMESSAGES_H
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include "AssetManager.h"
|
||||
#include "BinaryPathFinder.h"
|
||||
#include "dConfig.h"
|
||||
#include "eBubbleType.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "MovingPlatformComponent.h"
|
||||
#include "dMessageIdentifiers.h"
|
||||
|
Loading…
Reference in New Issue
Block a user