mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 09:48:20 +00:00
WIP
This commit is contained in:
parent
3a6123fe36
commit
4caed08ce4
@ -254,7 +254,7 @@ void Entity::Initialize() {
|
||||
}
|
||||
|
||||
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);
|
||||
@ -666,7 +666,7 @@ void Entity::Initialize() {
|
||||
|
||||
// Shooting gallery component
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::SHOOTING_GALLERY) > 0) {
|
||||
AddComponent<ShootingGalleryComponent>();
|
||||
AddComponent<ShootingGalleryComponent>(m_TemplateID);
|
||||
}
|
||||
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROPERTY, -1) != -1) {
|
||||
|
@ -47,7 +47,6 @@ set(DGAME_DCOMPONENTS_SOURCES
|
||||
"TriggerComponent.cpp"
|
||||
"HavokVehiclePhysicsComponent.cpp"
|
||||
"VendorComponent.cpp"
|
||||
"MiniGameControlComponent.cpp"
|
||||
"ScriptComponent.cpp"
|
||||
)
|
||||
|
||||
|
@ -696,22 +696,20 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument& document) {
|
||||
}
|
||||
|
||||
void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool bIsInitialUpdate) {
|
||||
// LWOInventoryComponent_EquippedItem
|
||||
outBitStream.Write(bIsInitialUpdate || m_Dirty);
|
||||
if (bIsInitialUpdate || m_Dirty) {
|
||||
outBitStream.Write(true);
|
||||
|
||||
outBitStream.Write<uint32_t>(m_Equipped.size());
|
||||
|
||||
for (const auto& pair : m_Equipped) {
|
||||
const auto item = pair.second;
|
||||
|
||||
if (bIsInitialUpdate) {
|
||||
AddItemSkills(item.lot);
|
||||
}
|
||||
if (bIsInitialUpdate) AddItemSkills(item.lot);
|
||||
|
||||
outBitStream.Write(item.id);
|
||||
outBitStream.Write(item.lot);
|
||||
|
||||
outBitStream.Write0();
|
||||
outBitStream.Write0(); // subkey
|
||||
|
||||
outBitStream.Write(item.count > 0);
|
||||
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);
|
||||
if (item.slot != 0) outBitStream.Write<uint16_t>(item.slot);
|
||||
|
||||
outBitStream.Write0();
|
||||
outBitStream.Write0(); // inventory type
|
||||
|
||||
bool flag = !item.config.empty();
|
||||
outBitStream.Write(flag);
|
||||
@ -746,11 +744,21 @@ void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool b
|
||||
}
|
||||
|
||||
m_Dirty = false;
|
||||
} else {
|
||||
outBitStream.Write(false);
|
||||
}
|
||||
|
||||
// EquippedModelTransform
|
||||
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) {
|
||||
|
@ -2,4 +2,16 @@
|
||||
|
||||
void ItemComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
|
||||
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
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -1,5 +0,0 @@
|
||||
#include "MiniGameControlComponent.h"
|
||||
|
||||
void MiniGameControlComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
|
||||
outBitStream.Write<uint32_t>(0x40000000);
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
#ifndef __MINIGAMECONTROLCOMPONENT__H__
|
||||
#define __MINIGAMECONTROLCOMPONENT__H__
|
||||
|
||||
#include "Component.h"
|
||||
#include "ActivityComponent.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
class MiniGameControlComponent final : public Component {
|
||||
class MiniGameControlComponent final : public ActivityComponent {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MINI_GAME_CONTROL;
|
||||
|
||||
MiniGameControlComponent(Entity* parent) : Component(parent) {}
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool isConstruction);
|
||||
MiniGameControlComponent(Entity* parent, LOT lot) : ActivityComponent(parent, lot) {}
|
||||
};
|
||||
|
||||
#endif //!__MINIGAMECONTROLCOMPONENT__H__
|
||||
|
@ -2,11 +2,6 @@
|
||||
#include "EntityManager.h"
|
||||
#include "ScriptedActivityComponent.h"
|
||||
|
||||
ShootingGalleryComponent::ShootingGalleryComponent(Entity* parent) : Component(parent) {
|
||||
}
|
||||
|
||||
ShootingGalleryComponent::~ShootingGalleryComponent() = default;
|
||||
|
||||
void ShootingGalleryComponent::SetStaticParams(const StaticShootingGalleryParams& params) {
|
||||
m_StaticParams = params;
|
||||
}
|
||||
@ -17,20 +12,15 @@ void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryPara
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ShootingGalleryComponent::Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) {
|
||||
// Start ScriptedActivityComponent
|
||||
outBitStream.Write<bool>(true);
|
||||
if (m_CurrentPlayerID == LWOOBJID_EMPTY) {
|
||||
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);
|
||||
}
|
||||
void ShootingGalleryComponent::SetCurrentPlayerID(LWOOBJID playerID) {
|
||||
m_CurrentPlayerID = playerID;
|
||||
m_Dirty = true;
|
||||
AddActivityPlayerData(playerID);
|
||||
};
|
||||
|
||||
}
|
||||
// End ScriptedActivityComponent
|
||||
|
||||
void ShootingGalleryComponent::Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) {
|
||||
ActivityComponent::Serialize(outBitStream, isInitialUpdate);
|
||||
|
||||
if (isInitialUpdate) {
|
||||
outBitStream.Write<float_t>(m_StaticParams.cameraPosition.GetX());
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "dCommonVars.h"
|
||||
#include "NiPoint3.h"
|
||||
#include "Entity.h"
|
||||
#include "Component.h"
|
||||
#include "ActivityComponent.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
|
||||
* also in the related scripts.
|
||||
*/
|
||||
class ShootingGalleryComponent final : public Component {
|
||||
class ShootingGalleryComponent final : public ActivityComponent {
|
||||
public:
|
||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SHOOTING_GALLERY;
|
||||
|
||||
explicit ShootingGalleryComponent(Entity* parent);
|
||||
~ShootingGalleryComponent();
|
||||
explicit ShootingGalleryComponent(Entity* parent, LOT lot) : ActivityComponent(parent, lot) {}
|
||||
void Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) override;
|
||||
|
||||
/**
|
||||
@ -107,13 +106,8 @@ public:
|
||||
* Sets the entity that's currently playing the shooting gallery
|
||||
* @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:
|
||||
|
||||
/**
|
||||
|
@ -486,6 +486,32 @@ SkillComponent::~SkillComponent() {
|
||||
|
||||
void SkillComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) {
|
||||
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>
|
||||
|
@ -90,7 +90,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
|
||||
auto* shootingGalleryComponent = self->GetComponent<ShootingGalleryComponent>();
|
||||
|
||||
if (shootingGalleryComponent != nullptr) {
|
||||
shootingGalleryComponent->SetCurrentPlayerID(player->GetObjectID());
|
||||
shootingGalleryComponent->AddActivityPlayerData(player->GetObjectID());
|
||||
|
||||
LOG("Setting player ID");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user