This commit is contained in:
Aaron Kimbre 2024-04-13 01:32:42 -05:00
parent 3a6123fe36
commit 4caed08ce4
10 changed files with 73 additions and 51 deletions

View File

@ -254,7 +254,7 @@ void Entity::Initialize() {
} }
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MINI_GAME_CONTROL) > 0) { if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MINI_GAME_CONTROL) > 0) {
AddComponent<MiniGameControlComponent>(); AddComponent<MiniGameControlComponent>(m_TemplateID);
} }
uint32_t possessableComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::POSSESSABLE); uint32_t possessableComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::POSSESSABLE);
@ -666,7 +666,7 @@ void Entity::Initialize() {
// Shooting gallery component // Shooting gallery component
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SHOOTING_GALLERY) > 0) { if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SHOOTING_GALLERY) > 0) {
AddComponent<ShootingGalleryComponent>(); AddComponent<ShootingGalleryComponent>(m_TemplateID);
} }
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY, -1) != -1) { if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY, -1) != -1) {

View File

@ -47,7 +47,6 @@ set(DGAME_DCOMPONENTS_SOURCES
"TriggerComponent.cpp" "TriggerComponent.cpp"
"HavokVehiclePhysicsComponent.cpp" "HavokVehiclePhysicsComponent.cpp"
"VendorComponent.cpp" "VendorComponent.cpp"
"MiniGameControlComponent.cpp"
"ScriptComponent.cpp" "ScriptComponent.cpp"
) )

View File

@ -696,22 +696,20 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument& document) {
} }
void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool bIsInitialUpdate) { void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool bIsInitialUpdate) {
// LWOInventoryComponent_EquippedItem
outBitStream.Write(bIsInitialUpdate || m_Dirty);
if (bIsInitialUpdate || m_Dirty) { if (bIsInitialUpdate || m_Dirty) {
outBitStream.Write(true);
outBitStream.Write<uint32_t>(m_Equipped.size()); outBitStream.Write<uint32_t>(m_Equipped.size());
for (const auto& pair : m_Equipped) { for (const auto& pair : m_Equipped) {
const auto item = pair.second; const auto item = pair.second;
if (bIsInitialUpdate) { if (bIsInitialUpdate) AddItemSkills(item.lot);
AddItemSkills(item.lot);
}
outBitStream.Write(item.id); outBitStream.Write(item.id);
outBitStream.Write(item.lot); outBitStream.Write(item.lot);
outBitStream.Write0(); outBitStream.Write0(); // subkey
outBitStream.Write(item.count > 0); outBitStream.Write(item.count > 0);
if (item.count > 0) outBitStream.Write(item.count); if (item.count > 0) outBitStream.Write(item.count);
@ -719,7 +717,7 @@ void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool b
outBitStream.Write(item.slot != 0); outBitStream.Write(item.slot != 0);
if (item.slot != 0) outBitStream.Write<uint16_t>(item.slot); if (item.slot != 0) outBitStream.Write<uint16_t>(item.slot);
outBitStream.Write0(); outBitStream.Write0(); // inventory type
bool flag = !item.config.empty(); bool flag = !item.config.empty();
outBitStream.Write(flag); outBitStream.Write(flag);
@ -746,11 +744,21 @@ void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool b
} }
m_Dirty = false; m_Dirty = false;
} else {
outBitStream.Write(false);
} }
// EquippedModelTransform
outBitStream.Write(false); outBitStream.Write(false);
/*
outBitStream.Write(bIsInitialUpdate || m_Dirty); // Same dirty or different?
if (bIsInitialUpdate || m_Dirty) {
outBitStream.Write<uint32_t>(m_Equipped.size()); // Equiped models?
for (const auto& [location, item] : m_Equipped) {
outBitStream.Write(item.id);
outBitStream.Write(item.pos);
outBitStream.Write(item.rot);
}
}
*/
} }
void InventoryComponent::Update(float deltaTime) { void InventoryComponent::Update(float deltaTime) {

View File

@ -2,4 +2,16 @@
void ItemComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { void ItemComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
outBitStream.Write0(); outBitStream.Write0();
/*
outBitStream.Write(isConstruction || m_Dirty); // Same dirty or different?
if (isConstruction || m_Dirty) {
outBitStream.Write(m_parent->GetObjectID());
outBitStream.Write(moderationStatus);
outBitStream.Write(!description.empty());
if (!description.empty()) {
outBitStream.Write<uint32_t>(description.size());
outBitStream.Write(description) // u16string
}
}
*/
} }

View File

@ -1,5 +0,0 @@
#include "MiniGameControlComponent.h"
void MiniGameControlComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
outBitStream.Write<uint32_t>(0x40000000);
}

View File

@ -1,15 +1,13 @@
#ifndef __MINIGAMECONTROLCOMPONENT__H__ #ifndef __MINIGAMECONTROLCOMPONENT__H__
#define __MINIGAMECONTROLCOMPONENT__H__ #define __MINIGAMECONTROLCOMPONENT__H__
#include "Component.h" #include "ActivityComponent.h"
#include "eReplicaComponentType.h" #include "eReplicaComponentType.h"
class MiniGameControlComponent final : public Component { class MiniGameControlComponent final : public ActivityComponent {
public: public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MINI_GAME_CONTROL; static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MINI_GAME_CONTROL;
MiniGameControlComponent(Entity* parent, LOT lot) : ActivityComponent(parent, lot) {}
MiniGameControlComponent(Entity* parent) : Component(parent) {}
void Serialize(RakNet::BitStream& outBitStream, bool isConstruction);
}; };
#endif //!__MINIGAMECONTROLCOMPONENT__H__ #endif //!__MINIGAMECONTROLCOMPONENT__H__

View File

@ -2,11 +2,6 @@
#include "EntityManager.h" #include "EntityManager.h"
#include "ScriptedActivityComponent.h" #include "ScriptedActivityComponent.h"
ShootingGalleryComponent::ShootingGalleryComponent(Entity* parent) : Component(parent) {
}
ShootingGalleryComponent::~ShootingGalleryComponent() = default;
void ShootingGalleryComponent::SetStaticParams(const StaticShootingGalleryParams& params) { void ShootingGalleryComponent::SetStaticParams(const StaticShootingGalleryParams& params) {
m_StaticParams = params; m_StaticParams = params;
} }
@ -17,20 +12,15 @@ void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryPara
Game::entityManager->SerializeEntity(m_Parent); Game::entityManager->SerializeEntity(m_Parent);
} }
void ShootingGalleryComponent::Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) { void ShootingGalleryComponent::SetCurrentPlayerID(LWOOBJID playerID) {
// Start ScriptedActivityComponent m_CurrentPlayerID = playerID;
outBitStream.Write<bool>(true); m_Dirty = true;
if (m_CurrentPlayerID == LWOOBJID_EMPTY) { AddActivityPlayerData(playerID);
outBitStream.Write<uint32_t>(0); };
} else {
outBitStream.Write<uint32_t>(1);
outBitStream.Write<LWOOBJID>(m_CurrentPlayerID);
for (size_t i = 0; i < 10; i++) {
outBitStream.Write<float_t>(0.0f);
}
}
// End ScriptedActivityComponent void ShootingGalleryComponent::Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) {
ActivityComponent::Serialize(outBitStream, isInitialUpdate);
if (isInitialUpdate) { if (isInitialUpdate) {
outBitStream.Write<float_t>(m_StaticParams.cameraPosition.GetX()); outBitStream.Write<float_t>(m_StaticParams.cameraPosition.GetX());

View File

@ -2,7 +2,7 @@
#include "dCommonVars.h" #include "dCommonVars.h"
#include "NiPoint3.h" #include "NiPoint3.h"
#include "Entity.h" #include "Entity.h"
#include "Component.h" #include "ActivityComponent.h"
#include "eReplicaComponentType.h" #include "eReplicaComponentType.h"
/** /**
@ -71,12 +71,11 @@ struct StaticShootingGalleryParams {
* A very ancient component that was used to guide shooting galleries, it's still kind of used but a lot of logic is * A very ancient component that was used to guide shooting galleries, it's still kind of used but a lot of logic is
* also in the related scripts. * also in the related scripts.
*/ */
class ShootingGalleryComponent final : public Component { class ShootingGalleryComponent final : public ActivityComponent {
public: public:
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SHOOTING_GALLERY; static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SHOOTING_GALLERY;
explicit ShootingGalleryComponent(Entity* parent); explicit ShootingGalleryComponent(Entity* parent, LOT lot) : ActivityComponent(parent, lot) {}
~ShootingGalleryComponent();
void Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) override; void Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) override;
/** /**
@ -107,13 +106,8 @@ public:
* Sets the entity that's currently playing the shooting gallery * Sets the entity that's currently playing the shooting gallery
* @param playerID the entity to set * @param playerID the entity to set
*/ */
void SetCurrentPlayerID(LWOOBJID playerID) { m_CurrentPlayerID = playerID; m_Dirty = true; }; void SetCurrentPlayerID(LWOOBJID playerID);
/**
* Returns the player that's currently playing the shooting gallery
* @return the player that's currently playing the shooting gallery
*/
LWOOBJID GetCurrentPlayerID() const { return m_CurrentPlayerID; };
private: private:
/** /**

View File

@ -486,6 +486,32 @@ SkillComponent::~SkillComponent() {
void SkillComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { void SkillComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) outBitStream.Write0(); if (bIsInitialUpdate) outBitStream.Write0();
/*
outBitStream.Write(bIsInitialUpdate && !m_managedBehaviors.empty());
if (bIsInitialUpdate && !m_managedBehaviors.empty()) {
outBitStream.Write<uint32_t>(m_managedBehaviors.size());
for (const auto& [id, skill] : m_managedBehaviors) {
outBitStream.Write(skill.skillUID);
outBitStream.Write(skill.skillID);
outBitStream.Write(skill.cast_type);
outBitStream.Write(skill.cancel_type);
outBitStream.Write(skill.behavior_count);
for (auto& index : skill.behavior_count) {
outBitStream.Write<uint32_t>(unknown_1);
outBitStream.Write<uint32_t>(action);
outBitStream.Write<uint32_t>(wait_time_ms);
outBitStream.Write<uint32_t>(template_id);
outBitStream.Write(casterObjId);
outBitStream.Write(originatorObjId);
outBitStream.Write(targetObjId);
outBitStream.Write<bool>(usedMouse);
outBitStream.Write(cooldown);
outBitStream.Write(charge_time);
outBitStream.Write(imagination_cost);
}
}
}
*/
} }
/// <summary> /// <summary>

View File

@ -90,7 +90,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
auto* shootingGalleryComponent = self->GetComponent<ShootingGalleryComponent>(); auto* shootingGalleryComponent = self->GetComponent<ShootingGalleryComponent>();
if (shootingGalleryComponent != nullptr) { if (shootingGalleryComponent != nullptr) {
shootingGalleryComponent->SetCurrentPlayerID(player->GetObjectID()); shootingGalleryComponent->AddActivityPlayerData(player->GetObjectID());
LOG("Setting player ID"); LOG("Setting player ID");