adding new pet flags

This commit is contained in:
jadebenn
2023-12-14 23:43:08 -06:00
parent f5ca142eb9
commit 668bebf68c
4 changed files with 630 additions and 25 deletions

View File

@@ -86,7 +86,7 @@ PetComponent::PetComponent(Entity* parent, uint32_t componentId): Component(pare
m_TimerAway = 0;
m_TimerBounce = 0;
m_DatabaseId = LWOOBJID_EMPTY;
m_Status = PetStatus::TAMEABLE; // Tameable
m_Flags = 1 << PetFlag::TAMEABLE; // Tameable
m_Ability = ePetAbilityType::Invalid;
m_StartPosition = m_Parent->GetPosition(); //NiPoint3::ZERO;
m_MovementAI = nullptr;
@@ -125,7 +125,7 @@ void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpd
outBitStream->Write1(); // Always serialize as dirty for now
outBitStream->Write<uint32_t>(static_cast<unsigned int>(m_Status));
outBitStream->Write<uint32_t>(static_cast<unsigned int>(m_Flags));
outBitStream->Write<uint32_t>(static_cast<uint32_t>(tamed ? m_Ability : ePetAbilityType::Invalid)); // Something with the overhead icon?
const bool interacting = m_Interaction != LWOOBJID_EMPTY;
@@ -719,7 +719,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
currentActivities.erase(m_Tamer);
SetStatus(PetStatus::TAMEABLE);
SetStatus(1 << PetFlag::TAMEABLE);
m_Tamer = LWOOBJID_EMPTY;
m_Timer = 0;
@@ -770,7 +770,7 @@ void PetComponent::ClientFailTamingMinigame() {
currentActivities.erase(m_Tamer);
SetStatus(PetStatus::TAMEABLE);
SetStatus(1 << PetFlag::TAMEABLE);
m_Tamer = LWOOBJID_EMPTY;
m_Timer = 0;
@@ -835,7 +835,7 @@ void PetComponent::OnSpawn() {
m_Parent->SetOwnerOverride(m_Owner);
m_MovementAI->SetMaxSpeed(m_SprintSpeed);
m_MovementAI->SetHaltDistance(m_FollowRadius);
SetStatus(PetStatus::NONE);
SetStatus(1 << PetFlag::NONE);
SetPetAiState(PetAiState::follow);
}
else {
@@ -946,7 +946,7 @@ void PetComponent::StopInteract() {
SetInteractType(PetInteractType::none);
SetAbility(petAbility);
SetPetAiState(PetAiState::follow);
SetStatus(PetStatus::NONE);
SetStatus(1 << PetFlag::NONE);
SetIsReadyToInteract(false);
SetIsHandlingInteraction(false); // Needed?
m_MovementAI->SetMaxSpeed(m_SprintSpeed);
@@ -976,7 +976,7 @@ void PetComponent::SetupInteractTreasureDig() {
auto petAbility = ePetAbilityType::DigAtPosition;
SetAbility(petAbility);
SetStatus(PetStatus::IS_NOT_WAITING); // TODO: Double-check this is the right flag being set
SetStatus(1 << PetFlag::NOT_WAITING); // TODO: Double-check this is the right flag being set
Game::entityManager->SerializeEntity(m_Parent); // TODO: Double-check pet packet captures
const auto sysAddr = owner->GetSystemAddress();
@@ -1053,7 +1053,7 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) { //
auto* owner = GetOwner();
if (owner == nullptr) return;
SetStatus(PetStatus::PLAY_SPAWN_ANIM);
SetStatus(1 << PetFlag::PLAY_SPAWN_ANIM);
auto databaseData = inventoryComponent->GetDatabasePet(m_DatabaseId);
@@ -1220,7 +1220,7 @@ LWOOBJID PetComponent::GetItemId() const {
}
uint32_t PetComponent::GetStatus() const {
return m_Status;
return m_Flags;
}
ePetAbilityType PetComponent::GetAbility() const {
@@ -1232,8 +1232,8 @@ void PetComponent::SetInteraction(LWOOBJID value) {
}
void PetComponent::SetStatus(uint32_t value) {
m_Status = value;
LOG_DEBUG("Pet status set to: %x", m_Status);
m_Flags = value;
LOG_DEBUG("Pet status set to: %x", m_Flags);
}
void PetComponent::SetAbility(ePetAbilityType value) {

View File

@@ -1,4 +1,5 @@
#pragma once
#ifndef PETCOMPONENT_H
#define PETCOMPONENT_H
#include "Entity.h"
#include "MovementAIComponent.h"
@@ -22,23 +23,34 @@ enum class PetAiState : uint8_t {
/*
* The type of object the pet is interacting with
*/
enum class PetInteractType : uint8_t {
enum PetInteractType : uint8_t {
none, // Not interacting
treasure, // Treasure dig
bouncer // Bouncer switch
};
/*
* The status of the pet: Governs the icon above their head and the interactions available
/**
* The flags governing the status of the pet: Governs the icon above their head and the interactions available
*/
enum PetStatus : uint32_t {
enum PetFlag : uint32_t {
NONE,
BEING_TAMED = 1 << 4, //0x10,
IS_NOT_WAITING = 1 << 5, //0x20,
PLAY_SPAWN_ANIM = 1 << 7, //0x80,
TAMEABLE = 1 << 8 //0x4000000
BEING_TAMED = 4,
NOT_WAITING = 5,
PLAY_SPAWN_ANIM = 7,
TAMEABLE = 8
};
/*
* DEPRECATED The status of the pet: Governs the icon above their head and the interactions available
*/
/*enum PetStatus : uint32_t {
NONE,
BEING_TAMED = 1 << 4, //PetFlag::BEING_TAMED, //0x10,
IS_NOT_WAITING = 1 << 5, //PetFlag::NOT_WAITING, //0x20,
PLAY_SPAWN_ANIM = 1 << 7, //PetFlag::PLAY_SPAWN_ANIM, //0x80,
TAMEABLE = 1 << 8 // PetFlag::TAMEABLE //0x4000000
};*/
enum PetEmote : int32_t {
ActivateSwitch = 201,
DigTreasure,
@@ -49,12 +61,11 @@ enum PetEmote : int32_t {
* Represents an entity that is a pet. This pet can be tamed and consequently follows the tamer around, allowing it
* to dig for treasure and activate pet bouncers.
*/
class PetComponent : public Component
{
class PetComponent : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PET;
explicit PetComponent(Entity* parentEntity, uint32_t componentId);
PetComponent(Entity* parentEntity, uint32_t componentId);
~PetComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
@@ -70,6 +81,26 @@ public:
*/
PetAiState GetPetAiState() { return m_State; };
/**
* Template function for setting pet flags
*/
template <typename... T>
void SetFlag(T... flag) {
//m_Flags |= (uint32_t)flag;
m_Flags |= ((uint32_t)flag | ...);//(static_cast<uint32_t>(flag) | ...);
//T::operator|(m_Flags, flag...);
}
/**
* Template function for getting pet flags
*/
template <typename... T>
const bool HasFlag(T... flag) {
//return (m_Flags & (u_int32_t)flag) == (u_int32_t)flag;
//return T::operator&(m_Flags, flag...) == T::operator&(flag...);
return true;
}
void Update(float deltaTime) override;
/**
@@ -452,9 +483,9 @@ private:
std::string m_OwnerName;
/**
* The current state of the pet (e.g. tamable, tamed, etc).
* The current flags of the pet (e.g. tamable, tamed, etc).
*/
uint32_t m_Status;
uint32_t m_Flags;
/**
* The current state of the pet AI
@@ -526,3 +557,5 @@ private:
*/
float m_SprintSpeed;
};
#endif // PETCOMPONENT_H