Merge branch 'main' into fix/cmake-libs-2

This commit is contained in:
David Markowitz
2024-01-25 02:43:29 -08:00
225 changed files with 2937 additions and 2556 deletions

View File

@@ -30,40 +30,36 @@
#include "LeaderboardManager.h"
ActivityComponent::ActivityComponent(Entity* parent, int32_t activityID) : Component(parent) {
if (activityID > 0) m_ActivityID = activityID;
else m_ActivityID = parent->GetVar<int32_t>(u"activityID");
CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
std::vector<CDActivities> activities = activitiesTable->Query([this](CDActivities entry) {return (entry.ActivityID == m_ActivityID); });
/*
* This is precisely what the client does functionally
* Use the component id as the default activity id and load its data from the database
* if activityID is specified and if that column exists in the activities table, update the activity info with that data.
*/
for (CDActivities activity : activities) {
m_ActivityInfo = activity;
if (static_cast<Leaderboard::Type>(activity.leaderboardType) == Leaderboard::Type::Racing && Game::config->GetValue("solo_racing") == "1") {
m_ActivityInfo.minTeamSize = 1;
m_ActivityInfo.minTeams = 1;
}
if (m_ActivityInfo.instanceMapID == -1) {
const auto& transferOverride = parent->GetVarAsString(u"transferZoneID");
if (!transferOverride.empty()) {
GeneralUtils::TryParse(transferOverride, m_ActivityInfo.instanceMapID);
}
}
m_ActivityID = activityID;
LoadActivityData(activityID);
if (m_Parent->HasVar(u"activityID")) {
m_ActivityID = parent->GetVar<int32_t>(u"activityID");
LoadActivityData(m_ActivityID);
}
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
if (destroyableComponent) {
// check for LMIs and set the loot LMIs
// First lookup the loot matrix id for this component id.
CDActivityRewardsTable* activityRewardsTable = CDClientManager::Instance().GetTable<CDActivityRewardsTable>();
std::vector<CDActivityRewards> activityRewards = activityRewardsTable->Query([=](CDActivityRewards entry) {return (entry.LootMatrixIndex == destroyableComponent->GetLootMatrixID()); });
uint32_t startingLMI = 0;
// If we have one, set the starting loot matrix id to that.
if (activityRewards.size() > 0) {
startingLMI = activityRewards[0].LootMatrixIndex;
}
if (startingLMI > 0) {
// now time for bodge :)
// We may have more than 1 loot matrix index to use depending ont the size of the team that is looting the activity.
// So this logic will get the rest of the loot matrix indices for this activity.
std::vector<CDActivityRewards> objectTemplateActivities = activityRewardsTable->Query([=](CDActivityRewards entry) {return (activityRewards[0].objectTemplate == entry.objectTemplate); });
for (const auto& item : objectTemplateActivities) {
@@ -74,6 +70,25 @@ ActivityComponent::ActivityComponent(Entity* parent, int32_t activityID) : Compo
}
}
}
void ActivityComponent::LoadActivityData(const int32_t activityId) {
CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
std::vector<CDActivities> activities = activitiesTable->Query([activityId](CDActivities entry) {return (entry.ActivityID == activityId); });
bool soloRacing = Game::config->GetValue("solo_racing") == "1";
for (CDActivities activity : activities) {
m_ActivityInfo = activity;
if (static_cast<Leaderboard::Type>(activity.leaderboardType) == Leaderboard::Type::Racing && soloRacing) {
m_ActivityInfo.minTeamSize = 1;
m_ActivityInfo.minTeams = 1;
}
if (m_ActivityInfo.instanceMapID == -1) {
const auto& transferOverride = m_Parent->GetVarAsString(u"transferZoneID");
if (!transferOverride.empty()) {
GeneralUtils::TryParse(transferOverride, m_ActivityInfo.instanceMapID);
}
}
}
}
void ActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_DirtyActivityInfo);

View File

@@ -152,6 +152,8 @@ class ActivityComponent : public Component {
public:
ActivityComponent(Entity* parent, int32_t activityID);
void LoadActivityData(const int32_t activityId);
void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;

View File

@@ -25,6 +25,7 @@
#include "Metrics.hpp"
#include "CDComponentsRegistryTable.h"
#include "CDPhysicsComponentTable.h"
#include "dNavMesh.h"
BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id): Component(parent) {
m_Target = LWOOBJID_EMPTY;
@@ -34,7 +35,6 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
m_MovementAI = nullptr;
m_Disabled = false;
m_SkillEntries = {};
m_MovementAI = nullptr;
m_SoftTimer = 5.0f;
//Grab the aggro information from BaseCombatAI:
@@ -129,17 +129,17 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
m_dpEntity->SetPosition(m_Parent->GetPosition());
m_dpEntityEnemy->SetPosition(m_Parent->GetPosition());
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::Instance().AddEntity(m_dpEntityEnemy);
dpWorld::AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntityEnemy);
}
BaseCombatAIComponent::~BaseCombatAIComponent() {
if (m_dpEntity)
dpWorld::Instance().RemoveEntity(m_dpEntity);
dpWorld::RemoveEntity(m_dpEntity);
if (m_dpEntityEnemy)
dpWorld::Instance().RemoveEntity(m_dpEntityEnemy);
dpWorld::RemoveEntity(m_dpEntityEnemy);
}
void BaseCombatAIComponent::Update(const float deltaTime) {
@@ -654,8 +654,8 @@ void BaseCombatAIComponent::Wander() {
auto destination = m_StartPosition + delta;
if (dpWorld::Instance().IsLoaded()) {
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(destination);
if (dpWorld::IsLoaded()) {
destination.y = dpWorld::GetNavMesh()->GetHeightAtPoint(destination);
}
if (Vector3::DistanceSquared(destination, m_MovementAI->GetParent()->GetPosition()) < 2 * 2) {

View File

@@ -45,9 +45,9 @@ struct AiSkillEntry
/**
* Handles the AI of entities, making them wander, tether and attack their enemies
*/
class BaseCombatAIComponent : public Component {
class BaseCombatAIComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::BASE_COMBAT_AI;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::BASE_COMBAT_AI;
BaseCombatAIComponent(Entity* parentEntity, uint32_t id);
~BaseCombatAIComponent() override;

View File

@@ -10,9 +10,9 @@
/**
* Attached to bouncer entities, allowing other entities to bounce off of it
*/
class BouncerComponent : public Component {
class BouncerComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::BOUNCER;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::BOUNCER;
BouncerComponent(Entity* parentEntity);
~BouncerComponent() override;

View File

@@ -47,9 +47,9 @@ struct Buff {
/**
* Allows for the application of buffs to the parent entity, altering health, armor and imagination.
*/
class BuffComponent : public Component {
class BuffComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::BUFF;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::BUFF;
explicit BuffComponent(Entity* parent);

View File

@@ -14,9 +14,9 @@
/**
* Component for the build border, allowing the user to start building when interacting with it
*/
class BuildBorderComponent : public Component {
class BuildBorderComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::BUILD_BORDER;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::BUILD_BORDER;
BuildBorderComponent(Entity* parent);
~BuildBorderComponent() override;

View File

@@ -10,6 +10,7 @@ set(DGAME_DCOMPONENTS_SOURCES
"ControllablePhysicsComponent.cpp"
"DestroyableComponent.cpp"
"DonationVendorComponent.cpp"
"GhostComponent.cpp"
"InventoryComponent.cpp"
"ItemComponent.cpp"
"LevelProgressionComponent.cpp"

View File

@@ -20,6 +20,8 @@
#include "Database.h"
#include "CDRewardCodesTable.h"
#include "Mail.h"
#include "ZoneInstanceManager.h"
#include "WorldPackets.h"
#include <ctime>
CharacterComponent::CharacterComponent(Entity* parent, Character* character) : Component(parent) {
@@ -763,12 +765,12 @@ void CharacterComponent::AwardClaimCodes() {
if (!m_Parent) return;
auto* user = m_Parent->GetParentUser();
if (!user) return;
auto rewardCodes = Database::Get()->GetRewardCodesByAccountID(user->GetAccountID());
if (rewardCodes.empty()) return;
auto* cdrewardCodes = CDClientManager::Instance().GetTable<CDRewardCodesTable>();
for (auto const rewardCode: rewardCodes){
for (auto const rewardCode : rewardCodes) {
LOG_DEBUG("Processing RewardCode %i", rewardCode);
const uint32_t rewardCodeIndex = rewardCode >> 6;
const uint32_t bitIndex = rewardCode % 64;
@@ -786,3 +788,32 @@ void CharacterComponent::AwardClaimCodes() {
Mail::SendMail(LWOOBJID_EMPTY, "%[MAIL_SYSTEM_NOTIFICATION]", m_Parent, subject.str(), body.str(), attachmentLOT, 1);
}
}
void CharacterComponent::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId) const {
const auto objid = m_Parent->GetObjectID();
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneId, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
auto* entity = Game::entityManager->GetEntity(objid);
if (!entity) return;
const auto sysAddr = entity->GetSystemAddress();
auto* character = entity->GetCharacter();
auto* characterComponent = entity->GetComponent<CharacterComponent>();
if (character && characterComponent) {
character->SetZoneID(zoneID);
character->SetZoneInstance(zoneInstance);
character->SetZoneClone(zoneClone);
characterComponent->SetLastRocketConfig(u"");
character->SaveXMLToDatabase();
}
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
Game::entityManager->DestructEntity(entity);
});
}

View File

@@ -61,9 +61,9 @@ enum StatisticID {
/**
* Represents a character, including their rockets and stats
*/
class CharacterComponent : public Component {
class CharacterComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::CHARACTER;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::CHARACTER;
CharacterComponent(Entity* parent, Character* character);
~CharacterComponent() override;
@@ -281,6 +281,14 @@ public:
LWOOBJID GetCurrentInteracting() {return m_CurrentInteracting;};
/**
* Sends a player to another zone with an optional clone ID
*
* @param zoneId zoneID for the new instance.
* @param cloneId cloneID for the new instance.
*/
void SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId = 0) const;
/**
* Character info regarding this character, including clothing styles, etc.
*/

View File

@@ -4,9 +4,9 @@
#include "Component.h"
#include "eReplicaComponentType.h"
class CollectibleComponent : public Component {
class CollectibleComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::COLLECTIBLE;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::COLLECTIBLE;
CollectibleComponent(Entity* parentEntity, int32_t collectibleId) : Component(parentEntity), m_CollectibleId(collectibleId) {}
int16_t GetCollectibleId() const { return m_CollectibleId; }

View File

@@ -7,8 +7,7 @@ class Entity;
/**
* Component base class, provides methods for game loop updates, usage events and loading and saving to XML.
*/
class Component
{
class Component {
public:
Component(Entity* parent);
virtual ~Component();

View File

@@ -57,13 +57,13 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Phy
float radius = 1.5f;
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), radius, false);
m_dpEntity->SetCollisionGroup(COLLISION_GROUP_DYNAMIC | COLLISION_GROUP_FRIENDLY);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
}
}
ControllablePhysicsComponent::~ControllablePhysicsComponent() {
if (m_dpEntity) {
dpWorld::Instance().RemoveEntity(m_dpEntity);
dpWorld::RemoveEntity(m_dpEntity);
}
}

View File

@@ -21,7 +21,7 @@ enum class eStateChangeType : uint32_t;
*/
class ControllablePhysicsComponent : public PhysicsComponent {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::CONTROLLABLE_PHYSICS;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::CONTROLLABLE_PHYSICS;
ControllablePhysicsComponent(Entity* entity);
~ControllablePhysicsComponent() override;

View File

@@ -17,9 +17,9 @@ enum class eStateChangeType : uint32_t;
* Represents the stats of an entity, for example its health, imagination and armor. Also handles factions, which
* indicate which enemies this entity has.
*/
class DestroyableComponent : public Component {
class DestroyableComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::DESTROYABLE;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::DESTROYABLE;
DestroyableComponent(Entity* parentEntity);
~DestroyableComponent() override;

View File

@@ -8,7 +8,7 @@ class Entity;
class DonationVendorComponent final : public VendorComponent {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::DONATION_VENDOR;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::DONATION_VENDOR;
DonationVendorComponent(Entity* parent);
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
uint32_t GetActivityID() {return m_ActivityId;};

View File

@@ -0,0 +1,57 @@
#include "GhostComponent.h"
GhostComponent::GhostComponent(Entity* parent) : Component(parent) {
m_GhostReferencePoint = NiPoint3::ZERO;
m_GhostOverridePoint = NiPoint3::ZERO;
m_GhostOverride = false;
}
GhostComponent::~GhostComponent() {
for (auto& observedEntity : m_ObservedEntities) {
if (observedEntity == 0) continue;
auto* entity = Game::entityManager->GetGhostCandidate(observedEntity);
if (!entity) continue;
entity->SetObservers(entity->GetObservers() - 1);
}
}
void GhostComponent::SetGhostReferencePoint(const NiPoint3& value) {
m_GhostReferencePoint = value;
}
void GhostComponent::SetGhostOverridePoint(const NiPoint3& value) {
m_GhostOverridePoint = value;
}
void GhostComponent::AddLimboConstruction(LWOOBJID objectId) {
m_LimboConstructions.insert(objectId);
}
void GhostComponent::RemoveLimboConstruction(LWOOBJID objectId) {
m_LimboConstructions.erase(objectId);
}
void GhostComponent::ConstructLimboEntities() {
for (const auto& objectId : m_LimboConstructions) {
auto* entity = Game::entityManager->GetEntity(objectId);
if (!entity) continue;
Game::entityManager->ConstructEntity(entity, m_Parent->GetSystemAddress());
}
m_LimboConstructions.clear();
}
void GhostComponent::ObserveEntity(int32_t id) {
m_ObservedEntities.insert(id);
}
bool GhostComponent::IsObserved(int32_t id) {
return m_ObservedEntities.contains(id);
}
void GhostComponent::GhostEntity(int32_t id) {
m_ObservedEntities.erase(id);
}

View File

@@ -0,0 +1,54 @@
#ifndef __GHOSTCOMPONENT__H__
#define __GHOSTCOMPONENT__H__
#include "Component.h"
#include "eReplicaComponentType.h"
#include <unordered_set>
class NiPoint3;
class GhostComponent final : public Component {
public:
static inline const eReplicaComponentType ComponentType = eReplicaComponentType::GHOST;
GhostComponent(Entity* parent);
~GhostComponent() override;
void SetGhostOverride(bool value) { m_GhostOverride = value; };
const NiPoint3& GetGhostReferencePoint() const { return m_GhostOverride ? m_GhostOverridePoint : m_GhostReferencePoint; };
const NiPoint3& GetOriginGhostReferencePoint() const { return m_GhostReferencePoint; };
const NiPoint3& GetGhostOverridePoint() const { return m_GhostOverridePoint; };
bool GetGhostOverride() const { return m_GhostOverride; };
void SetGhostReferencePoint(const NiPoint3& value);
void SetGhostOverridePoint(const NiPoint3& value);
void AddLimboConstruction(const LWOOBJID objectId);
void RemoveLimboConstruction(const LWOOBJID objectId);
void ConstructLimboEntities();
void ObserveEntity(const int32_t id);
bool IsObserved(const int32_t id);
void GhostEntity(const int32_t id);
private:
NiPoint3 m_GhostReferencePoint;
NiPoint3 m_GhostOverridePoint;
std::unordered_set<int32_t> m_ObservedEntities;
std::unordered_set<LWOOBJID> m_LimboConstructions;
bool m_GhostOverride;
};
#endif //!__GHOSTCOMPONENT__H__

View File

@@ -4,38 +4,14 @@
#include "Entity.h"
#include "PhysicsComponent.h"
#include "eReplicaComponentType.h"
struct RemoteInputInfo {
RemoteInputInfo() {
m_RemoteInputX = 0;
m_RemoteInputY = 0;
m_IsPowersliding = false;
m_IsModified = false;
}
void operator=(const RemoteInputInfo& other) {
m_RemoteInputX = other.m_RemoteInputX;
m_RemoteInputY = other.m_RemoteInputY;
m_IsPowersliding = other.m_IsPowersliding;
m_IsModified = other.m_IsModified;
}
bool operator==(const RemoteInputInfo& other) {
return m_RemoteInputX == other.m_RemoteInputX && m_RemoteInputY == other.m_RemoteInputY && m_IsPowersliding == other.m_IsPowersliding && m_IsModified == other.m_IsModified;
}
float m_RemoteInputX;
float m_RemoteInputY;
bool m_IsPowersliding;
bool m_IsModified;
};
#include "PositionUpdate.h"
/**
* Physics component for vehicles.
*/
class HavokVehiclePhysicsComponent : public PhysicsComponent {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::HAVOK_VEHICLE_PHYSICS;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::HAVOK_VEHICLE_PHYSICS;
HavokVehiclePhysicsComponent(Entity* parentEntity);

View File

@@ -31,6 +31,7 @@
#include "eMissionTaskType.h"
#include "eStateChangeType.h"
#include "eUseItemResponse.h"
#include "Mail.h"
#include "CDComponentsRegistryTable.h"
#include "CDInventoryComponentTable.h"
@@ -264,17 +265,11 @@ void InventoryComponent::AddItem(
}
if (slot == -1) {
auto* player = dynamic_cast<Player*>(GetParent());
if (player == nullptr) {
return;
}
outOfSpace += size;
switch (sourceType) {
case 0:
player->SendMail(LWOOBJID_EMPTY, "Darkflame Universe", "Lost Reward", "You received an item and didn&apos;t have room for it.", lot, size);
Mail::SendMail(LWOOBJID_EMPTY, "Darkflame Universe", m_Parent, "Lost Reward", "You received an item and didn&apos;t have room for it.", lot, size);
break;
case 1:

View File

@@ -35,10 +35,9 @@ enum class eItemType : int32_t;
* of different types, each type representing a different group of items, see `eInventoryType` for a list of
* inventories.
*/
class InventoryComponent : public Component
{
class InventoryComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::INVENTORY;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::INVENTORY;
explicit InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document = nullptr);
void Update(float deltaTime) override;

View File

@@ -4,9 +4,9 @@
#include "Component.h"
#include "eReplicaComponentType.h"
class ItemComponent : public Component {
class ItemComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::ITEM;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ITEM;
ItemComponent(Entity* entity) : Component(entity) {}

View File

@@ -11,10 +11,10 @@
* Component that handles the LOT that is shown in the LUP exhibit in the LUP world. Works by setting a timer and
* switching the LOTs around that we'd like to display.
*/
class LUPExhibitComponent : public Component
class LUPExhibitComponent final : public Component
{
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::LUP_EXHIBIT;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::LUP_EXHIBIT;
LUPExhibitComponent(Entity* parent) : Component(parent) {};
void Update(float deltaTime) override;

View File

@@ -11,9 +11,9 @@
*
*/
class LevelProgressionComponent : public Component {
class LevelProgressionComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::LEVEL_PROGRESSION;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::LEVEL_PROGRESSION;
/**
* Constructor for this component

View File

@@ -6,7 +6,7 @@
class MiniGameControlComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MINI_GAME_CONTROL;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MINI_GAME_CONTROL;
MiniGameControlComponent(Entity* parent) : Component(parent) {}
void Serialize(RakNet::BitStream* outBitStream, bool isConstruction);

View File

@@ -24,10 +24,9 @@ class AchievementCacheKey;
* The mission inventory of an entity. Tracks mission state for each mission that can be accepted and allows for
* progression of each of the mission task types (see eMissionTaskType).
*/
class MissionComponent : public Component
{
class MissionComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MISSION;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MISSION;
explicit MissionComponent(Entity* parent);
~MissionComponent() override;

View File

@@ -59,9 +59,9 @@ private:
/**
* Allows entities to offer missions to other entities, depending on their mission inventory progression.
*/
class MissionOfferComponent : public Component {
class MissionOfferComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MISSION_OFFER;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MISSION_OFFER;
MissionOfferComponent(Entity* parent, LOT parentLot);

View File

@@ -22,9 +22,9 @@ class MoveToInventoryMessage;
/**
* Component that represents entities that are a model, e.g. collectible models and BBB models.
*/
class ModelComponent : public Component {
class ModelComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MODEL;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MODEL;
ModelComponent(Entity* parent);

View File

@@ -10,9 +10,9 @@
* same as having said items in your inventory (the subkey for this component) this component is the one that
* renders the entity into the world.
*/
class ModuleAssemblyComponent : public Component {
class ModuleAssemblyComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MODULE_ASSEMBLY;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MODULE_ASSEMBLY;
ModuleAssemblyComponent(Entity* parent);
~ModuleAssemblyComponent() override;

View File

@@ -16,6 +16,8 @@
#include "CDComponentsRegistryTable.h"
#include "CDPhysicsComponentTable.h"
#include "dNavMesh.h"
namespace {
/**
* Cache of all lots and their respective speeds
@@ -169,8 +171,8 @@ NiPoint3 MovementAIComponent::ApproximateLocation() const {
auto approximation = source + ((destination - source) * percentageToWaypoint);
if (dpWorld::Instance().IsLoaded()) {
approximation.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(approximation);
if (dpWorld::IsLoaded()) {
approximation.y = dpWorld::GetNavMesh()->GetHeightAtPoint(approximation);
}
return approximation;
@@ -181,8 +183,8 @@ bool MovementAIComponent::Warp(const NiPoint3& point) {
NiPoint3 destination = point;
if (dpWorld::Instance().IsLoaded()) {
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(point);
if (dpWorld::IsLoaded()) {
destination.y = dpWorld::GetNavMesh()->GetHeightAtPoint(point);
if (std::abs(destination.y - point.y) > 3) {
return false;
@@ -302,8 +304,8 @@ void MovementAIComponent::SetDestination(const NiPoint3& destination) {
}
std::vector<NiPoint3> computedPath;
if (dpWorld::Instance().IsLoaded()) {
computedPath = dpWorld::Instance().GetNavMesh()->GetPath(m_Parent->GetPosition(), destination, m_Info.wanderSpeed);
if (dpWorld::IsLoaded()) {
computedPath = dpWorld::GetNavMesh()->GetPath(m_Parent->GetPosition(), destination, m_Info.wanderSpeed);
}
// Somehow failed
@@ -328,8 +330,8 @@ void MovementAIComponent::SetDestination(const NiPoint3& destination) {
// Simply path
for (auto& point : computedPath) {
if (dpWorld::Instance().IsLoaded()) {
point.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(point);
if (dpWorld::IsLoaded()) {
point.y = dpWorld::GetNavMesh()->GetHeightAtPoint(point);
}
m_InterpolatedWaypoints.push_back(point);

View File

@@ -55,9 +55,9 @@ struct MovementAIInfo {
* Component that handles the movement settings of an entity. Not to be confused with the BaseCombatAI component that
* actually handles attackig and following enemy entities.
*/
class MovementAIComponent : public Component {
class MovementAIComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MOVEMENT_AI;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MOVEMENT_AI;
MovementAIComponent(Entity* parentEntity, MovementAIInfo info);

View File

@@ -104,9 +104,9 @@ public:
* don't at all do what you expect them to as we don't instruct the client of changes made here.
* ^^^ Trivia: This made the red blocks platform and property platforms a pain to implement.
*/
class MovingPlatformComponent : public Component {
class MovingPlatformComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MOVING_PLATFORM;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MOVING_PLATFORM;
MovingPlatformComponent(Entity* parent, const std::string& pathName);
~MovingPlatformComponent() override;

View File

@@ -8,9 +8,9 @@
* Component that handles the LUP/WBL rocket launchpad that can be interacted with to travel to WBL worlds.
*
*/
class MultiZoneEntranceComponent : public Component {
class MultiZoneEntranceComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MULTI_ZONE_ENTRANCE;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MULTI_ZONE_ENTRANCE;
/**
* Constructor for this component, builds the m_LUPWorlds vector

View File

@@ -30,6 +30,7 @@
#include "eObjectBits.h"
#include "eGameMasterLevel.h"
#include "eMissionState.h"
#include "dNavMesh.h"
std::unordered_map<LOT, PetComponent::PetPuzzleData> PetComponent::buildCache{};
std::unordered_map<LWOOBJID, LWOOBJID> PetComponent::currentActivities{};
@@ -69,7 +70,8 @@ std::map<LOT, int32_t> PetComponent::petFlags = {
{ 13067, 838 }, // Skeleton dragon
};
PetComponent::PetComponent(Entity* parent, uint32_t componentId): Component(parent) {
PetComponent::PetComponent(Entity* parentEntity, uint32_t componentId) : Component{ parentEntity } {
m_PetInfo = CDClientManager::Instance().GetTable<CDPetComponentTable>()->GetByID(componentId); // TODO: Make reference when safe
m_ComponentId = componentId;
m_Interaction = LWOOBJID_EMPTY;
@@ -81,31 +83,17 @@ PetComponent::PetComponent(Entity* parent, uint32_t componentId): Component(pare
m_TimerAway = 0;
m_DatabaseId = LWOOBJID_EMPTY;
m_Status = 67108866; // Tamable
m_Ability = PetAbilityType::Invalid;
m_Ability = ePetAbilityType::Invalid;
m_StartPosition = NiPoint3::ZERO;
m_MovementAI = nullptr;
m_TresureTime = 0;
m_Preconditions = nullptr;
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(parent->GetVar<std::u16string>(u"CheckPrecondition"));
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(parentEntity->GetVar<std::u16string>(u"CheckPrecondition"));
if (!checkPreconditions.empty()) {
SetPreconditions(checkPreconditions);
}
// Get the imagination drain rate from the CDClient
auto query = CDClientDatabase::CreatePreppedStmt("SELECT imaginationDrainRate FROM PetComponent WHERE id = ?;");
query.bind(1, static_cast<int>(componentId));
auto result = query.execQuery();
// Should a result not exist for this pet default to 60 seconds.
if (!result.eof() && !result.fieldIsNull(0)) {
imaginationDrainRate = result.getFloatField(0, 60.0f);
} else {
imaginationDrainRate = 60.0f;
}
result.finalize();
}
void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
@@ -114,7 +102,7 @@ void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpd
outBitStream->Write1(); // Always serialize as dirty for now
outBitStream->Write<uint32_t>(m_Status);
outBitStream->Write(tamed ? m_Ability : PetAbilityType::Invalid); // Something with the overhead icon?
outBitStream->Write(tamed ? m_Ability : ePetAbilityType::Invalid); // Something with the overhead icon?
const bool interacting = m_Interaction != LWOOBJID_EMPTY;
@@ -263,17 +251,17 @@ void PetComponent::OnUse(Entity* originator) {
NiPoint3 forward = NiQuaternion::LookAt(m_Parent->GetPosition(), originator->GetPosition()).GetForwardVector();
forward.y = 0;
if (dpWorld::Instance().IsLoaded()) {
if (dpWorld::IsLoaded()) {
NiPoint3 attempt = petPosition + forward * interactionDistance;
float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(attempt);
float y = dpWorld::GetNavMesh()->GetHeightAtPoint(attempt);
while (std::abs(y - petPosition.y) > 4 && interactionDistance > 10) {
const NiPoint3 forward = m_Parent->GetRotation().GetForwardVector();
attempt = originatorPosition + forward * interactionDistance;
y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(attempt);
y = dpWorld::GetNavMesh()->GetHeightAtPoint(attempt);
interactionDistance -= 0.5f;
}
@@ -825,8 +813,8 @@ void PetComponent::Wander() {
auto destination = m_StartPosition + delta;
if (dpWorld::Instance().IsLoaded()) {
destination.y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(destination);
if (dpWorld::IsLoaded()) {
destination.y = dpWorld::GetNavMesh()->GetHeightAtPoint(destination);
}
if (Vector3::DistanceSquared(destination, m_MovementAI->GetParent()->GetPosition()) < 2 * 2) {
@@ -835,11 +823,11 @@ void PetComponent::Wander() {
return;
}
m_MovementAI->SetMaxSpeed(info.wanderSpeed);
m_MovementAI->SetMaxSpeed(m_PetInfo.sprintSpeed);
m_MovementAI->SetDestination(destination);
m_Timer += (m_MovementAI->GetParent()->GetPosition().x - destination.x) / info.wanderSpeed;
m_Timer += (m_MovementAI->GetParent()->GetPosition().x - destination.x) / m_PetInfo.sprintSpeed;
}
void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
@@ -905,8 +893,6 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
GameMessages::SendRegisterPetDBID(m_Owner, m_DatabaseId, owner->GetSystemAddress());
}
GameMessages::SendShowPetActionButton(m_Owner, 3, true, owner->GetSystemAddress());
}
void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
@@ -928,22 +914,22 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
if (!fromTaming) playerDestroyableComponent->Imagine(-1);
// Set this to a variable so when this is called back from the player the timer doesn't fire off.
m_Parent->AddCallbackTimer(imaginationDrainRate, [playerDestroyableComponent, this, item]() {
m_Parent->AddCallbackTimer(m_PetInfo.imaginationDrainRate, [playerDestroyableComponent, this, item]() {
if (!playerDestroyableComponent) {
LOG("No petComponent and/or no playerDestroyableComponent");
return;
}
// If we are out of imagination despawn the pet.
if (playerDestroyableComponent->GetImagination() == 0) {
this->Deactivate();
auto playerEntity = playerDestroyableComponent->GetParent();
if (!playerEntity) return;
// If we are out of imagination despawn the pet.
if (playerDestroyableComponent->GetImagination() == 0) {
this->Deactivate();
auto playerEntity = playerDestroyableComponent->GetParent();
if (!playerEntity) return;
GameMessages::SendUseItemRequirementsResponse(playerEntity->GetObjectID(), playerEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet);
}
GameMessages::SendUseItemRequirementsResponse(playerEntity->GetObjectID(), playerEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet);
}
this->AddDrainImaginationTimer(item);
this->AddDrainImaginationTimer(item);
});
}
@@ -966,7 +952,7 @@ void PetComponent::Deactivate() {
GameMessages::SendRegisterPetDBID(m_Owner, LWOOBJID_EMPTY, owner->GetSystemAddress());
GameMessages::SendShowPetActionButton(m_Owner, 0, false, owner->GetSystemAddress());
GameMessages::SendShowPetActionButton(m_Owner, ePetAbilityType::Invalid, false, owner->GetSystemAddress());
}
void PetComponent::Release() {
@@ -985,12 +971,9 @@ void PetComponent::Release() {
item->SetCount(0, false, false);
}
void PetComponent::Command(NiPoint3 position, LWOOBJID source, int32_t commandType, int32_t typeId, bool overrideObey) {
void PetComponent::Command(const NiPoint3& position, const LWOOBJID source, const int32_t commandType, const int32_t typeId, const bool overrideObey) {
auto* owner = GetOwner();
if (owner == nullptr) {
return;
}
if (!owner) return;
if (commandType == 1) {
// Emotes
@@ -1030,7 +1013,7 @@ uint32_t PetComponent::GetStatus() const {
return m_Status;
}
PetAbilityType PetComponent::GetAbility() const {
ePetAbilityType PetComponent::GetAbility() const {
return m_Ability;
}
@@ -1042,7 +1025,7 @@ void PetComponent::SetStatus(uint32_t value) {
m_Status = value;
}
void PetComponent::SetAbility(PetAbilityType value) {
void PetComponent::SetAbility(ePetAbilityType value) {
m_Ability = value;
}
@@ -1098,7 +1081,7 @@ void PetComponent::SetPetNameForModeration(const std::string& petName) {
}
//Save to db:
Database::Get()->SetPetNameModerationStatus(m_DatabaseId, IPetNames::Info{petName, approved});
Database::Get()->SetPetNameModerationStatus(m_DatabaseId, IPetNames::Info{ petName, approved });
}
void PetComponent::LoadPetNameFromModeration() {

View File

@@ -1,27 +1,22 @@
#pragma once
#ifndef PETCOMPONENT_H
#define PETCOMPONENT_H
#include "Entity.h"
#include "MovementAIComponent.h"
#include "Component.h"
#include "Preconditions.h"
#include "ePetAbilityType.h"
#include "eReplicaComponentType.h"
enum class PetAbilityType : uint32_t
{
Invalid,
GoToObject,
JumpOnObject,
DigAtPosition
};
#include "CDPetComponentTable.h"
/**
* 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 final : public Component
{
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PET;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PET;
explicit PetComponent(Entity* parentEntity, uint32_t componentId);
~PetComponent() override;
@@ -103,7 +98,7 @@ public:
* @param typeId extra information about the command, e.g. the emote to play
* @param overrideObey unused
*/
void Command(NiPoint3 position, LWOOBJID source, int32_t commandType, int32_t typeId, bool overrideObey);
void Command(const NiPoint3& position, const LWOOBJID source, const int32_t commandType, const int32_t typeId, const bool overrideObey);
/**
* Returns the ID of the owner of this pet (if any)
@@ -158,13 +153,13 @@ public:
* Returns an ability the pet may perform, currently unused
* @return an ability the pet may perform
*/
PetAbilityType GetAbility() const;
ePetAbilityType GetAbility() const;
/**
* Sets the ability of the pet, currently unused
* @param value the ability to set
*/
void SetAbility(PetAbilityType value);
void SetAbility(ePetAbilityType value);
/**
* Sets preconditions for the pet that need to be met before it can be tamed
@@ -323,7 +318,7 @@ private:
/**
* A currently active ability, mostly unused
*/
PetAbilityType m_Ability;
ePetAbilityType m_Ability;
/**
* The time an entity has left to complete the minigame
@@ -357,7 +352,10 @@ private:
PreconditionExpression* m_Preconditions;
/**
* The rate at which imagination is drained from the user for having the pet out.
* Pet information loaded from the CDClientDatabase
* TODO: Switch to a reference when safe to do so
*/
float imaginationDrainRate;
CDPetComponent m_PetInfo;
};
#endif // !PETCOMPONENT_H

View File

@@ -161,7 +161,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : PhysicsCompon
m_dpEntity->SetRotation(m_Rotation);
m_dpEntity->SetPosition(m_Position);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
} else if (info->physicsAsset == "miscellaneous\\misc_phys_640x640.hkx") {
// Move this down by 13.521004 units so it is still effectively at the same height as before
m_Position = m_Position - NiPoint3::UNIT_Y * 13.521004f;
@@ -172,56 +172,56 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : PhysicsCompon
m_dpEntity->SetRotation(m_Rotation);
m_dpEntity->SetPosition(m_Position);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
} else if (info->physicsAsset == "env\\trigger_wall_tall.hkx") {
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 10.0f, 25.0f, 1.0f);
m_dpEntity->SetScale(m_Scale);
m_dpEntity->SetRotation(m_Rotation);
m_dpEntity->SetPosition(m_Position);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
} else if (info->physicsAsset == "env\\env_gen_placeholderphysics.hkx") {
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 20.0f, 20.0f, 20.0f);
m_dpEntity->SetScale(m_Scale);
m_dpEntity->SetRotation(m_Rotation);
m_dpEntity->SetPosition(m_Position);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
} else if (info->physicsAsset == "env\\POI_trigger_wall.hkx") {
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 1.0f, 12.5f, 20.0f); // Not sure what the real size is
m_dpEntity->SetScale(m_Scale);
m_dpEntity->SetRotation(m_Rotation);
m_dpEntity->SetPosition(m_Position);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
} else if (info->physicsAsset == "env\\NG_NinjaGo\\env_ng_gen_gate_chamber_puzzle_ceiling_tile_falling_phantom.hkx") {
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 18.0f, 5.0f, 15.0f);
m_dpEntity->SetScale(m_Scale);
m_dpEntity->SetRotation(m_Rotation);
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 7.5f);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
} else if (info->physicsAsset == "env\\NG_NinjaGo\\ng_flamejet_brick_phantom.HKX") {
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 1.0f, 1.0f, 12.0f);
m_dpEntity->SetScale(m_Scale);
m_dpEntity->SetRotation(m_Rotation);
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 6.0f);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
} else if (info->physicsAsset == "env\\Ring_Trigger.hkx") {
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 6.0f, 6.0f, 6.0f);
m_dpEntity->SetScale(m_Scale);
m_dpEntity->SetRotation(m_Rotation);
m_dpEntity->SetPosition(m_Position);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
} else if (info->physicsAsset == "env\\vfx_propertyImaginationBall.hkx") {
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 4.5f);
m_dpEntity->SetScale(m_Scale);
m_dpEntity->SetRotation(m_Rotation);
m_dpEntity->SetPosition(m_Position);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
} else if (info->physicsAsset == "env\\env_won_fv_gas-blocking-volume.hkx") {
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true);
m_dpEntity->SetScale(m_Scale);
m_dpEntity->SetRotation(m_Rotation);
m_Position.y -= (111.467964f * m_Scale) / 2;
m_dpEntity->SetPosition(m_Position);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
} else {
//LOG("This one is supposed to have %s", info->physicsAsset.c_str());
@@ -230,7 +230,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : PhysicsCompon
m_dpEntity->SetScale(m_Scale);
m_dpEntity->SetRotation(m_Rotation);
m_dpEntity->SetPosition(m_Position);
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
}
}
@@ -238,7 +238,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : PhysicsCompon
PhantomPhysicsComponent::~PhantomPhysicsComponent() {
if (m_dpEntity) {
dpWorld::Instance().RemoveEntity(m_dpEntity);
dpWorld::RemoveEntity(m_dpEntity);
}
}
@@ -300,7 +300,7 @@ void PhantomPhysicsComponent::CreatePhysics() {
m_dpEntity->SetPosition({ m_Position.x, m_Position.y - (height / 2), m_Position.z });
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::AddEntity(m_dpEntity);
m_HasCreatedPhysics = true;
}

View File

@@ -25,9 +25,9 @@ enum class ePhysicsEffectType : uint32_t ;
* trigger gameplay events, for example the bus in Avant Gardens that moves around when the player touches its physics
* body. Optionally this object can also have effects, like the fans in AG.
*/
class PhantomPhysicsComponent : public PhysicsComponent {
class PhantomPhysicsComponent final : public PhysicsComponent {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PHANTOM_PHYSICS;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PHANTOM_PHYSICS;
PhantomPhysicsComponent(Entity* parent);
~PhantomPhysicsComponent() override;

View File

@@ -8,9 +8,9 @@
* Component that handles player forced movement
*
*/
class PlayerForcedMovementComponent : public Component {
class PlayerForcedMovementComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PLAYER_FORCED_MOVEMENT;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PLAYER_FORCED_MOVEMENT;
/**
* Constructor for this component

View File

@@ -12,9 +12,9 @@
* Represents an entity that can be controlled by some other entity, generally used by cars to indicate that some
* player is controlling it.
*/
class PossessableComponent : public Component {
class PossessableComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::POSSESSABLE;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::POSSESSABLE;
PossessableComponent(Entity* parentEntity, uint32_t componentId);

View File

@@ -16,9 +16,9 @@ enum class ePossessionType : uint8_t {
/**
* Represents an entity that can posess other entities. Generally used by players to drive a car.
*/
class PossessorComponent : public Component {
class PossessorComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::POSSESSOR;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::POSSESSOR;
PossessorComponent(Entity* parent);
~PossessorComponent() override;

View File

@@ -20,9 +20,9 @@ struct PropertyState {
/**
* This component is unused and has no functionality
*/
class PropertyComponent : public Component {
class PropertyComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY;
explicit PropertyComponent(Entity* parentEntity);
~PropertyComponent() override;
[[nodiscard]] PropertyState* GetPropertyState() const { return m_PropertyState; };

View File

@@ -11,10 +11,10 @@
/**
* Represents the launch pad that's used to select and browse properties
*/
class PropertyEntranceComponent : public Component {
class PropertyEntranceComponent final : public Component {
public:
explicit PropertyEntranceComponent(Entity* parent, uint32_t componentID);
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_ENTRANCE;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_ENTRANCE;
/**
* Handles an OnUse request for some other entity, rendering the property browse menu

View File

@@ -20,6 +20,8 @@
#include "InventoryComponent.h"
#include "eMissionTaskType.h"
#include "eObjectBits.h"
#include "CharacterComponent.h"
#include "PlayerManager.h"
#include <vector>
#include "CppScripts.h"
@@ -226,7 +228,7 @@ void PropertyManagementComponent::OnStartBuilding() {
if (ownerEntity == nullptr) return;
const auto players = Player::GetAllPlayers();
const auto players = PlayerManager::GetAllPlayers();
LWOMAPID zoneId = 1100;
@@ -247,7 +249,8 @@ void PropertyManagementComponent::OnStartBuilding() {
for (auto* player : players) {
if (player == ownerEntity) continue;
player->SendToZone(zoneId);
auto* characterComponent = player->GetComponent<CharacterComponent>();
if (characterComponent) characterComponent->SendToZone(zoneId);
}
auto inventoryComponent = ownerEntity->GetComponent<InventoryComponent>();
@@ -519,7 +522,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
{
item->SetCount(item->GetCount() - 1);
LOG("BODGE TIME, YES IT GOES HERE");
LOG("DLU currently does not support breaking apart brick by brick models.");
break;
}

View File

@@ -8,8 +8,7 @@
/**
* Information regarding which players may visit this property
*/
enum class PropertyPrivacyOption
{
enum class PropertyPrivacyOption {
/**
* Default, only you can visit your property
*/
@@ -29,10 +28,9 @@ enum class PropertyPrivacyOption
/**
* Main component that handles interactions with a property, generally the plaques you see on properties.
*/
class PropertyManagementComponent : public Component
{
class PropertyManagementComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_MANAGEMENT;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_MANAGEMENT;
PropertyManagementComponent(Entity* parent);
static PropertyManagementComponent* Instance();

View File

@@ -7,10 +7,9 @@
/**
* The property guard that stands on a property before it's claimed, allows entities to attempt claiming this property.
*/
class PropertyVendorComponent : public Component
{
class PropertyVendorComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_VENDOR;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_VENDOR;
explicit PropertyVendorComponent(Entity* parent);
/**

View File

@@ -18,7 +18,7 @@ ProximityMonitorComponent::~ProximityMonitorComponent() {
for (const auto& en : m_ProximitiesData) {
if (!en.second) continue;
dpWorld::Instance().RemoveEntity(en.second);
dpWorld::RemoveEntity(en.second);
}
m_ProximitiesData.clear();
@@ -28,12 +28,12 @@ void ProximityMonitorComponent::SetProximityRadius(float proxRadius, const std::
dpEntity* en = new dpEntity(m_Parent->GetObjectID(), proxRadius);
en->SetPosition(m_Parent->GetPosition());
dpWorld::Instance().AddEntity(en);
dpWorld::AddEntity(en);
m_ProximitiesData.insert(std::make_pair(name, en));
}
void ProximityMonitorComponent::SetProximityRadius(dpEntity* entity, const std::string& name) {
dpWorld::Instance().AddEntity(entity);
dpWorld::AddEntity(entity);
entity->SetPosition(m_Parent->GetPosition());
m_ProximitiesData.insert(std::make_pair(name, entity));
}

View File

@@ -17,9 +17,9 @@
* Utility component for detecting how close entities are to named proximities for this entity. Allows you to store
* proximity checks for multiple ojects.
*/
class ProximityMonitorComponent : public Component {
class ProximityMonitorComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROXIMITY_MONITOR;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PROXIMITY_MONITOR;
ProximityMonitorComponent(Entity* parentEntity, int smallRadius = -1, int largeRadius = -1);
~ProximityMonitorComponent() override;

View File

@@ -14,7 +14,6 @@
#include "eGameActivity.h"
#include "dServer.h"
#include "PacketUtils.h"
#include "Spawner.h"
#include "MovingPlatformComponent.h"
#include "Preconditions.h"

View File

@@ -20,9 +20,9 @@ enum class eQuickBuildFailReason : uint32_t;
* consists of an activator that shows a popup and then the actual entity that the bricks are built into. Note
* that quick builds are also scripted activities so this shared some logic with the ScriptedActivityComponent.
*/
class QuickBuildComponent : public Component {
class QuickBuildComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::QUICK_BUILD;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::QUICK_BUILD;
QuickBuildComponent(Entity* entity);
~QuickBuildComponent() override;

View File

@@ -71,10 +71,8 @@ void RacingControlComponent::OnPlayerLoaded(Entity* player) {
// If the race has already started, send the player back to the main world.
if (m_Loaded || !vehicle) {
auto* playerInstance = dynamic_cast<Player*>(player);
if (playerInstance) {
playerInstance->SendToZone(m_MainWorld);
}
auto* characterComponent = player->GetComponent<CharacterComponent>();
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
return;
}
@@ -105,10 +103,11 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
if (item == nullptr) {
LOG("Failed to find item");
auto* playerInstance = dynamic_cast<Player*>(player);
if (playerInstance) {
auto* characterComponent = player->GetComponent<CharacterComponent>();
if (characterComponent) {
m_LoadedPlayers--;
playerInstance->SendToZone(m_MainWorld);
characterComponent->SendToZone(m_MainWorld);
}
return;
@@ -427,9 +426,9 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu
m_Parent->GetObjectID(), 3, 0, LWOOBJID_EMPTY, u"",
player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
auto* playerInstance = dynamic_cast<Player*>(player);
auto* characterComponent = player->GetComponent<CharacterComponent>();
playerInstance->SendToZone(m_MainWorld);
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
vehicle->Kill();
}
@@ -561,9 +560,9 @@ void RacingControlComponent::Update(float deltaTime) {
continue;
}
auto* playerInstance = dynamic_cast<Player*>(playerEntity);
auto* characterComponent = playerEntity->GetComponent<CharacterComponent>();
playerInstance->SendToZone(m_MainWorld);
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
}
m_LobbyPlayers.clear();
@@ -623,9 +622,9 @@ void RacingControlComponent::Update(float deltaTime) {
continue;
}
auto* playerInstance = dynamic_cast<Player*>(playerEntity);
auto* characterComponent = playerEntity->GetComponent<CharacterComponent>();
playerInstance->SendToZone(m_MainWorld);
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
}
return;

View File

@@ -103,9 +103,9 @@ struct RacingPlayerInfo {
/**
* Component that's attached to a manager entity in each race zone that loads player vehicles, keep scores, etc.
*/
class RacingControlComponent : public Component {
class RacingControlComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::RACING_CONTROL;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RACING_CONTROL;
RacingControlComponent(Entity* parentEntity);
~RacingControlComponent();

View File

@@ -8,7 +8,7 @@ class Entity;
class RacingSoundTriggerComponent : public SoundTriggerComponent {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::RACING_SOUND_TRIGGER;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RACING_SOUND_TRIGGER;
RacingSoundTriggerComponent(Entity* parent) : SoundTriggerComponent(parent){};
};

View File

@@ -6,7 +6,7 @@
class RacingStatsComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::RACING_STATS;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RACING_STATS;
RacingStatsComponent(Entity* parent) : Component(parent) {}
};

View File

@@ -15,7 +15,7 @@ public:
explicit RailActivatorComponent(Entity* parent, int32_t componentID);
~RailActivatorComponent() override;
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::RAIL_ACTIVATOR;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RAIL_ACTIVATOR;
/**
* Handles the OnUse event from some entity, initiates the rail movement

View File

@@ -5,7 +5,6 @@
#include <iomanip>
#include "Entity.h"
#include "PacketUtils.h"
#include "CDClientManager.h"
#include "GameMessages.h"

View File

@@ -54,9 +54,9 @@ struct Effect {
* Determines that a component should be visibly rendered into the world, most entities have this. This component
* also handles effects that play for entities.
*/
class RenderComponent : public Component {
class RenderComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::RENDER;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RENDER;
RenderComponent(Entity* entity, int32_t componentId = -1);
~RenderComponent() override;

View File

@@ -19,7 +19,7 @@
*/
class RigidbodyPhantomPhysicsComponent : public PhysicsComponent {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS;
RigidbodyPhantomPhysicsComponent(Entity* parent);

View File

@@ -16,9 +16,9 @@ class PreconditionExpression;
/**
* Component that handles rocket launchpads that can be interacted with to travel to other worlds.
*/
class RocketLaunchpadControlComponent : public Component {
class RocketLaunchpadControlComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::ROCKET_LAUNCH;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ROCKET_LAUNCH;
RocketLaunchpadControlComponent(Entity* parent, int rocketId);
~RocketLaunchpadControlComponent() override;

View File

@@ -6,9 +6,9 @@
class Entity;
class ScriptedActivityComponent : public ActivityComponent {
class ScriptedActivityComponent final : public ActivityComponent {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPTED_ACTIVITY;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SCRIPTED_ACTIVITY;
ScriptedActivityComponent(Entity* parent, int activityID) : ActivityComponent(parent, activityID){};
};

View File

@@ -71,9 +71,9 @@ 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 : public Component {
class ShootingGalleryComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SHOOTING_GALLERY;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SHOOTING_GALLERY;
explicit ShootingGalleryComponent(Entity* parent);
~ShootingGalleryComponent();

View File

@@ -28,7 +28,7 @@ enum class eClimbableType : int32_t {
*/
class SimplePhysicsComponent : public PhysicsComponent {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SIMPLE_PHYSICS;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SIMPLE_PHYSICS;
SimplePhysicsComponent(Entity* parent, uint32_t componentID);
~SimplePhysicsComponent() override;

View File

@@ -1,6 +1,6 @@
/*
* Darkflame Universe
* Copyright 2018
* Copyright 2024
*/
#ifndef SKILLCOMPONENT_H
@@ -55,11 +55,11 @@ struct SkillExecutionResult {
*
* Skills are a built up by a tree of behaviors. See dGame/dBehaviors/ for a list of behaviors.
*
* This system is very conveluted and still has a lot of unknowns.
* This system is very convoluted and still has a lot of unknowns.
*/
class SkillComponent : public Component {
class SkillComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SKILL;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SKILL;
explicit SkillComponent(Entity* parent);
~SkillComponent() override;

View File

@@ -1,4 +1,5 @@
#pragma once
#include "dCommonVars.h"
#include "Entity.h"
#include "GUID.h"
@@ -43,7 +44,7 @@ struct GUIDResults{
void Serialize(RakNet::BitStream* outBitStream);
};
struct MixerProgram{
struct MixerProgram {
std::string name;
uint32_t result;
@@ -58,7 +59,7 @@ struct MixerProgram{
class SoundTriggerComponent : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER;
explicit SoundTriggerComponent(Entity* parent);
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void ActivateMusicCue(const std::string& name, float bordemTime = -1.0);
@@ -66,11 +67,11 @@ public:
private:
std::vector<MusicCue> m_MusicCues = {};
std::vector<MusicParameter> m_MusicParameters = {};
std::vector<GUIDResults> m_2DAmbientSounds = {};
std::vector<GUIDResults> m_3DAmbientSounds = {};
std::vector<MixerProgram> m_MixerPrograms = {};
std::vector<MusicCue> m_MusicCues;
std::vector<MusicParameter> m_MusicParameters;
std::vector<GUIDResults> m_2DAmbientSounds;
std::vector<GUIDResults> m_3DAmbientSounds;
std::vector<MixerProgram> m_MixerPrograms;
bool m_Dirty = false;
};

View File

@@ -14,9 +14,9 @@
/**
* A component for switches in game, including pet triggered switches.
*/
class SwitchComponent : public Component {
class SwitchComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SWITCH;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SWITCH;
SwitchComponent(Entity* parent);
~SwitchComponent() override;

View File

@@ -13,6 +13,7 @@
#include "QuickBuildComponent.h"
#include "SkillComponent.h"
#include "eEndBehavior.h"
#include "PlayerManager.h"
TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo): Component(parent) {
@@ -175,7 +176,7 @@ std::vector<Entity*> TriggerComponent::GatherTargets(LUTriggers::Command* comman
}
} else if (command->target == "objGroup") entities = Game::entityManager->GetEntitiesInGroup(command->targetName);
else if (command->target == "allPlayers") {
for (auto* player : Player::GetAllPlayers()) {
for (auto* player : PlayerManager::GetAllPlayers()) {
entities.push_back(player);
}
} else if (command->target == "allNPCs") { /*UNUSED*/ }

View File

@@ -5,9 +5,9 @@
#include "LUTriggers.h"
#include "eReplicaComponentType.h"
class TriggerComponent : public Component {
class TriggerComponent final : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::TRIGGER;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::TRIGGER;
explicit TriggerComponent(Entity* parent, const std::string triggerInfo);

View File

@@ -20,7 +20,7 @@ struct SoldItem {
class VendorComponent : public Component {
public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::VENDOR;
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::VENDOR;
VendorComponent(Entity* parent);
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;