mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-03-06 08:39:47 +00:00
Merge branch 'main' into npc-pathing
This commit is contained in:
@@ -173,7 +173,7 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
|
||||
}
|
||||
|
||||
if (m_SoftTimer <= 0.0f) {
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
m_SoftTimer = 5.0f;
|
||||
} else {
|
||||
@@ -305,7 +305,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
||||
}
|
||||
|
||||
if (serilizationRequired) {
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 6270, u"tether", "tether");
|
||||
@@ -412,7 +412,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
||||
float biggestThreat = 0;
|
||||
|
||||
for (const auto& entry : possibleTargets) {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(entry);
|
||||
auto* entity = Game::entityManager->GetEntity(entry);
|
||||
|
||||
if (entity == nullptr) {
|
||||
continue;
|
||||
@@ -458,7 +458,7 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
||||
std::vector<LWOOBJID> deadThreats{};
|
||||
|
||||
for (const auto& threatTarget : m_ThreatEntries) {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(threatTarget.first);
|
||||
auto* entity = Game::entityManager->GetEntity(threatTarget.first);
|
||||
|
||||
if (entity == nullptr) {
|
||||
deadThreats.push_back(threatTarget.first);
|
||||
@@ -497,7 +497,7 @@ std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
|
||||
std::vector<LWOOBJID> targets;
|
||||
|
||||
for (auto id : m_Parent->GetTargetsInPhantom()) {
|
||||
auto* other = EntityManager::Instance()->GetEntity(id);
|
||||
auto* other = Game::entityManager->GetEntity(id);
|
||||
|
||||
const auto distance = Vector3::DistanceSquared(m_Parent->GetPosition(), other->GetPosition());
|
||||
|
||||
@@ -535,11 +535,11 @@ void BaseCombatAIComponent::SetAiState(AiState newState) {
|
||||
if (newState == this->m_State) return;
|
||||
this->m_State = newState;
|
||||
m_DirtyStateOrTarget = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(target);
|
||||
auto* entity = Game::entityManager->GetEntity(target);
|
||||
|
||||
if (entity == nullptr) {
|
||||
Game::logger->Log("BaseCombatAIComponent", "Invalid entity for checking validity (%llu)!", target);
|
||||
@@ -588,11 +588,11 @@ void BaseCombatAIComponent::SetTarget(const LWOOBJID target) {
|
||||
if (this->m_Target == target) return;
|
||||
m_Target = target;
|
||||
m_DirtyStateOrTarget = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
Entity* BaseCombatAIComponent::GetTargetEntity() const {
|
||||
return EntityManager::Instance()->GetEntity(m_Target);
|
||||
return Game::entityManager->GetEntity(m_Target);
|
||||
}
|
||||
|
||||
void BaseCombatAIComponent::Taunt(LWOOBJID offender, float threat) {
|
||||
|
||||
@@ -36,7 +36,7 @@ Entity* BouncerComponent::GetParentEntity() const {
|
||||
void BouncerComponent::SetPetEnabled(bool value) {
|
||||
m_PetEnabled = value;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void BouncerComponent::SetPetBouncerEnabled(bool value) {
|
||||
@@ -44,7 +44,7 @@ void BouncerComponent::SetPetBouncerEnabled(bool value) {
|
||||
|
||||
GameMessages::SendBouncerActiveStatus(m_Parent->GetObjectID(), value, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
if (value) {
|
||||
m_Parent->TriggerEvent(eTriggerEventType::PET_ON_SWITCH, m_Parent);
|
||||
@@ -68,7 +68,7 @@ void BouncerComponent::LookupPetSwitch() {
|
||||
const auto& groups = m_Parent->GetGroups();
|
||||
|
||||
for (const auto& group : groups) {
|
||||
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup(group);
|
||||
const auto& entities = Game::entityManager->GetEntitiesInGroup(group);
|
||||
|
||||
for (auto* entity : entities) {
|
||||
auto* switchComponent = entity->GetComponent<SwitchComponent>();
|
||||
@@ -79,7 +79,7 @@ void BouncerComponent::LookupPetSwitch() {
|
||||
m_PetSwitchLoaded = true;
|
||||
m_PetEnabled = true;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
Game::logger->Log("BouncerComponent", "Loaded pet bouncer");
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ BuildBorderComponent::~BuildBorderComponent() {
|
||||
|
||||
void BuildBorderComponent::OnUse(Entity* originator) {
|
||||
if (originator->GetCharacter()) {
|
||||
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup("PropertyPlaque");
|
||||
const auto& entities = Game::entityManager->GetEntitiesInGroup("PropertyPlaque");
|
||||
|
||||
auto buildArea = m_Parent->GetObjectID();
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "VehiclePhysicsComponent.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Item.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
#include "eGameActivity.h"
|
||||
|
||||
@@ -419,7 +419,7 @@ void CharacterComponent::TrackMissionCompletion(bool isAchievement) {
|
||||
|
||||
// Achievements are tracked separately for the zone
|
||||
if (isAchievement) {
|
||||
const auto mapID = dZoneManager::Instance()->GetZoneID().GetMapID();
|
||||
const auto mapID = Game::zoneManager->GetZoneID().GetMapID();
|
||||
GetZoneStatisticsForMap(mapID).m_AchievementsCollected++;
|
||||
}
|
||||
}
|
||||
@@ -480,7 +480,7 @@ void CharacterComponent::TrackArmorDelta(int32_t armor) {
|
||||
void CharacterComponent::TrackRebuildComplete() {
|
||||
UpdatePlayerStatistic(QuickBuildsCompleted);
|
||||
|
||||
const auto mapID = dZoneManager::Instance()->GetZoneID().GetMapID();
|
||||
const auto mapID = Game::zoneManager->GetZoneID().GetMapID();
|
||||
GetZoneStatisticsForMap(mapID).m_QuickBuildsCompleted++;
|
||||
}
|
||||
|
||||
@@ -734,6 +734,6 @@ void CharacterComponent::RemoveVentureVisionEffect(std::string ventureVisionType
|
||||
void CharacterComponent::UpdateClientMinimap(bool showFaction, std::string ventureVisionType) const {
|
||||
if (!m_Parent) return;
|
||||
AMFArrayValue arrayToSend;
|
||||
arrayToSend.InsertValue(ventureVisionType, showFaction ? static_cast<AMFValue*>(new AMFTrueValue()) : static_cast<AMFValue*>(new AMFFalseValue()));
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent ? m_Parent->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", &arrayToSend);
|
||||
arrayToSend.Insert(ventureVisionType, showFaction);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent ? m_Parent->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", arrayToSend);
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto zoneInfo = dZoneManager::Instance()->GetZone()->GetZoneID();
|
||||
auto zoneInfo = Game::zoneManager->GetZone()->GetZoneID();
|
||||
|
||||
if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0) {
|
||||
character->SetAttribute("lzx", m_Position.x);
|
||||
@@ -300,7 +300,7 @@ void ControllablePhysicsComponent::RemovePickupRadiusScale(float value) {
|
||||
auto candidateRadius = m_ActivePickupRadiusScales[i];
|
||||
if (m_PickupRadius < candidateRadius) m_PickupRadius = candidateRadius;
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::AddSpeedboost(float value) {
|
||||
@@ -320,14 +320,14 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) {
|
||||
|
||||
// Recalculate speedboost since we removed one
|
||||
m_SpeedBoost = 0.0f;
|
||||
if (m_ActiveSpeedBoosts.size() == 0) { // no active speed boosts left, so return to base speed
|
||||
if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed
|
||||
auto* levelProgressionComponent = m_Parent->GetComponent<LevelProgressionComponent>();
|
||||
if (levelProgressionComponent) m_SpeedBoost = levelProgressionComponent->GetSpeedBase();
|
||||
} else { // Used the last applied speedboost
|
||||
m_SpeedBoost = m_ActiveSpeedBoosts.back();
|
||||
}
|
||||
SetSpeedMultiplier(m_SpeedBoost / 500.0f); // 500 being the base speed
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims){
|
||||
@@ -339,13 +339,13 @@ void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bo
|
||||
m_IsInBubble = true;
|
||||
m_DirtyBubble = true;
|
||||
m_SpecialAnims = specialAnims;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::DeactivateBubbleBuff(){
|
||||
m_DirtyBubble = true;
|
||||
m_IsInBubble = false;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
};
|
||||
|
||||
void ControllablePhysicsComponent::SetStunImmunity(
|
||||
|
||||
@@ -276,7 +276,7 @@ public:
|
||||
* The speed boosts of this component.
|
||||
* @return All active Speed boosts for this component.
|
||||
*/
|
||||
std::vector<float> GetActiveSpeedboosts() { return m_ActivePickupRadiusScales; };
|
||||
std::vector<float> GetActiveSpeedboosts() { return m_ActiveSpeedBoosts; };
|
||||
|
||||
/**
|
||||
* Activates the Bubble Buff
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "Game.h"
|
||||
#include "dConfig.h"
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "AMFFormat_BitStream.h"
|
||||
#include "Amf3.h"
|
||||
#include "AmfSerialize.h"
|
||||
#include "GameMessages.h"
|
||||
#include "User.h"
|
||||
#include "CDClientManager.h"
|
||||
@@ -51,7 +51,7 @@ DestroyableComponent::DestroyableComponent(Entity* parent) : Component(parent) {
|
||||
m_IsGMImmune = false;
|
||||
m_IsShielded = false;
|
||||
m_DamageToAbsorb = 0;
|
||||
m_HasBricks = false;
|
||||
m_IsModuleAssembly = m_Parent->HasComponent(eReplicaComponentType::MODULE_ASSEMBLY);
|
||||
m_DirtyThreatList = false;
|
||||
m_HasThreats = false;
|
||||
m_ExplodeFactor = 1.0f;
|
||||
@@ -163,7 +163,7 @@ void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn
|
||||
outBitStream->Write(m_IsSmashed);
|
||||
|
||||
if (m_IsSmashable) {
|
||||
outBitStream->Write(m_HasBricks);
|
||||
outBitStream->Write(m_IsModuleAssembly);
|
||||
outBitStream->Write(m_ExplodeFactor != 1.0f);
|
||||
if (m_ExplodeFactor != 1.0f) outBitStream->Write(m_ExplodeFactor);
|
||||
}
|
||||
@@ -245,19 +245,15 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) {
|
||||
if (playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_Parent->GetParentUser()) return;
|
||||
AMFStringValue* amount = new AMFStringValue();
|
||||
amount->SetStringValue(std::to_string(difference));
|
||||
AMFStringValue* type = new AMFStringValue();
|
||||
type->SetStringValue("health");
|
||||
|
||||
AMFArrayValue args;
|
||||
args.InsertValue("amount", amount);
|
||||
args.InsertValue("type", type);
|
||||
args.Insert("amount", std::to_string(difference));
|
||||
args.Insert("type", "health");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetArmor(int32_t value) {
|
||||
@@ -290,19 +286,15 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) {
|
||||
if (playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_Parent->GetParentUser()) return;
|
||||
AMFStringValue* amount = new AMFStringValue();
|
||||
amount->SetStringValue(std::to_string(value));
|
||||
AMFStringValue* type = new AMFStringValue();
|
||||
type->SetStringValue("armor");
|
||||
|
||||
AMFArrayValue args;
|
||||
args.InsertValue("amount", amount);
|
||||
args.InsertValue("type", type);
|
||||
args.Insert("amount", std::to_string(value));
|
||||
args.Insert("type", "armor");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetImagination(int32_t value) {
|
||||
@@ -334,18 +326,14 @@ void DestroyableComponent::SetMaxImagination(float value, bool playAnim) {
|
||||
if (playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_Parent->GetParentUser()) return;
|
||||
AMFStringValue* amount = new AMFStringValue();
|
||||
amount->SetStringValue(std::to_string(difference));
|
||||
AMFStringValue* type = new AMFStringValue();
|
||||
type->SetStringValue("imagination");
|
||||
|
||||
AMFArrayValue args;
|
||||
args.InsertValue("amount", amount);
|
||||
args.InsertValue("type", type);
|
||||
args.Insert("amount", std::to_string(difference));
|
||||
args.Insert("type", "imagination");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_Parent, m_Parent->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetDamageToAbsorb(int32_t value) {
|
||||
@@ -494,11 +482,11 @@ LWOOBJID DestroyableComponent::GetKillerID() const {
|
||||
}
|
||||
|
||||
Entity* DestroyableComponent::GetKiller() const {
|
||||
return EntityManager::Instance()->GetEntity(m_KillerID);
|
||||
return Game::entityManager->GetEntity(m_KillerID);
|
||||
}
|
||||
|
||||
bool DestroyableComponent::CheckValidity(const LWOOBJID target, const bool ignoreFactions, const bool targetEnemy, const bool targetFriend) const {
|
||||
auto* targetEntity = EntityManager::Instance()->GetEntity(target);
|
||||
auto* targetEntity = Game::entityManager->GetEntity(target);
|
||||
|
||||
if (targetEntity == nullptr) {
|
||||
Game::logger->Log("DestroyableComponent", "Invalid entity for checking validity (%llu)!", target);
|
||||
@@ -544,7 +532,7 @@ void DestroyableComponent::Heal(const uint32_t health) {
|
||||
|
||||
SetHealth(current);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -562,7 +550,7 @@ void DestroyableComponent::Imagine(const int32_t deltaImagination) {
|
||||
|
||||
SetImagination(current);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -576,7 +564,7 @@ void DestroyableComponent::Repair(const uint32_t armor) {
|
||||
|
||||
SetArmor(current);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -638,7 +626,7 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
||||
if (possessor) {
|
||||
auto possessableId = possessor->GetPossessable();
|
||||
if (possessableId != LWOOBJID_EMPTY) {
|
||||
auto possessable = EntityManager::Instance()->GetEntity(possessableId);
|
||||
auto possessable = Game::entityManager->GetEntity(possessableId);
|
||||
if (possessable) {
|
||||
possessor->Dismount(possessable);
|
||||
}
|
||||
@@ -650,10 +638,10 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
||||
}
|
||||
|
||||
if (echo) {
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
auto* attacker = EntityManager::Instance()->GetEntity(source);
|
||||
auto* attacker = Game::entityManager->GetEntity(source);
|
||||
m_Parent->OnHit(attacker);
|
||||
m_Parent->OnHitOrHealResult(attacker, sourceDamage);
|
||||
NotifySubscribers(attacker, sourceDamage);
|
||||
@@ -673,7 +661,7 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
||||
}
|
||||
|
||||
//check if hardcore mode is enabled
|
||||
if (EntityManager::Instance()->GetHardcoreMode()) {
|
||||
if (Game::entityManager->GetHardcoreMode()) {
|
||||
DoHardcoreModeDrops(source);
|
||||
}
|
||||
|
||||
@@ -708,12 +696,12 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
SetArmor(0);
|
||||
SetHealth(0);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
m_KillerID = source;
|
||||
|
||||
auto* owner = EntityManager::Instance()->GetEntity(source);
|
||||
auto* owner = Game::entityManager->GetEntity(source);
|
||||
|
||||
if (owner != nullptr) {
|
||||
owner = owner->GetOwner(); // If the owner is overwritten, we collect that here
|
||||
@@ -733,7 +721,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
if (missions != nullptr) {
|
||||
if (team != nullptr) {
|
||||
for (const auto memberId : team->members) {
|
||||
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
||||
auto* member = Game::entityManager->GetEntity(memberId);
|
||||
|
||||
if (member == nullptr) continue;
|
||||
|
||||
@@ -773,12 +761,12 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
if (team->lootOption == 0) { // Round robin
|
||||
specificOwner = TeamManager::Instance()->GetNextLootOwner(team);
|
||||
|
||||
auto* member = EntityManager::Instance()->GetEntity(specificOwner);
|
||||
auto* member = Game::entityManager->GetEntity(specificOwner);
|
||||
|
||||
if (member) LootGenerator::Instance().DropLoot(member, m_Parent, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||
} else {
|
||||
for (const auto memberId : team->members) { // Free for all
|
||||
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
||||
auto* member = Game::entityManager->GetEntity(memberId);
|
||||
|
||||
if (member == nullptr) continue;
|
||||
|
||||
@@ -791,13 +779,13 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
}
|
||||
} else {
|
||||
//Check if this zone allows coin drops
|
||||
if (dZoneManager::Instance()->GetPlayerLoseCoinOnDeath()) {
|
||||
if (Game::zoneManager->GetPlayerLoseCoinOnDeath()) {
|
||||
auto* character = m_Parent->GetCharacter();
|
||||
uint64_t coinsTotal = character->GetCoins();
|
||||
const uint64_t minCoinsToLose = dZoneManager::Instance()->GetWorldConfig()->coinsLostOnDeathMin;
|
||||
const uint64_t minCoinsToLose = Game::zoneManager->GetWorldConfig()->coinsLostOnDeathMin;
|
||||
if (coinsTotal >= minCoinsToLose) {
|
||||
const uint64_t maxCoinsToLose = dZoneManager::Instance()->GetWorldConfig()->coinsLostOnDeathMax;
|
||||
const float coinPercentageToLose = dZoneManager::Instance()->GetWorldConfig()->coinsLostOnDeathPercent;
|
||||
const uint64_t maxCoinsToLose = Game::zoneManager->GetWorldConfig()->coinsLostOnDeathMax;
|
||||
const float coinPercentageToLose = Game::zoneManager->GetWorldConfig()->coinsLostOnDeathPercent;
|
||||
|
||||
uint64_t coinsToLose = std::max(static_cast<uint64_t>(coinsTotal * coinPercentageToLose), minCoinsToLose);
|
||||
coinsToLose = std::min(maxCoinsToLose, coinsToLose);
|
||||
@@ -809,12 +797,12 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
}
|
||||
}
|
||||
|
||||
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
|
||||
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
||||
script->OnPlayerDied(zoneControl, m_Parent);
|
||||
}
|
||||
|
||||
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
||||
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
||||
for (Entity* scriptEntity : scriptedActs) {
|
||||
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
|
||||
@@ -977,7 +965,7 @@ void DestroyableComponent::FixStats() {
|
||||
destroyableComponent->SetImagination(currentImagination);
|
||||
|
||||
// Serialize the entity
|
||||
EntityManager::Instance()->SerializeEntity(entity);
|
||||
Game::entityManager->SerializeEntity(entity);
|
||||
}
|
||||
|
||||
void DestroyableComponent::AddOnHitCallback(const std::function<void(Entity*)>& callback) {
|
||||
@@ -991,12 +979,12 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
auto* character = m_Parent->GetComponent<CharacterComponent>();
|
||||
auto uscore = character->GetUScore();
|
||||
|
||||
auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100);
|
||||
auto uscoreToLose = uscore * (Game::entityManager->GetHardcoreLoseUscoreOnDeathPercent() / 100);
|
||||
character->SetUScore(uscore - uscoreToLose);
|
||||
|
||||
GameMessages::SendModifyLEGOScore(m_Parent, m_Parent->GetSystemAddress(), -uscoreToLose, eLootSourceType::MISSION);
|
||||
|
||||
if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) {
|
||||
if (Game::entityManager->GetHardcoreDropinventoryOnDeath()) {
|
||||
//drop all items from inventory:
|
||||
auto* inventory = m_Parent->GetComponent<InventoryComponent>();
|
||||
if (inventory) {
|
||||
@@ -1013,7 +1001,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
GameMessages::SendDropClientLoot(m_Parent, source, item.second->GetLot(), 0, m_Parent->GetPosition(), item.second->GetCount());
|
||||
item.second->SetCount(0, false, false);
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1033,25 +1021,25 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
|
||||
// Reload the player since we can't normally reduce uscore from the server and we want the UI to update
|
||||
// do this last so we don't get killed.... again
|
||||
EntityManager::Instance()->DestructEntity(m_Parent);
|
||||
EntityManager::Instance()->ConstructEntity(m_Parent);
|
||||
Game::entityManager->DestructEntity(m_Parent);
|
||||
Game::entityManager->ConstructEntity(m_Parent);
|
||||
return;
|
||||
}
|
||||
|
||||
//award the player some u-score:
|
||||
auto* player = EntityManager::Instance()->GetEntity(source);
|
||||
auto* player = Game::entityManager->GetEntity(source);
|
||||
if (player && player->IsPlayer()) {
|
||||
auto* playerStats = player->GetComponent<CharacterComponent>();
|
||||
if (playerStats) {
|
||||
//get the maximum health from this enemy:
|
||||
auto maxHealth = GetMaxHealth();
|
||||
|
||||
int uscore = maxHealth * EntityManager::Instance()->GetHardcoreUscoreEnemiesMultiplier();
|
||||
int uscore = maxHealth * Game::entityManager->GetHardcoreUscoreEnemiesMultiplier();
|
||||
|
||||
playerStats->SetUScore(playerStats->GetUScore() + uscore);
|
||||
GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::MISSION);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ public:
|
||||
* Returns whether or not this entity has bricks flying out when smashed
|
||||
* @return whether or not this entity has bricks flying out when smashed
|
||||
*/
|
||||
bool GetHasBricks() const { return m_HasBricks; }
|
||||
bool GetHasBricks() const { return m_IsModuleAssembly; }
|
||||
|
||||
/**
|
||||
* Sets the multiplier for the explosion that's visible when the bricks fly out when this entity is smashed
|
||||
@@ -546,7 +546,7 @@ private:
|
||||
/**
|
||||
* Whether this entity has bricks flying out when smashed (causes the client to look up the files)
|
||||
*/
|
||||
bool m_HasBricks;
|
||||
bool m_IsModuleAssembly;
|
||||
|
||||
/**
|
||||
* The rate at which bricks fly out when smashed
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "CDObjectSkillsTable.h"
|
||||
#include "CDSkillBehaviorTable.h"
|
||||
|
||||
InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document): Component(parent) {
|
||||
InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document) : Component(parent) {
|
||||
this->m_Dirty = true;
|
||||
this->m_Equipped = {};
|
||||
this->m_Pushed = {};
|
||||
@@ -826,18 +826,26 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
if (character != nullptr && !skipChecks) {
|
||||
// Hacky proximity rocket
|
||||
if (item->GetLot() == 6416) {
|
||||
const auto rocketLauchPads = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::ROCKET_LAUNCH);
|
||||
const auto rocketLauchPads = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::ROCKET_LAUNCH);
|
||||
|
||||
const auto position = m_Parent->GetPosition();
|
||||
|
||||
for (auto* lauchPad : rocketLauchPads) {
|
||||
if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
|
||||
for (auto* launchPad : rocketLauchPads) {
|
||||
if (!launchPad) continue;
|
||||
|
||||
auto prereq = launchPad->GetVarAsString(u"rocketLaunchPreCondition");
|
||||
if (!prereq.empty()) {
|
||||
PreconditionExpression expression(prereq);
|
||||
if (!expression.Check(m_Parent)) continue;
|
||||
}
|
||||
|
||||
if (Vector3::DistanceSquared(launchPad->GetPosition(), position) > 13 * 13) continue;
|
||||
|
||||
auto* characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||
|
||||
if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId());
|
||||
|
||||
lauchPad->OnUse(m_Parent);
|
||||
launchPad->OnUse(m_Parent);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -879,7 +887,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
|
||||
EquipScripts(item);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void InventoryComponent::UnEquipItem(Item* item) {
|
||||
@@ -909,12 +917,12 @@ void InventoryComponent::UnEquipItem(Item* item) {
|
||||
|
||||
UnequipScripts(item);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
// Trigger property event
|
||||
if (PropertyManagementComponent::Instance() != nullptr && item->GetCount() > 0 && Inventory::FindInventoryTypeForLot(item->GetLot()) == MODELS) {
|
||||
PropertyManagementComponent::Instance()->GetParent()->OnZonePropertyModelRemovedWhileEquipped(m_Parent);
|
||||
dZoneManager::Instance()->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_Parent);
|
||||
Game::zoneManager->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_Parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -960,7 +968,7 @@ void InventoryComponent::HandlePossession(Item* item) {
|
||||
if (possessorComponent->GetIsDismounting()) return;
|
||||
|
||||
// Check to see if we are already mounting something
|
||||
auto* currentlyPossessedEntity = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
|
||||
auto* currentlyPossessedEntity = Game::entityManager->GetEntity(possessorComponent->GetPossessable());
|
||||
auto currentlyPossessedItem = possessorComponent->GetMountItemID();
|
||||
|
||||
if (currentlyPossessedItem) {
|
||||
@@ -983,26 +991,15 @@ void InventoryComponent::HandlePossession(Item* item) {
|
||||
info.rot = startRotation;
|
||||
info.spawnerID = m_Parent->GetObjectID();
|
||||
|
||||
auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent);
|
||||
auto* mount = Game::entityManager->CreateEntity(info, nullptr, m_Parent);
|
||||
|
||||
// Check to see if the mount is a vehicle, if so, flip it
|
||||
auto* vehicleComponent = mount->GetComponent<VehiclePhysicsComponent>();
|
||||
if (vehicleComponent) {
|
||||
auto angles = startRotation.GetEulerAngles();
|
||||
// Make it right side up
|
||||
angles.x -= PI;
|
||||
// Make it going in the direction of the player
|
||||
angles.y -= PI;
|
||||
startRotation = NiQuaternion::FromEulerAngles(angles);
|
||||
mount->SetRotation(startRotation);
|
||||
// We're pod racing now
|
||||
characterComponent->SetIsRacing(true);
|
||||
}
|
||||
if (vehicleComponent) characterComponent->SetIsRacing(true);
|
||||
|
||||
// Setup the destroyable stats
|
||||
auto* destroyableComponent = mount->GetComponent<DestroyableComponent>();
|
||||
if (destroyableComponent) {
|
||||
destroyableComponent->SetIsSmashable(false);
|
||||
destroyableComponent->SetIsImmune(true);
|
||||
}
|
||||
|
||||
@@ -1019,9 +1016,9 @@ void InventoryComponent::HandlePossession(Item* item) {
|
||||
GameMessages::SendSetJetPackMode(m_Parent, false);
|
||||
|
||||
// Make it go to the client
|
||||
EntityManager::Instance()->ConstructEntity(mount);
|
||||
Game::entityManager->ConstructEntity(mount);
|
||||
// Update the possessor
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
// have to unlock the input so it vehicle can be driven
|
||||
if (vehicleComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_Parent->GetSystemAddress());
|
||||
@@ -1083,7 +1080,7 @@ void InventoryComponent::PopEquippedItems() {
|
||||
destroyableComponent->SetHealth(static_cast<int32_t>(destroyableComponent->GetMaxHealth()));
|
||||
destroyableComponent->SetArmor(static_cast<int32_t>(destroyableComponent->GetMaxArmor()));
|
||||
destroyableComponent->SetImagination(static_cast<int32_t>(destroyableComponent->GetMaxImagination()));
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
m_Dirty = true;
|
||||
@@ -1259,7 +1256,7 @@ void InventoryComponent::SpawnPet(Item* item) {
|
||||
info.rot = NiQuaternion::IDENTITY;
|
||||
info.spawnerID = m_Parent->GetObjectID();
|
||||
|
||||
auto* pet = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* pet = Game::entityManager->CreateEntity(info);
|
||||
|
||||
auto* petComponent = pet->GetComponent<PetComponent>();
|
||||
|
||||
@@ -1267,7 +1264,7 @@ void InventoryComponent::SpawnPet(Item* item) {
|
||||
petComponent->Activate(item);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(pet);
|
||||
Game::entityManager->ConstructEntity(pet);
|
||||
}
|
||||
|
||||
void InventoryComponent::SetDatabasePet(LWOOBJID id, const DatabasePet& data) {
|
||||
@@ -1376,7 +1373,7 @@ void InventoryComponent::SetNPCItems(const std::vector<LOT>& items) {
|
||||
UpdateSlot(info.equipLocation, { id, static_cast<LOT>(item), 1, slot++ }, true);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
InventoryComponent::~InventoryComponent() {
|
||||
|
||||
@@ -35,7 +35,7 @@ void LUPExhibitComponent::NextExhibit() {
|
||||
|
||||
m_Exhibit = m_Exhibits[m_ExhibitIndex];
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "InventoryComponent.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Game.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "Mail.h"
|
||||
#include "MissionPrerequisites.h"
|
||||
@@ -26,7 +26,7 @@ std::unordered_map<AchievementCacheKey, std::vector<uint32_t>> MissionComponent:
|
||||
|
||||
//! Initializer
|
||||
MissionComponent::MissionComponent(Entity* parent) : Component(parent) {
|
||||
m_LastUsedMissionOrderUID = dZoneManager::Instance()->GetUniqueMissionIdStartingValue();
|
||||
m_LastUsedMissionOrderUID = Game::zoneManager->GetUniqueMissionIdStartingValue();
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
|
||||
@@ -377,7 +377,7 @@ bool MovementAIComponent::Warp(const NiPoint3& point) {
|
||||
|
||||
SetPosition(destination);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -406,7 +406,7 @@ void MovementAIComponent::Stop() {
|
||||
|
||||
m_CurrentSpeed = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void MovementAIComponent::PullToPoint(const NiPoint3& point) {
|
||||
@@ -448,13 +448,14 @@ float MovementAIComponent::GetBaseSpeed(LOT lot) {
|
||||
|
||||
foundComponent:
|
||||
|
||||
float speed;
|
||||
// Client defaults speed to 10 and if the speed is also null in the table, it defaults to 10.
|
||||
float speed = 10.0f;
|
||||
|
||||
if (physicsComponent == nullptr) {
|
||||
speed = 8;
|
||||
} else {
|
||||
speed = physicsComponent->speed;
|
||||
}
|
||||
if (physicsComponent) speed = physicsComponent->speed;
|
||||
|
||||
float delta = fabs(speed) - 1.0f;
|
||||
|
||||
if (delta <= std::numeric_limits<float>::epsilon()) speed = 10.0f;
|
||||
|
||||
m_PhysicsSpeedCache[lot] = speed;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ MovingPlatformComponent::MovingPlatformComponent(Entity* parent, const std::stri
|
||||
m_MoverSubComponentType = eMoverSubComponentType::mover;
|
||||
m_MoverSubComponent = new MoverSubComponent(m_Parent->GetDefaultPosition());
|
||||
m_PathName = GeneralUtils::ASCIIToUTF16(pathName);
|
||||
m_Path = dZoneManager::Instance()->GetZone()->GetPath(pathName);
|
||||
m_Path = Game::zoneManager->GetZone()->GetPath(pathName);
|
||||
m_NoAutoStart = false;
|
||||
|
||||
if (m_Path == nullptr) {
|
||||
@@ -133,7 +133,7 @@ void MovingPlatformComponent::SetMovementState(eMovementPlatformState value) {
|
||||
|
||||
subComponent->mState = value;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint) {
|
||||
@@ -194,7 +194,7 @@ void MovingPlatformComponent::StartPathing() {
|
||||
|
||||
//GameMessages::SendPlatformResync(m_Parent, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void MovingPlatformComponent::ContinuePathing() {
|
||||
@@ -242,7 +242,7 @@ void MovingPlatformComponent::ContinuePathing() {
|
||||
subComponent->mCurrentWaypointIndex = pathSize;
|
||||
switch (behavior) {
|
||||
case PathBehavior::Once:
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
return;
|
||||
|
||||
case PathBehavior::Bounce:
|
||||
@@ -304,7 +304,7 @@ void MovingPlatformComponent::ContinuePathing() {
|
||||
ContinuePathing();
|
||||
});
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void MovingPlatformComponent::StopPathing() {
|
||||
@@ -318,7 +318,7 @@ void MovingPlatformComponent::StopPathing() {
|
||||
subComponent->mDesiredWaypointIndex = -1;
|
||||
subComponent->mShouldStopAtDesiredWaypoint = false;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
//GameMessages::SendPlatformResync(m_Parent, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
@@ -341,7 +341,7 @@ void MovingPlatformComponent::WarpToWaypoint(size_t index) {
|
||||
m_Parent->SetPosition(waypoint.position);
|
||||
m_Parent->SetRotation(waypoint.rotation);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
size_t MovingPlatformComponent::GetLastWaypointIndex() const {
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "Database.h"
|
||||
#include "EntityInfo.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
|
||||
@@ -153,7 +154,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
}
|
||||
|
||||
if (m_Tamer != LWOOBJID_EMPTY) {
|
||||
auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer);
|
||||
auto* tamer = Game::entityManager->GetEntity(m_Tamer);
|
||||
|
||||
if (tamer != nullptr) {
|
||||
return;
|
||||
@@ -235,7 +236,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto& bricks = BrickDatabase::Instance()->GetBricks(buildFile);
|
||||
const auto& bricks = BrickDatabase::GetBricks(buildFile);
|
||||
|
||||
if (bricks.empty()) {
|
||||
ChatPackets::SendSystemMessage(originator->GetSystemAddress(), u"Failed to load the puzzle minigame for this pet.");
|
||||
@@ -343,7 +344,7 @@ void PetComponent::Update(float deltaTime) {
|
||||
|
||||
if (m_Timer <= 0) {
|
||||
Wander();
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
} else {
|
||||
m_Timer = 5;
|
||||
@@ -368,7 +369,7 @@ void PetComponent::Update(float deltaTime) {
|
||||
}
|
||||
|
||||
if (m_TresureTime > 0) {
|
||||
auto* tresure = EntityManager::Instance()->GetEntity(m_Interaction);
|
||||
auto* tresure = Game::entityManager->GetEntity(m_Interaction);
|
||||
|
||||
if (tresure == nullptr) {
|
||||
m_TresureTime = 0;
|
||||
@@ -448,7 +449,7 @@ void PetComponent::Update(float deltaTime) {
|
||||
|
||||
NiPoint3 tresurePosition = closestTresure->GetPosition();
|
||||
float distance = Vector3::DistanceSquared(position, tresurePosition);
|
||||
if (distance < 3 * 3) {
|
||||
if (distance < 5 * 5) {
|
||||
m_Interaction = closestTresure->GetObjectID();
|
||||
|
||||
Command(NiPoint3::ZERO, LWOOBJID_EMPTY, 1, 202, true);
|
||||
@@ -475,7 +476,7 @@ skipTresure:
|
||||
void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
|
||||
if (m_Tamer == LWOOBJID_EMPTY) return;
|
||||
|
||||
auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer);
|
||||
auto* tamer = Game::entityManager->GetEntity(m_Tamer);
|
||||
|
||||
if (tamer == nullptr) {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
@@ -497,7 +498,7 @@ void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
|
||||
|
||||
destroyableComponent->SetImagination(imagination);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(tamer);
|
||||
Game::entityManager->SerializeEntity(tamer);
|
||||
|
||||
if (clientFailed) {
|
||||
if (imagination < cached->second.imaginationCost) {
|
||||
@@ -515,7 +516,7 @@ void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
|
||||
void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
if (m_Tamer == LWOOBJID_EMPTY) return;
|
||||
|
||||
auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer);
|
||||
auto* tamer = Game::entityManager->GetEntity(m_Tamer);
|
||||
|
||||
if (tamer == nullptr) {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
@@ -530,7 +531,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
}
|
||||
|
||||
GameMessages::SendPlayFXEffect(tamer, -1, u"petceleb", "", LWOOBJID_EMPTY, 1, 1, true);
|
||||
GameMessages::SendPlayAnimation(tamer, u"rebuild-celebrate");
|
||||
RenderComponent::PlayAnimation(tamer, u"rebuild-celebrate");
|
||||
|
||||
EntityInfo info{};
|
||||
info.lot = cached->second.puzzleModelLot;
|
||||
@@ -538,11 +539,11 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
info.rot = NiQuaternion::IDENTITY;
|
||||
info.spawnerID = tamer->GetObjectID();
|
||||
|
||||
auto* modelEntity = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* modelEntity = Game::entityManager->CreateEntity(info);
|
||||
|
||||
m_ModelId = modelEntity->GetObjectID();
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(modelEntity);
|
||||
Game::entityManager->ConstructEntity(modelEntity);
|
||||
|
||||
GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress());
|
||||
|
||||
@@ -638,7 +639,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer);
|
||||
auto* tamer = Game::entityManager->GetEntity(m_Tamer);
|
||||
|
||||
if (tamer == nullptr) {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
@@ -660,7 +661,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
||||
//Save our pet's new name to the db:
|
||||
SetPetNameForModeration(GeneralUtils::UTF16ToWTF8(name));
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
std::u16string u16name = GeneralUtils::UTF8ToUTF16(m_Name);
|
||||
std::u16string u16ownerName = GeneralUtils::UTF8ToUTF16(m_OwnerName);
|
||||
@@ -683,7 +684,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
||||
|
||||
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_Parent->GetObjectID());
|
||||
|
||||
auto* modelEntity = EntityManager::Instance()->GetEntity(m_ModelId);
|
||||
auto* modelEntity = Game::entityManager->GetEntity(m_ModelId);
|
||||
|
||||
if (modelEntity != nullptr) {
|
||||
modelEntity->Smash(m_Tamer);
|
||||
@@ -702,7 +703,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
||||
void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
||||
if (m_Tamer == LWOOBJID_EMPTY) return;
|
||||
|
||||
auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer);
|
||||
auto* tamer = Game::entityManager->GetEntity(m_Tamer);
|
||||
|
||||
if (tamer == nullptr) {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
@@ -732,7 +733,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
m_Timer = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
// Notify the end of a pet taming minigame
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
||||
@@ -753,7 +754,7 @@ void PetComponent::StartTimer() {
|
||||
void PetComponent::ClientFailTamingMinigame() {
|
||||
if (m_Tamer == LWOOBJID_EMPTY) return;
|
||||
|
||||
auto* tamer = EntityManager::Instance()->GetEntity(m_Tamer);
|
||||
auto* tamer = Game::entityManager->GetEntity(m_Tamer);
|
||||
|
||||
if (tamer == nullptr) {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
@@ -783,7 +784,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
m_Timer = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
// Notify the end of a pet taming minigame
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_Parent)) {
|
||||
@@ -886,7 +887,7 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
|
||||
|
||||
m_Timer = 3;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
owner->GetCharacter()->SetPlayerFlag(ePlayerFlag::FIRST_MANUAL_PET_HIBERNATE, true);
|
||||
|
||||
@@ -1003,7 +1004,7 @@ LWOOBJID PetComponent::GetOwnerId() const {
|
||||
}
|
||||
|
||||
Entity* PetComponent::GetOwner() const {
|
||||
return EntityManager::Instance()->GetEntity(m_Owner);
|
||||
return Game::entityManager->GetEntity(m_Owner);
|
||||
}
|
||||
|
||||
LWOOBJID PetComponent::GetDatabaseId() const {
|
||||
@@ -1045,7 +1046,7 @@ PetComponent* PetComponent::GetTamingPet(LWOOBJID tamer) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(pair->second);
|
||||
auto* entity = Game::entityManager->GetEntity(pair->second);
|
||||
|
||||
if (entity == nullptr) {
|
||||
currentActivities.erase(tamer);
|
||||
@@ -1063,7 +1064,7 @@ PetComponent* PetComponent::GetActivePet(LWOOBJID owner) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(pair->second);
|
||||
auto* entity = Game::entityManager->GetEntity(pair->second);
|
||||
|
||||
if (entity == nullptr) {
|
||||
activePets.erase(owner);
|
||||
|
||||
@@ -362,7 +362,7 @@ void PhantomPhysicsComponent::Update(float deltaTime) {
|
||||
|
||||
//If we are a respawn volume, inform the client:
|
||||
if (m_IsRespawnVolume) {
|
||||
auto entity = EntityManager::Instance()->GetEntity(en->GetObjectID());
|
||||
auto entity = Game::entityManager->GetEntity(en->GetObjectID());
|
||||
|
||||
if (entity) {
|
||||
GameMessages::SendPlayerReachedRespawnCheckpoint(entity, m_RespawnPos, m_RespawnRot);
|
||||
@@ -403,8 +403,8 @@ void PhantomPhysicsComponent::SpawnVertices() {
|
||||
info.spawnerID = m_Parent->GetObjectID();
|
||||
info.spawnerNodeID = 0;
|
||||
|
||||
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
||||
EntityManager::Instance()->ConstructEntity(newEntity);
|
||||
Entity* newEntity = Game::entityManager->CreateEntity(info, nullptr);
|
||||
Game::entityManager->ConstructEntity(newEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ PossessorComponent::PossessorComponent(Entity* parent) : Component(parent) {
|
||||
|
||||
PossessorComponent::~PossessorComponent() {
|
||||
if (m_Possessable != LWOOBJID_EMPTY) {
|
||||
auto* mount = EntityManager::Instance()->GetEntity(m_Possessable);
|
||||
auto* mount = Game::entityManager->GetEntity(m_Possessable);
|
||||
if (mount) {
|
||||
auto* possessable = mount->GetComponent<PossessableComponent>();
|
||||
if (possessable) {
|
||||
@@ -58,8 +58,8 @@ void PossessorComponent::Mount(Entity* mount) {
|
||||
GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_Parent->GetSystemAddress());
|
||||
GameMessages::SendSetStunned(m_Parent->GetObjectID(), eStateChangeType::PUSH, m_Parent->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
EntityManager::Instance()->SerializeEntity(mount);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(mount);
|
||||
}
|
||||
|
||||
void PossessorComponent::Dismount(Entity* mount, bool forceDismount) {
|
||||
@@ -73,8 +73,8 @@ void PossessorComponent::Dismount(Entity* mount, bool forceDismount) {
|
||||
possessableComponent->SetPossessor(LWOOBJID_EMPTY);
|
||||
if (forceDismount) possessableComponent->ForceDepossess();
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
EntityManager::Instance()->SerializeEntity(mount);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(mount);
|
||||
|
||||
auto characterComponent = m_Parent->GetComponent<CharacterComponent>();
|
||||
if (characterComponent) characterComponent->SetIsRacing(false);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "CharacterComponent.h"
|
||||
#include "UserManager.h"
|
||||
#include "dLogger.h"
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "eObjectBits.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
|
||||
@@ -36,12 +36,9 @@ void PropertyEntranceComponent::OnUse(Entity* entity) {
|
||||
|
||||
AMFArrayValue args;
|
||||
|
||||
auto* state = new AMFStringValue();
|
||||
state->SetStringValue("property_menu");
|
||||
args.Insert("state", "property_menu");
|
||||
|
||||
args.InsertValue("state", state);
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", &args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", args);
|
||||
}
|
||||
|
||||
void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index, bool returnToZone, const SystemAddress& sysAddr) {
|
||||
|
||||
@@ -38,7 +38,7 @@ PropertyManagementComponent::PropertyManagementComponent(Entity* parent) : Compo
|
||||
|
||||
instance = this;
|
||||
|
||||
const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID();
|
||||
const auto& worldId = Game::zoneManager->GetZone()->GetZoneID();
|
||||
|
||||
const auto zoneId = worldId.GetMapID();
|
||||
const auto cloneId = worldId.GetCloneID();
|
||||
@@ -90,7 +90,7 @@ LWOOBJID PropertyManagementComponent::GetOwnerId() const {
|
||||
}
|
||||
|
||||
Entity* PropertyManagementComponent::GetOwner() const {
|
||||
return EntityManager::Instance()->GetEntity(owner);
|
||||
return Game::entityManager->GetEntity(owner);
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::SetOwner(Entity* value) {
|
||||
@@ -98,7 +98,7 @@ void PropertyManagementComponent::SetOwner(Entity* value) {
|
||||
}
|
||||
|
||||
std::vector<NiPoint3> PropertyManagementComponent::GetPaths() const {
|
||||
const auto zoneId = dZoneManager::Instance()->GetZone()->GetWorldID();
|
||||
const auto zoneId = Game::zoneManager->GetZone()->GetWorldID();
|
||||
|
||||
auto query = CDClientDatabase::CreatePreppedStmt(
|
||||
"SELECT path FROM PropertyTemplate WHERE mapID = ?;");
|
||||
@@ -185,14 +185,14 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(playerId);
|
||||
auto* entity = Game::entityManager->GetEntity(playerId);
|
||||
|
||||
auto* user = entity->GetParentUser();
|
||||
|
||||
auto character = entity->GetCharacter();
|
||||
if (!character) return false;
|
||||
|
||||
auto* zone = dZoneManager::Instance()->GetZone();
|
||||
auto* zone = Game::zoneManager->GetZone();
|
||||
|
||||
const auto& worldId = zone->GetZoneID();
|
||||
const auto propertyZoneId = worldId.GetMapID();
|
||||
@@ -240,7 +240,7 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* zoneControlObject = dZoneManager::Instance()->GetZoneControlObject();
|
||||
auto* zoneControlObject = Game::zoneManager->GetZoneControlObject();
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControlObject)) {
|
||||
script->OnZonePropertyRented(zoneControlObject, entity);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ void PropertyManagementComponent::OnStartBuilding() {
|
||||
|
||||
LWOMAPID zoneId = 1100;
|
||||
|
||||
const auto entrance = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::PROPERTY_ENTRANCE);
|
||||
const auto entrance = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::PROPERTY_ENTRANCE);
|
||||
|
||||
originalPrivacyOption = privacyOption;
|
||||
|
||||
@@ -339,9 +339,9 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
||||
info.settings.push_back(setting->Copy());
|
||||
}
|
||||
|
||||
Entity* newEntity = EntityManager::Instance()->CreateEntity(info);
|
||||
Entity* newEntity = Game::entityManager->CreateEntity(info);
|
||||
if (newEntity != nullptr) {
|
||||
EntityManager::Instance()->ConstructEntity(newEntity);
|
||||
Game::entityManager->ConstructEntity(newEntity);
|
||||
|
||||
// Make sure the propMgmt doesn't delete our model after the server dies
|
||||
// Trying to do this after the entity is constructed. Shouldn't really change anything but
|
||||
@@ -371,14 +371,14 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
||||
info.respawnTime = 10;
|
||||
|
||||
info.emulated = true;
|
||||
info.emulator = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID();
|
||||
info.emulator = Game::entityManager->GetZoneControlEntity()->GetObjectID();
|
||||
|
||||
info.spawnerID = persistentId;
|
||||
GeneralUtils::SetBit(info.spawnerID, eObjectBits::CLIENT);
|
||||
|
||||
const auto spawnerId = dZoneManager::Instance()->MakeSpawner(info);
|
||||
const auto spawnerId = Game::zoneManager->MakeSpawner(info);
|
||||
|
||||
auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId);
|
||||
auto* spawner = Game::zoneManager->GetSpawner(spawnerId);
|
||||
|
||||
auto ldfModelBehavior = new LDFData<LWOOBJID>(u"modelBehaviors", 0);
|
||||
auto userModelID = new LDFData<LWOOBJID>(u"userModelID", info.spawnerID);
|
||||
@@ -401,7 +401,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
||||
|
||||
GameMessages::SendGetModelsOnProperty(entity->GetObjectID(), GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
EntityManager::Instance()->GetZoneControlEntity()->OnZonePropertyModelPlaced(entity);
|
||||
Game::entityManager->GetZoneControlEntity()->OnZonePropertyModelPlaced(entity);
|
||||
});
|
||||
// Progress place model missions
|
||||
auto missionComponent = entity->GetComponent<MissionComponent>();
|
||||
@@ -433,7 +433,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
|
||||
const auto spawnerId = index->second;
|
||||
|
||||
auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId);
|
||||
auto* spawner = Game::zoneManager->GetSpawner(spawnerId);
|
||||
|
||||
models.erase(id);
|
||||
|
||||
@@ -441,7 +441,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
Game::logger->Log("PropertyManagementComponent", "Failed to find spawner");
|
||||
}
|
||||
|
||||
auto* model = EntityManager::Instance()->GetEntity(id);
|
||||
auto* model = Game::entityManager->GetEntity(id);
|
||||
|
||||
if (model == nullptr) {
|
||||
Game::logger->Log("PropertyManagementComponent", "Failed to find model entity");
|
||||
@@ -449,7 +449,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
return;
|
||||
}
|
||||
|
||||
EntityManager::Instance()->DestructEntity(model);
|
||||
Game::entityManager->DestructEntity(model);
|
||||
|
||||
Game::logger->Log("PropertyManagementComponent", "Deleting model LOT %i", model->GetLOT());
|
||||
|
||||
@@ -496,7 +496,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3::ZERO, LWOOBJID_EMPTY, 16, NiQuaternion::IDENTITY);
|
||||
|
||||
if (spawner != nullptr) {
|
||||
dZoneManager::Instance()->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||
Game::zoneManager->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||
} else {
|
||||
model->Smash(LWOOBJID_EMPTY, eKillType::SILENT);
|
||||
}
|
||||
@@ -520,13 +520,13 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
item->Equip();
|
||||
|
||||
GameMessages::SendUGCEquipPostDeleteBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), item->GetId(), item->GetCount());
|
||||
EntityManager::Instance()->GetZoneControlEntity()->OnZonePropertyModelPickedUp(entity);
|
||||
Game::entityManager->GetZoneControlEntity()->OnZonePropertyModelPickedUp(entity);
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: // Return to inv
|
||||
{
|
||||
EntityManager::Instance()->GetZoneControlEntity()->OnZonePropertyModelRemoved(entity);
|
||||
Game::entityManager->GetZoneControlEntity()->OnZonePropertyModelRemoved(entity);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -549,7 +549,7 @@ void PropertyManagementComponent::DeleteModel(const LWOOBJID id, const int delet
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), NiPoint3::ZERO, LWOOBJID_EMPTY, 16, NiQuaternion::IDENTITY);
|
||||
|
||||
if (spawner != nullptr) {
|
||||
dZoneManager::Instance()->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||
Game::zoneManager->RemoveSpawner(spawner->m_Info.spawnerID);
|
||||
} else {
|
||||
model->Smash(LWOOBJID_EMPTY, eKillType::SILENT);
|
||||
}
|
||||
@@ -613,7 +613,7 @@ void PropertyManagementComponent::Load() {
|
||||
info.respawnTime = 10;
|
||||
|
||||
//info.emulated = true;
|
||||
//info.emulator = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID();
|
||||
//info.emulator = Game::entityManager->GetZoneControlEntity()->GetObjectID();
|
||||
|
||||
info.spawnerID = id;
|
||||
|
||||
@@ -652,9 +652,9 @@ void PropertyManagementComponent::Load() {
|
||||
|
||||
node->config = settings;
|
||||
|
||||
const auto spawnerId = dZoneManager::Instance()->MakeSpawner(info);
|
||||
const auto spawnerId = Game::zoneManager->MakeSpawner(info);
|
||||
|
||||
auto* spawner = dZoneManager::Instance()->GetSpawner(spawnerId);
|
||||
auto* spawner = Game::zoneManager->GetSpawner(spawnerId);
|
||||
|
||||
auto* model = spawner->Spawn();
|
||||
|
||||
@@ -698,7 +698,7 @@ void PropertyManagementComponent::Save() {
|
||||
|
||||
modelIds.push_back(id);
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(pair.first);
|
||||
auto* entity = Game::entityManager->GetEntity(pair.first);
|
||||
|
||||
if (entity == nullptr) {
|
||||
continue;
|
||||
@@ -786,7 +786,7 @@ void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const
|
||||
author = m_Parent->GetObjectID();
|
||||
}
|
||||
|
||||
const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID();
|
||||
const auto& worldId = Game::zoneManager->GetZone()->GetZoneID();
|
||||
const auto zoneId = worldId.GetMapID();
|
||||
|
||||
Game::logger->Log("Properties", "Getting property info for %d", zoneId);
|
||||
|
||||
@@ -43,7 +43,7 @@ void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool con
|
||||
|
||||
GameMessages::SendPropertyRentalResponse(m_Parent->GetObjectID(), 0, 0, 0, 0, originator->GetSystemAddress());
|
||||
|
||||
auto* controller = dZoneManager::Instance()->GetZoneControlObject();
|
||||
auto* controller = Game::zoneManager->GetZoneControlObject();
|
||||
|
||||
controller->OnFireEventServerSide(m_Parent, "propertyRented");
|
||||
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#include "dConfig.h"
|
||||
#include "Loot.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "LeaderboardManager.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "CDActivitiesTable.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327950288
|
||||
@@ -45,36 +48,14 @@ RacingControlComponent::RacingControlComponent(Entity* parent)
|
||||
m_EmptyTimer = 0;
|
||||
m_SoloRacing = Game::config->GetValue("solo_racing") == "1";
|
||||
|
||||
// Select the main world ID as fallback when a player fails to load.
|
||||
|
||||
m_MainWorld = 1200;
|
||||
const auto worldID = Game::server->GetZoneID();
|
||||
if (Game::zoneManager->CheckIfAccessibleZone((worldID/10)*10)) m_MainWorld = (worldID/10)*10;
|
||||
|
||||
switch (worldID) {
|
||||
case 1203:
|
||||
m_ActivityID = 42;
|
||||
m_MainWorld = 1200;
|
||||
break;
|
||||
|
||||
case 1261:
|
||||
m_ActivityID = 60;
|
||||
m_MainWorld = 1260;
|
||||
break;
|
||||
|
||||
case 1303:
|
||||
m_ActivityID = 39;
|
||||
m_MainWorld = 1300;
|
||||
break;
|
||||
|
||||
case 1403:
|
||||
m_ActivityID = 54;
|
||||
m_MainWorld = 1400;
|
||||
break;
|
||||
|
||||
default:
|
||||
m_ActivityID = 42;
|
||||
m_MainWorld = 1200;
|
||||
break;
|
||||
}
|
||||
m_ActivityID = 42;
|
||||
CDActivitiesTable* activitiesTable = CDClientManager::Instance().GetTable<CDActivitiesTable>();
|
||||
std::vector<CDActivities> activities = activitiesTable->Query([=](CDActivities entry) {return (entry.instanceMapID == worldID); });
|
||||
for (CDActivities activity : activities) m_ActivityID = activity.ActivityID;
|
||||
}
|
||||
|
||||
RacingControlComponent::~RacingControlComponent() {}
|
||||
@@ -125,10 +106,10 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
|
||||
// Calculate the vehicle's starting position.
|
||||
|
||||
auto* path = dZoneManager::Instance()->GetZone()->GetPath(
|
||||
auto* path = Game::zoneManager->GetZone()->GetPath(
|
||||
GeneralUtils::UTF16ToWTF8(m_PathName));
|
||||
|
||||
auto spawnPointEntities = EntityManager::Instance()->GetEntitiesByLOT(4843);
|
||||
auto spawnPointEntities = Game::entityManager->GetEntitiesByLOT(4843);
|
||||
auto startPosition = NiPoint3::ZERO;
|
||||
auto startRotation = NiQuaternion::IDENTITY;
|
||||
const std::string placementAsString = std::to_string(positionNumber);
|
||||
@@ -144,8 +125,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
// Make sure the player is at the correct position.
|
||||
|
||||
GameMessages::SendTeleport(player->GetObjectID(), startPosition,
|
||||
startRotation, player->GetSystemAddress(), true,
|
||||
true);
|
||||
startRotation, player->GetSystemAddress(), true);
|
||||
|
||||
// Spawn the vehicle entity.
|
||||
|
||||
@@ -156,7 +136,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
info.spawnerID = m_Parent->GetObjectID();
|
||||
|
||||
auto* carEntity =
|
||||
EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent);
|
||||
Game::entityManager->CreateEntity(info, nullptr, m_Parent);
|
||||
|
||||
// Make the vehicle a child of the racing controller.
|
||||
m_Parent->AddChild(carEntity);
|
||||
@@ -227,9 +207,9 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
|
||||
// Construct and serialize everything when done.
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(carEntity);
|
||||
EntityManager::Instance()->SerializeEntity(player);
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->ConstructEntity(carEntity);
|
||||
Game::entityManager->SerializeEntity(player);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
GameMessages::SendRacingSetPlayerResetInfo(
|
||||
m_Parent->GetObjectID(), 0, 0, player->GetObjectID(), startPosition, 1,
|
||||
@@ -240,7 +220,7 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
// Reset the player to the start position during downtime, in case something
|
||||
// went wrong.
|
||||
m_Parent->AddCallbackTimer(1, [this, playerID]() {
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
@@ -263,11 +243,9 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
|
||||
// Make sure everything has the correct position.
|
||||
GameMessages::SendTeleport(player->GetObjectID(), startPosition,
|
||||
startRotation, player->GetSystemAddress(), true,
|
||||
true);
|
||||
startRotation, player->GetSystemAddress(), true);
|
||||
GameMessages::SendTeleport(carEntity->GetObjectID(), startPosition,
|
||||
startRotation, player->GetSystemAddress(), true,
|
||||
true);
|
||||
startRotation, player->GetSystemAddress(), true);
|
||||
}
|
||||
|
||||
void RacingControlComponent::OnRacingClientReady(Entity* player) {
|
||||
@@ -291,7 +269,7 @@ void RacingControlComponent::OnRacingClientReady(Entity* player) {
|
||||
racingPlayer.vehicleID, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void RacingControlComponent::OnRequestDie(Entity* player) {
|
||||
@@ -304,7 +282,7 @@ void RacingControlComponent::OnRequestDie(Entity* player) {
|
||||
}
|
||||
|
||||
auto* vehicle =
|
||||
EntityManager::Instance()->GetEntity(racingPlayer.vehicleID);
|
||||
Game::entityManager->GetEntity(racingPlayer.vehicleID);
|
||||
|
||||
if (!vehicle) return;
|
||||
|
||||
@@ -341,7 +319,7 @@ void RacingControlComponent::OnRequestDie(Entity* player) {
|
||||
auto* destroyableComponent = vehicle->GetComponent<DestroyableComponent>();
|
||||
// Reset imagination to half its current value, rounded up to the nearest value divisible by 10, as it was done in live.
|
||||
if (destroyableComponent) destroyableComponent->SetImagination(respawnImagination);
|
||||
EntityManager::Instance()->SerializeEntity(vehicle);
|
||||
Game::entityManager->SerializeEntity(vehicle);
|
||||
});
|
||||
|
||||
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
||||
@@ -370,7 +348,7 @@ void RacingControlComponent::OnRacingPlayerInfoResetFinished(Entity* player) {
|
||||
}
|
||||
|
||||
auto* vehicle =
|
||||
EntityManager::Instance()->GetEntity(racingPlayer.vehicleID);
|
||||
Game::entityManager->GetEntity(racingPlayer.vehicleID);
|
||||
|
||||
if (vehicle == nullptr) {
|
||||
return;
|
||||
@@ -382,8 +360,7 @@ void RacingControlComponent::OnRacingPlayerInfoResetFinished(Entity* player) {
|
||||
}
|
||||
}
|
||||
|
||||
void RacingControlComponent::HandleMessageBoxResponse(Entity* player,
|
||||
const std::string& id) {
|
||||
void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t button, const std::string& id) {
|
||||
auto* data = GetPlayerData(player->GetObjectID());
|
||||
|
||||
if (data == nullptr) {
|
||||
@@ -391,15 +368,17 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player,
|
||||
}
|
||||
|
||||
if (id == "rewardButton") {
|
||||
if (data->collectedRewards) {
|
||||
return;
|
||||
}
|
||||
if (data->collectedRewards) return;
|
||||
|
||||
data->collectedRewards = true;
|
||||
|
||||
// Calculate the score, different loot depending on player count
|
||||
const auto score = m_LoadedPlayers * 10 + data->finished;
|
||||
auto playersRating = m_LoadedPlayers;
|
||||
if(m_LoadedPlayers == 1 && m_SoloRacing) {
|
||||
playersRating *= 2;
|
||||
}
|
||||
|
||||
const auto score = playersRating * 10 + data->finished;
|
||||
LootGenerator::Instance().GiveActivityLoot(player, m_Parent, m_ActivityID, score);
|
||||
|
||||
// Giving rewards
|
||||
@@ -418,15 +397,15 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player,
|
||||
if (m_SoloRacing || m_LoadedPlayers > 2) {
|
||||
missionComponent->Progress(eMissionTaskType::RACING, data->finished, (LWOOBJID)eRacingTaskParam::FINISH_WITH_PLACEMENT); // Finish in 1st place on a race
|
||||
if (data->finished == 1) {
|
||||
missionComponent->Progress(eMissionTaskType::RACING, dZoneManager::Instance()->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::FIRST_PLACE_MULTIPLE_TRACKS); // Finish in 1st place on multiple tracks.
|
||||
missionComponent->Progress(eMissionTaskType::RACING, dZoneManager::Instance()->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::WIN_RACE_IN_WORLD); // Finished first place in specific world.
|
||||
missionComponent->Progress(eMissionTaskType::RACING, Game::zoneManager->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::FIRST_PLACE_MULTIPLE_TRACKS); // Finish in 1st place on multiple tracks.
|
||||
missionComponent->Progress(eMissionTaskType::RACING, Game::zoneManager->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::WIN_RACE_IN_WORLD); // Finished first place in specific world.
|
||||
}
|
||||
if (data->finished == m_LoadedPlayers) {
|
||||
missionComponent->Progress(eMissionTaskType::RACING, dZoneManager::Instance()->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::LAST_PLACE_FINISH); // Finished first place in specific world.
|
||||
missionComponent->Progress(eMissionTaskType::RACING, Game::zoneManager->GetZone()->GetWorldID(), (LWOOBJID)eRacingTaskParam::LAST_PLACE_FINISH); // Finished first place in specific world.
|
||||
}
|
||||
}
|
||||
} else if (id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") {
|
||||
auto* vehicle = EntityManager::Instance()->GetEntity(data->vehicleID);
|
||||
} else if ((id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") && button == m_ActivityExitConfirm) {
|
||||
auto* vehicle = Game::entityManager->GetEntity(data->vehicleID);
|
||||
|
||||
if (vehicle == nullptr) {
|
||||
return;
|
||||
@@ -527,7 +506,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
// Check if any players has disconnected before loading in
|
||||
for (size_t i = 0; i < m_LobbyPlayers.size(); i++) {
|
||||
auto* playerEntity =
|
||||
EntityManager::Instance()->GetEntity(m_LobbyPlayers[i]);
|
||||
Game::entityManager->GetEntity(m_LobbyPlayers[i]);
|
||||
|
||||
if (playerEntity == nullptr) {
|
||||
--m_LoadedPlayers;
|
||||
@@ -549,7 +528,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
if (m_EmptyTimer >= 30) {
|
||||
for (const auto player : m_LobbyPlayers) {
|
||||
auto* playerEntity =
|
||||
EntityManager::Instance()->GetEntity(player);
|
||||
Game::entityManager->GetEntity(player);
|
||||
|
||||
if (playerEntity == nullptr) {
|
||||
continue;
|
||||
@@ -574,7 +553,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
"Loading player now!");
|
||||
|
||||
auto* player =
|
||||
EntityManager::Instance()->GetEntity(m_LobbyPlayers[positionNumber]);
|
||||
Game::entityManager->GetEntity(m_LobbyPlayers[positionNumber]);
|
||||
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
@@ -598,7 +577,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
if (!m_Started) {
|
||||
// Check if anyone has disconnected during this period
|
||||
for (size_t i = 0; i < m_RacingPlayers.size(); i++) {
|
||||
auto* playerEntity = EntityManager::Instance()->GetEntity(
|
||||
auto* playerEntity = Game::entityManager->GetEntity(
|
||||
m_RacingPlayers[i].playerID);
|
||||
|
||||
if (playerEntity == nullptr) {
|
||||
@@ -614,7 +593,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
if (m_LoadedPlayers < 2 && !(m_LoadedPlayers == 1 && m_SoloRacing)) {
|
||||
for (const auto player : m_LobbyPlayers) {
|
||||
auto* playerEntity =
|
||||
EntityManager::Instance()->GetEntity(player);
|
||||
Game::entityManager->GetEntity(player);
|
||||
|
||||
if (playerEntity == nullptr) {
|
||||
continue;
|
||||
@@ -647,15 +626,15 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
|
||||
for (const auto& player : m_RacingPlayers) {
|
||||
auto* vehicle =
|
||||
EntityManager::Instance()->GetEntity(player.vehicleID);
|
||||
Game::entityManager->GetEntity(player.vehicleID);
|
||||
auto* playerEntity =
|
||||
EntityManager::Instance()->GetEntity(player.playerID);
|
||||
Game::entityManager->GetEntity(player.playerID);
|
||||
|
||||
if (vehicle != nullptr && playerEntity != nullptr) {
|
||||
GameMessages::SendTeleport(
|
||||
player.playerID, player.respawnPosition,
|
||||
player.respawnRotation,
|
||||
playerEntity->GetSystemAddress(), true, true);
|
||||
playerEntity->GetSystemAddress(), true);
|
||||
|
||||
vehicle->SetPosition(player.respawnPosition);
|
||||
vehicle->SetRotation(player.respawnRotation);
|
||||
@@ -667,18 +646,18 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
destroyableComponent->SetImagination(0);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(vehicle);
|
||||
EntityManager::Instance()->SerializeEntity(
|
||||
Game::entityManager->SerializeEntity(vehicle);
|
||||
Game::entityManager->SerializeEntity(
|
||||
playerEntity);
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn imagination pickups
|
||||
auto* minSpawner = dZoneManager::Instance()->GetSpawnersByName(
|
||||
auto* minSpawner = Game::zoneManager->GetSpawnersByName(
|
||||
"ImaginationSpawn_Min")[0];
|
||||
auto* medSpawner = dZoneManager::Instance()->GetSpawnersByName(
|
||||
auto* medSpawner = Game::zoneManager->GetSpawnersByName(
|
||||
"ImaginationSpawn_Med")[0];
|
||||
auto* maxSpawner = dZoneManager::Instance()->GetSpawnersByName(
|
||||
auto* maxSpawner = Game::zoneManager->GetSpawnersByName(
|
||||
"ImaginationSpawn_Max")[0];
|
||||
|
||||
minSpawner->Activate();
|
||||
@@ -694,9 +673,9 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
// Reset players to their start location, without smashing them
|
||||
for (auto& player : m_RacingPlayers) {
|
||||
auto* vehicleEntity =
|
||||
EntityManager::Instance()->GetEntity(player.vehicleID);
|
||||
Game::entityManager->GetEntity(player.vehicleID);
|
||||
auto* playerEntity =
|
||||
EntityManager::Instance()->GetEntity(player.playerID);
|
||||
Game::entityManager->GetEntity(player.playerID);
|
||||
|
||||
if (vehicleEntity == nullptr || playerEntity == nullptr) {
|
||||
continue;
|
||||
@@ -713,9 +692,9 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
// Activate the players movement
|
||||
for (auto& player : m_RacingPlayers) {
|
||||
auto* vehicleEntity =
|
||||
EntityManager::Instance()->GetEntity(player.vehicleID);
|
||||
Game::entityManager->GetEntity(player.vehicleID);
|
||||
auto* playerEntity =
|
||||
EntityManager::Instance()->GetEntity(player.playerID);
|
||||
Game::entityManager->GetEntity(player.playerID);
|
||||
|
||||
if (vehicleEntity == nullptr || playerEntity == nullptr) {
|
||||
continue;
|
||||
@@ -733,7 +712,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
|
||||
Game::logger->Log("RacingControlComponent", "Starting race");
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
m_StartTime = std::time(nullptr);
|
||||
}
|
||||
@@ -747,13 +726,13 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
}
|
||||
|
||||
// Race routines
|
||||
auto* path = dZoneManager::Instance()->GetZone()->GetPath(
|
||||
auto* path = Game::zoneManager->GetZone()->GetPath(
|
||||
GeneralUtils::UTF16ToWTF8(m_PathName));
|
||||
|
||||
for (auto& player : m_RacingPlayers) {
|
||||
auto* vehicle = EntityManager::Instance()->GetEntity(player.vehicleID);
|
||||
auto* vehicle = Game::entityManager->GetEntity(player.vehicleID);
|
||||
auto* playerEntity =
|
||||
EntityManager::Instance()->GetEntity(player.playerID);
|
||||
Game::entityManager->GetEntity(player.playerID);
|
||||
|
||||
if (vehicle == nullptr || playerEntity == nullptr) {
|
||||
continue;
|
||||
@@ -859,6 +838,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
"Completed time %llu, %llu",
|
||||
raceTime, raceTime * 1000);
|
||||
|
||||
LeaderboardManager::SaveScore(playerEntity->GetObjectID(), m_ActivityID, static_cast<float>(player.raceTime), static_cast<float>(player.bestLapTime), static_cast<float>(player.finished == 1));
|
||||
// Entire race time
|
||||
missionComponent->Progress(eMissionTaskType::RACING, (raceTime) * 1000, (LWOOBJID)eRacingTaskParam::TOTAL_TRACK_TIME);
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ public:
|
||||
/**
|
||||
* Invoked when the player responds to the GUI.
|
||||
*/
|
||||
void HandleMessageBoxResponse(Entity* player, const std::string& id);
|
||||
void HandleMessageBoxResponse(Entity* player, int32_t button, const std::string& id);
|
||||
|
||||
/**
|
||||
* Get the racing data from a player's LWOOBJID.
|
||||
@@ -246,4 +246,9 @@ private:
|
||||
float m_EmptyTimer;
|
||||
|
||||
bool m_SoloRacing;
|
||||
|
||||
/**
|
||||
* Value for message box response to know if we are exiting the race via the activity dialogue
|
||||
*/
|
||||
const int32_t m_ActivityExitConfirm = 1;
|
||||
};
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "RebuildComponent.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "eStateChangeType.h"
|
||||
|
||||
RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t componentID) : Component(parent) {
|
||||
@@ -57,29 +59,16 @@ void RailActivatorComponent::OnUse(Entity* originator) {
|
||||
GameMessages::SendPlayFXEffect(originator->GetObjectID(), m_StartEffect.first, m_StartEffect.second,
|
||||
std::to_string(m_StartEffect.first));
|
||||
}
|
||||
|
||||
|
||||
float animationLength = 0.5f;
|
||||
if (!m_StartAnimation.empty()) {
|
||||
GameMessages::SendPlayAnimation(originator, m_StartAnimation);
|
||||
}
|
||||
|
||||
float animationLength;
|
||||
|
||||
if (m_StartAnimation == u"whirlwind-rail-up-earth") {
|
||||
animationLength = 1.5f;
|
||||
} else if (m_StartAnimation == u"whirlwind-rail-up-lightning") {
|
||||
animationLength = 0.5f;
|
||||
} else if (m_StartAnimation == u"whirlwind-rail-up-ice") {
|
||||
animationLength = 0.5f;
|
||||
} else if (m_StartAnimation == u"whirlwind-rail-up-fire") {
|
||||
animationLength = 0.5f;
|
||||
} else {
|
||||
animationLength = 0.5f;
|
||||
animationLength = RenderComponent::PlayAnimation(originator, m_StartAnimation);
|
||||
}
|
||||
|
||||
const auto originatorID = originator->GetObjectID();
|
||||
|
||||
m_Parent->AddCallbackTimer(animationLength, [originatorID, this]() {
|
||||
auto* originator = EntityManager::Instance()->GetEntity(originatorID);
|
||||
auto* originator = Game::entityManager->GetEntity(originatorID);
|
||||
|
||||
if (originator == nullptr) {
|
||||
return;
|
||||
@@ -112,7 +101,7 @@ void RailActivatorComponent::OnRailMovementReady(Entity* originator) const {
|
||||
}
|
||||
|
||||
if (!m_LoopAnimation.empty()) {
|
||||
GameMessages::SendPlayAnimation(originator, m_LoopAnimation);
|
||||
RenderComponent::PlayAnimation(originator, m_LoopAnimation);
|
||||
}
|
||||
|
||||
GameMessages::SendSetRailMovement(originator->GetObjectID(), m_PathDirection, m_Path, m_PathStart,
|
||||
@@ -147,7 +136,7 @@ void RailActivatorComponent::OnCancelRailMovement(Entity* originator) {
|
||||
}
|
||||
|
||||
if (!m_StopAnimation.empty()) {
|
||||
GameMessages::SendPlayAnimation(originator, m_StopAnimation);
|
||||
RenderComponent::PlayAnimation(originator, m_StopAnimation);
|
||||
}
|
||||
|
||||
// Remove the player after they've signalled they're done railing
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "Preconditions.h"
|
||||
#include "Loot.h"
|
||||
#include "TeamManager.h"
|
||||
#include "RenderComponent.h"
|
||||
|
||||
#include "CppScripts.h"
|
||||
|
||||
@@ -119,7 +120,7 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
else {
|
||||
m_SoftTimer = 5.0f;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}*/
|
||||
|
||||
switch (m_State) {
|
||||
@@ -138,7 +139,7 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
||||
m_ShowResetEffect = true;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash) {
|
||||
@@ -162,7 +163,7 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
if (!m_ShowResetEffect) {
|
||||
m_ShowResetEffect = true;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,18 +197,18 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
DestroyableComponent* destComp = builder->GetComponent<DestroyableComponent>();
|
||||
if (!destComp) break;
|
||||
|
||||
int newImagination = destComp->GetImagination() - 1;
|
||||
|
||||
destComp->SetImagination(newImagination);
|
||||
EntityManager::Instance()->SerializeEntity(builder);
|
||||
|
||||
++m_DrainedImagination;
|
||||
|
||||
if (newImagination == 0 && m_DrainedImagination < m_TakeImagination) {
|
||||
int newImagination = destComp->GetImagination();
|
||||
if (newImagination <= 0) {
|
||||
CancelRebuild(builder, eQuickBuildFailReason::OUT_OF_IMAGINATION, true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
++m_DrainedImagination;
|
||||
--newImagination;
|
||||
destComp->SetImagination(newImagination);
|
||||
Game::entityManager->SerializeEntity(builder);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (m_Timer >= m_CompleteTime && m_DrainedImagination >= m_TakeImagination) {
|
||||
@@ -224,7 +225,7 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
||||
m_ShowResetEffect = true;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash) {
|
||||
@@ -262,20 +263,20 @@ void RebuildComponent::SpawnActivator() {
|
||||
info.spawnerID = m_Parent->GetObjectID();
|
||||
info.pos = m_ActivatorPosition == NiPoint3::ZERO ? m_Parent->GetPosition() : m_ActivatorPosition;
|
||||
|
||||
m_Activator = EntityManager::Instance()->CreateEntity(info, nullptr, m_Parent);
|
||||
m_Activator = Game::entityManager->CreateEntity(info, nullptr, m_Parent);
|
||||
if (m_Activator) {
|
||||
m_ActivatorId = m_Activator->GetObjectID();
|
||||
EntityManager::Instance()->ConstructEntity(m_Activator);
|
||||
Game::entityManager->ConstructEntity(m_Activator);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RebuildComponent::DespawnActivator() {
|
||||
if (m_Activator) {
|
||||
EntityManager::Instance()->DestructEntity(m_Activator);
|
||||
Game::entityManager->DestructEntity(m_Activator);
|
||||
|
||||
m_Activator->ScheduleKillAfterUpdate();
|
||||
|
||||
@@ -286,7 +287,7 @@ void RebuildComponent::DespawnActivator() {
|
||||
}
|
||||
|
||||
Entity* RebuildComponent::GetActivator() {
|
||||
return EntityManager::Instance()->GetEntity(m_ActivatorId);
|
||||
return Game::entityManager->GetEntity(m_ActivatorId);
|
||||
}
|
||||
|
||||
NiPoint3 RebuildComponent::GetActivatorPosition() {
|
||||
@@ -334,7 +335,7 @@ eRebuildState RebuildComponent::GetState() {
|
||||
}
|
||||
|
||||
Entity* RebuildComponent::GetBuilder() const {
|
||||
auto* builder = EntityManager::Instance()->GetEntity(m_Builder);
|
||||
auto* builder = Game::entityManager->GetEntity(m_Builder);
|
||||
|
||||
return builder;
|
||||
}
|
||||
@@ -402,14 +403,14 @@ void RebuildComponent::StartRebuild(Entity* user) {
|
||||
auto* character = user->GetComponent<CharacterComponent>();
|
||||
character->SetCurrentActivity(eGameActivity::QUICKBUILDING);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(user);
|
||||
Game::entityManager->SerializeEntity(user);
|
||||
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::BUILDING, user->GetObjectID());
|
||||
GameMessages::SendEnableRebuild(m_Parent, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID());
|
||||
|
||||
m_State = eRebuildState::BUILDING;
|
||||
m_StateDirty = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
auto* movingPlatform = m_Parent->GetComponent<MovingPlatformComponent>();
|
||||
if (movingPlatform != nullptr) {
|
||||
@@ -442,7 +443,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(user);
|
||||
Game::entityManager->SerializeEntity(user);
|
||||
|
||||
GameMessages::SendRebuildNotifyState(m_Parent, m_State, eRebuildState::COMPLETED, user->GetObjectID());
|
||||
GameMessages::SendPlayFXEffect(m_Parent, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true);
|
||||
@@ -455,7 +456,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
m_Timer = 0.0f;
|
||||
m_DrainedImagination = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
// Removes extra item requirements, isn't live accurate.
|
||||
// In live, all items were removed at the start of the quickbuild, then returned if it was cancelled.
|
||||
@@ -475,7 +476,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
auto* team = TeamManager::Instance()->GetTeam(builder->GetObjectID());
|
||||
if (team) {
|
||||
for (const auto memberId : team->members) { // progress missions for all team members
|
||||
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
||||
auto* member = Game::entityManager->GetEntity(memberId);
|
||||
if (member) {
|
||||
auto* missionComponent = member->GetComponent<MissionComponent>();
|
||||
if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId);
|
||||
@@ -517,7 +518,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
character->SetPlayerFlag(flagNumber, true);
|
||||
}
|
||||
}
|
||||
GameMessages::SendPlayAnimation(user, u"rebuild-celebrate", 1.09f);
|
||||
RenderComponent::PlayAnimation(user, u"rebuild-celebrate", 1.09f);
|
||||
}
|
||||
|
||||
void RebuildComponent::ResetRebuild(bool failed) {
|
||||
@@ -527,7 +528,7 @@ void RebuildComponent::ResetRebuild(bool failed) {
|
||||
GameMessages::SendEnableRebuild(m_Parent, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID());
|
||||
|
||||
if (failed) {
|
||||
GameMessages::SendPlayAnimation(builder, u"rebuild-fail");
|
||||
RenderComponent::PlayAnimation(builder, u"rebuild-fail");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,7 +541,7 @@ void RebuildComponent::ResetRebuild(bool failed) {
|
||||
m_ShowResetEffect = false;
|
||||
m_DrainedImagination = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
// Notify scripts and possible subscribers
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_Parent))
|
||||
@@ -580,7 +581,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failR
|
||||
for (const auto& cb : m_RebuildStateCallbacks)
|
||||
cb(m_State);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
if (entity == nullptr) {
|
||||
@@ -590,7 +591,7 @@ void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failR
|
||||
CharacterComponent* characterComponent = entity->GetComponent<CharacterComponent>();
|
||||
if (characterComponent) {
|
||||
characterComponent->SetCurrentActivity(eGameActivity::NONE);
|
||||
EntityManager::Instance()->SerializeEntity(entity);
|
||||
Game::entityManager->SerializeEntity(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,72 +11,36 @@
|
||||
#include "GameMessages.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
#include "CDAnimationsTable.h"
|
||||
|
||||
std::unordered_map<int32_t, float> RenderComponent::m_DurationCache{};
|
||||
|
||||
RenderComponent::RenderComponent(Entity* parent) : Component(parent) {
|
||||
RenderComponent::RenderComponent(Entity* parent, int32_t componentId): Component(parent) {
|
||||
m_Effects = std::vector<Effect*>();
|
||||
m_LastAnimationName = "";
|
||||
if (componentId == -1) return;
|
||||
|
||||
return;
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT * FROM RenderComponent WHERE id = ?;");
|
||||
query.bind(1, componentId);
|
||||
auto result = query.execQuery();
|
||||
|
||||
/*
|
||||
auto* table = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||
|
||||
const auto entry = table->GetByIDAndType(parent->GetLOT(), eReplicaComponentType::RENDER);
|
||||
|
||||
std::stringstream query;
|
||||
|
||||
query << "SELECT effect1, effect2, effect3, effect4, effect5, effect6 FROM RenderComponent WHERE id = " << std::to_string(entry) << ";";
|
||||
|
||||
auto result = CDClientDatabase::ExecuteQuery(query.str());
|
||||
|
||||
if (result.eof())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto i = 0; i < 6; ++i)
|
||||
{
|
||||
if (result.fieldIsNull(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto id = result.getIntField(i);
|
||||
|
||||
if (id <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
query.clear();
|
||||
|
||||
query << "SELECT effectType, effectName FROM BehaviorEffect WHERE effectID = " << std::to_string(id) << ";";
|
||||
|
||||
auto effectResult = CDClientDatabase::ExecuteQuery(query.str());
|
||||
|
||||
while (!effectResult.eof())
|
||||
{
|
||||
const auto type = effectResult.fieldIsNull(0) ? "" : std::string(effectResult.getStringField(0));
|
||||
|
||||
const auto name = effectResult.fieldIsNull(1) ? "" : std::string(effectResult.getStringField(1));
|
||||
|
||||
auto* effect = new Effect();
|
||||
|
||||
effect->name = name;
|
||||
effect->type = GeneralUtils::ASCIIToUTF16(type);
|
||||
effect->scale = 1;
|
||||
effect->effectID = id;
|
||||
effect->secondary = LWOOBJID_EMPTY;
|
||||
|
||||
m_Effects.push_back(effect);
|
||||
|
||||
effectResult.nextRow();
|
||||
if (!result.eof()) {
|
||||
auto animationGroupIDs = std::string(result.getStringField("animationGroupIDs", ""));
|
||||
if (!animationGroupIDs.empty()) {
|
||||
auto* animationsTable = CDClientManager::Instance().GetTable<CDAnimationsTable>();
|
||||
auto groupIdsSplit = GeneralUtils::SplitString(animationGroupIDs, ',');
|
||||
for (auto& groupId : groupIdsSplit) {
|
||||
int32_t groupIdInt;
|
||||
if (!GeneralUtils::TryParse(groupId, groupIdInt)) {
|
||||
Game::logger->Log("RenderComponent", "bad animation group Id %s", groupId.c_str());
|
||||
continue;
|
||||
}
|
||||
m_animationGroupIds.push_back(groupIdInt);
|
||||
animationsTable->CacheAnimationGroup(groupIdInt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.finalize();
|
||||
*/
|
||||
}
|
||||
|
||||
RenderComponent::~RenderComponent() {
|
||||
@@ -224,3 +188,45 @@ void RenderComponent::StopEffect(const std::string& name, const bool killImmedia
|
||||
std::vector<Effect*>& RenderComponent::GetEffects() {
|
||||
return m_Effects;
|
||||
}
|
||||
|
||||
|
||||
float RenderComponent::PlayAnimation(Entity* self, const std::u16string& animation, float priority, float scale) {
|
||||
if (!self) return 0.0f;
|
||||
return RenderComponent::PlayAnimation(self, GeneralUtils::UTF16ToWTF8(animation), priority, scale);
|
||||
}
|
||||
|
||||
float RenderComponent::PlayAnimation(Entity* self, const std::string& animation, float priority, float scale) {
|
||||
if (!self) return 0.0f;
|
||||
return RenderComponent::DoAnimation(self, animation, true, priority, scale);
|
||||
}
|
||||
|
||||
float RenderComponent::GetAnimationTime(Entity* self, const std::u16string& animation) {
|
||||
if (!self) return 0.0f;
|
||||
return RenderComponent::GetAnimationTime(self, GeneralUtils::UTF16ToWTF8(animation));
|
||||
}
|
||||
|
||||
float RenderComponent::GetAnimationTime(Entity* self, const std::string& animation) {
|
||||
if (!self) return 0.0f;
|
||||
return RenderComponent::DoAnimation(self, animation, false);
|
||||
}
|
||||
|
||||
|
||||
float RenderComponent::DoAnimation(Entity* self, const std::string& animation, bool sendAnimation, float priority, float scale) {
|
||||
float returnlength = 0.0f;
|
||||
if (!self) return returnlength;
|
||||
auto* renderComponent = self->GetComponent<RenderComponent>();
|
||||
if (!renderComponent) return returnlength;
|
||||
|
||||
auto* animationsTable = CDClientManager::Instance().GetTable<CDAnimationsTable>();
|
||||
for (auto& groupId : renderComponent->m_animationGroupIds) {
|
||||
auto animationGroup = animationsTable->GetAnimation(animation, renderComponent->GetLastAnimationName(), groupId);
|
||||
if (animationGroup.FoundData()) {
|
||||
auto data = animationGroup.Data();
|
||||
renderComponent->SetLastAnimationName(data.animation_name);
|
||||
returnlength = data.animation_length;
|
||||
}
|
||||
}
|
||||
if (sendAnimation) GameMessages::SendPlayAnimation(self, GeneralUtils::ASCIIToUTF16(animation), priority, scale);
|
||||
if (returnlength == 0.0f) Game::logger->Log("RenderComponent", "WARNING: Unable to find animation %s for lot %i in any group.", animation.c_str(), self->GetLOT());
|
||||
return returnlength;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "AMFFormat.h"
|
||||
#include "Amf3.h"
|
||||
#include "Component.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
@@ -58,7 +58,7 @@ class RenderComponent : public Component {
|
||||
public:
|
||||
static const eReplicaComponentType ComponentType = eReplicaComponentType::RENDER;
|
||||
|
||||
RenderComponent(Entity* entity);
|
||||
RenderComponent(Entity* entity, int32_t componentId = -1);
|
||||
~RenderComponent() override;
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||
@@ -104,6 +104,32 @@ public:
|
||||
*/
|
||||
std::vector<Effect*>& GetEffects();
|
||||
|
||||
/**
|
||||
* Verifies that an animation can be played on this entity by checking
|
||||
* if it has the animation assigned to its group. If it does, the animation is echo'd
|
||||
* down to all clients to be played and the duration of the played animation is returned.
|
||||
* If the animation did not exist or the function was called in an invalid state, 0 is returned.
|
||||
*
|
||||
* The logic here matches the exact client logic.
|
||||
*
|
||||
* @param self The entity that wants to play an animation
|
||||
* @param animation The animation_type (animationID in the client) to be played.
|
||||
* @param sendAnimation Whether or not to echo the animation down to all clients.
|
||||
* @param priority The priority of the animation. Only used if sendAnimation is true.
|
||||
* @param scale The scale of the animation. Only used if sendAnimation is true.
|
||||
*
|
||||
* @return The duration of the animation that was played.
|
||||
*/
|
||||
static float DoAnimation(Entity* self, const std::string& animation, bool sendAnimation, float priority = 0.0f, float scale = 1.0f);
|
||||
|
||||
static float PlayAnimation(Entity* self, const std::u16string& animation, float priority = 0.0f, float scale = 1.0f);
|
||||
static float PlayAnimation(Entity* self, const std::string& animation, float priority = 0.0f, float scale = 1.0f);
|
||||
static float GetAnimationTime(Entity* self, const std::string& animation);
|
||||
static float GetAnimationTime(Entity* self, const std::u16string& animation);
|
||||
|
||||
const std::string& GetLastAnimationName() const { return m_LastAnimationName; };
|
||||
void SetLastAnimationName(const std::string& name) { m_LastAnimationName = name; };
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -111,6 +137,11 @@ private:
|
||||
*/
|
||||
std::vector<Effect*> m_Effects;
|
||||
|
||||
std::vector<int32_t> m_animationGroupIds;
|
||||
|
||||
// The last animationName that was played
|
||||
std::string m_LastAnimationName;
|
||||
|
||||
/**
|
||||
* Cache of queries that look for the length of each effect, indexed by effect ID
|
||||
*/
|
||||
|
||||
@@ -81,7 +81,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId,
|
||||
|
||||
GameMessages::SendChangeObjectWorldState(rocket->GetId(), eObjectWorldState::ATTACHED, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(originator);
|
||||
Game::entityManager->SerializeEntity(originator);
|
||||
}
|
||||
|
||||
void RocketLaunchpadControlComponent::OnUse(Entity* originator) {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "CDCurrencyTableTable.h"
|
||||
#include "CDActivityRewardsTable.h"
|
||||
#include "CDActivitiesTable.h"
|
||||
#include "LeaderboardManager.h"
|
||||
|
||||
ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activityID) : Component(parent) {
|
||||
m_ActivityID = activityID;
|
||||
@@ -35,10 +36,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit
|
||||
|
||||
for (CDActivities activity : activities) {
|
||||
m_ActivityInfo = activity;
|
||||
|
||||
const auto mapID = m_ActivityInfo.instanceMapID;
|
||||
|
||||
if ((mapID == 1203 || mapID == 1261 || mapID == 1303 || mapID == 1403) && Game::config->GetValue("solo_racing") == "1") {
|
||||
if (static_cast<Leaderboard::Type>(activity.leaderboardType) == Leaderboard::Type::Racing && Game::config->GetValue("solo_racing") == "1") {
|
||||
m_ActivityInfo.minTeamSize = 1;
|
||||
m_ActivityInfo.minTeams = 1;
|
||||
}
|
||||
@@ -139,7 +137,7 @@ void ScriptedActivityComponent::PlayerJoin(Entity* player) {
|
||||
instance->AddParticipant(player);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) {
|
||||
@@ -151,7 +149,7 @@ void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) {
|
||||
|
||||
auto* character = player->GetCharacter();
|
||||
if (character != nullptr)
|
||||
character->SetLastNonInstanceZoneID(dZoneManager::Instance()->GetZone()->GetWorldID());
|
||||
character->SetLastNonInstanceZoneID(Game::zoneManager->GetZone()->GetWorldID());
|
||||
|
||||
for (Lobby* lobby : m_Queue) {
|
||||
if (lobby->players.size() < m_ActivityInfo.maxTeamSize || m_ActivityInfo.maxTeamSize == 1 && lobby->players.size() < m_ActivityInfo.maxTeams) {
|
||||
@@ -312,7 +310,7 @@ bool ScriptedActivityComponent::IsValidActivity(Entity* player) {
|
||||
}
|
||||
|
||||
ChatPackets::SendSystemMessage(player->GetSystemAddress(), u"Sorry, this activity is not ready.");
|
||||
static_cast<Player*>(player)->SendToZone(dZoneManager::Instance()->GetZone()->GetWorldID()); // Gets them out of this stuck state
|
||||
static_cast<Player*>(player)->SendToZone(Game::zoneManager->GetZone()->GetWorldID()); // Gets them out of this stuck state
|
||||
|
||||
return false;
|
||||
}*/
|
||||
@@ -447,7 +445,7 @@ void ScriptedActivityComponent::RemoveActivityPlayerData(LWOOBJID playerID) {
|
||||
m_ActivityPlayers[i] = nullptr;
|
||||
|
||||
m_ActivityPlayers.erase(m_ActivityPlayers.begin() + i);
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -460,7 +458,7 @@ ActivityPlayer* ScriptedActivityComponent::AddActivityPlayerData(LWOOBJID player
|
||||
return data;
|
||||
|
||||
m_ActivityPlayers.push_back(new ActivityPlayer{ playerID, {} });
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
|
||||
return GetActivityPlayerData(playerID);
|
||||
}
|
||||
@@ -482,7 +480,7 @@ void ScriptedActivityComponent::SetActivityValue(LWOOBJID playerID, uint32_t ind
|
||||
data->values[std::min(index, (uint32_t)9)] = value;
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ScriptedActivityComponent::PlayerRemove(LWOOBJID playerID) {
|
||||
@@ -537,7 +535,7 @@ void ActivityInstance::StartZone() {
|
||||
const auto objid = player->GetObjectID();
|
||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, m_ActivityInfo.instanceMapID, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(objid);
|
||||
auto* player = Game::entityManager->GetEntity(objid);
|
||||
if (player == nullptr)
|
||||
return;
|
||||
|
||||
@@ -587,7 +585,7 @@ std::vector<Entity*> ActivityInstance::GetParticipants() const {
|
||||
entities.reserve(m_Participants.size());
|
||||
|
||||
for (const auto& id : m_Participants) {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(id);
|
||||
auto* entity = Game::entityManager->GetEntity(id);
|
||||
if (entity != nullptr)
|
||||
entities.push_back(entity);
|
||||
}
|
||||
@@ -619,5 +617,5 @@ void ActivityInstance::SetScore(uint32_t score) {
|
||||
}
|
||||
|
||||
Entity* LobbyPlayer::GetEntity() const {
|
||||
return EntityManager::Instance()->GetEntity(entityID);
|
||||
return Game::entityManager->GetEntity(entityID);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ void ShootingGalleryComponent::SetStaticParams(const StaticShootingGalleryParams
|
||||
void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryParams& params) {
|
||||
m_DynamicParams = params;
|
||||
m_Dirty = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const {
|
||||
|
||||
@@ -292,7 +292,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
|
||||
start.optionalOriginatorID = context->originator;
|
||||
start.optionalTargetID = target;
|
||||
|
||||
auto* originator = EntityManager::Instance()->GetEntity(context->originator);
|
||||
auto* originator = Game::entityManager->GetEntity(context->originator);
|
||||
|
||||
if (originator != nullptr) {
|
||||
start.originatorRot = originator->GetRotation();
|
||||
@@ -338,7 +338,7 @@ void SkillComponent::CalculateUpdate(const float deltaTime) {
|
||||
|
||||
entry.time += deltaTime;
|
||||
|
||||
auto* origin = EntityManager::Instance()->GetEntity(entry.context->originator);
|
||||
auto* origin = Game::entityManager->GetEntity(entry.context->originator);
|
||||
|
||||
if (origin == nullptr) {
|
||||
continue;
|
||||
@@ -349,7 +349,7 @@ void SkillComponent::CalculateUpdate(const float deltaTime) {
|
||||
const auto position = entry.startPosition + (entry.velocity * entry.time);
|
||||
|
||||
for (const auto& targetId : targets) {
|
||||
auto* target = EntityManager::Instance()->GetEntity(targetId);
|
||||
auto* target = Game::entityManager->GetEntity(targetId);
|
||||
|
||||
const auto targetPosition = target->GetPosition();
|
||||
|
||||
@@ -397,7 +397,7 @@ void SkillComponent::CalculateUpdate(const float deltaTime) {
|
||||
|
||||
|
||||
void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry) const {
|
||||
auto* other = EntityManager::Instance()->GetEntity(entry.branchContext.target);
|
||||
auto* other = Game::entityManager->GetEntity(entry.branchContext.target);
|
||||
|
||||
if (other == nullptr) {
|
||||
if (entry.branchContext.target != LWOOBJID_EMPTY) {
|
||||
|
||||
@@ -76,7 +76,7 @@ void SoundTriggerComponent::ActivateMusicCue(const std::string& name) {
|
||||
-1.0f
|
||||
});
|
||||
dirty = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,6 @@ void SoundTriggerComponent::DeactivateMusicCue(const std::string& name) {
|
||||
if (musicCue != this->musicCues.end()) {
|
||||
this->musicCues.erase(musicCue);
|
||||
dirty = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "SwitchComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "eTriggerEventType.h"
|
||||
#include "RenderComponent.h"
|
||||
|
||||
std::vector<SwitchComponent*> SwitchComponent::petSwitches;
|
||||
|
||||
@@ -48,7 +49,7 @@ void SwitchComponent::EntityEnter(Entity* entity) {
|
||||
const auto grpName = m_Parent->GetVarAsString(u"grp_name");
|
||||
|
||||
if (!grpName.empty()) {
|
||||
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
|
||||
const auto entities = Game::entityManager->GetEntitiesInGroup(grpName);
|
||||
|
||||
for (auto* entity : entities) {
|
||||
entity->OnFireEventServerSide(entity, "OnActivated");
|
||||
@@ -59,10 +60,10 @@ void SwitchComponent::EntityEnter(Entity* entity) {
|
||||
|
||||
if (m_PetBouncer != nullptr) {
|
||||
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true);
|
||||
GameMessages::SendPlayAnimation(m_Parent, u"engaged", 0, 1);
|
||||
RenderComponent::PlayAnimation(m_Parent, u"engaged");
|
||||
m_PetBouncer->SetPetBouncerEnabled(true);
|
||||
} else {
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -84,7 +85,7 @@ void SwitchComponent::Update(float deltaTime) {
|
||||
const auto grpName = m_Parent->GetVarAsString(u"grp_name");
|
||||
|
||||
if (!grpName.empty()) {
|
||||
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
|
||||
const auto entities = Game::entityManager->GetEntitiesInGroup(grpName);
|
||||
|
||||
for (auto* entity : entities) {
|
||||
entity->OnFireEventServerSide(entity, "OnDectivated");
|
||||
@@ -94,7 +95,7 @@ void SwitchComponent::Update(float deltaTime) {
|
||||
if (m_PetBouncer != nullptr) {
|
||||
m_PetBouncer->SetPetBouncerEnabled(false);
|
||||
} else {
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo
|
||||
uint32_t triggerID;
|
||||
GeneralUtils::TryParse<uint32_t>(tokens.at(1), triggerID);
|
||||
|
||||
m_Trigger = dZoneManager::Instance()->GetZone()->GetTrigger(sceneID, triggerID);
|
||||
m_Trigger = Game::zoneManager->GetZone()->GetTrigger(sceneID, triggerID);
|
||||
|
||||
if (!m_Trigger) m_Trigger = new LUTriggers::Trigger();
|
||||
}
|
||||
@@ -170,10 +170,10 @@ std::vector<Entity*> TriggerComponent::GatherTargets(LUTriggers::Command* comman
|
||||
else if (command->target == "targetTeam" && optionalTarget) {
|
||||
auto* team = TeamManager::Instance()->GetTeam(optionalTarget->GetObjectID());
|
||||
for (const auto memberId : team->members) {
|
||||
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
||||
auto* member = Game::entityManager->GetEntity(memberId);
|
||||
if (member) entities.push_back(member);
|
||||
}
|
||||
} else if (command->target == "objGroup") entities = EntityManager::Instance()->GetEntitiesInGroup(command->targetName);
|
||||
} else if (command->target == "objGroup") entities = Game::entityManager->GetEntitiesInGroup(command->targetName);
|
||||
else if (command->target == "allPlayers") {
|
||||
for (auto* player : Player::GetAllPlayers()) {
|
||||
entities.push_back(player);
|
||||
@@ -235,6 +235,8 @@ void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std:
|
||||
}
|
||||
|
||||
void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::string> argArray){
|
||||
if (argArray.size() < 3) return;
|
||||
|
||||
auto* phantomPhysicsComponent = m_Parent->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!phantomPhysicsComponent) {
|
||||
Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!");
|
||||
@@ -247,7 +249,7 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::s
|
||||
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), direction);
|
||||
phantomPhysicsComponent->SetDirection(direction);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -272,7 +274,7 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args)
|
||||
NiPoint3 direction = delta / length;
|
||||
phantomPhysicsComponent->SetDirection(direction);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::string> argArray){
|
||||
@@ -393,7 +395,7 @@ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::v
|
||||
phantomPhysicsComponent->SetMax(max);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(targetEntity);
|
||||
Game::entityManager->SerializeEntity(targetEntity);
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleSetPhysicsVolumeStatus(Entity* targetEntity, std::string args) {
|
||||
@@ -403,29 +405,29 @@ void TriggerComponent::HandleSetPhysicsVolumeStatus(Entity* targetEntity, std::s
|
||||
return;
|
||||
}
|
||||
phantomPhysicsComponent->SetPhysicsEffectActive(args == "On");
|
||||
EntityManager::Instance()->SerializeEntity(targetEntity);
|
||||
Game::entityManager->SerializeEntity(targetEntity);
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleActivateSpawnerNetwork(std::string args){
|
||||
for (auto* spawner : dZoneManager::Instance()->GetSpawnersByName(args)) {
|
||||
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
||||
if (spawner) spawner->Activate();
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleDeactivateSpawnerNetwork(std::string args){
|
||||
for (auto* spawner : dZoneManager::Instance()->GetSpawnersByName(args)) {
|
||||
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
||||
if (spawner) spawner->Deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleResetSpawnerNetwork(std::string args){
|
||||
for (auto* spawner : dZoneManager::Instance()->GetSpawnersByName(args)) {
|
||||
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
||||
if (spawner) spawner->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleDestroySpawnerNetworkObjects(std::string args){
|
||||
for (auto* spawner : dZoneManager::Instance()->GetSpawnersByName(args)) {
|
||||
for (auto* spawner : Game::zoneManager->GetSpawnersByName(args)) {
|
||||
if (spawner) spawner->DestroyAllEntities();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,34 +19,47 @@ VehiclePhysicsComponent::~VehiclePhysicsComponent() {
|
||||
}
|
||||
|
||||
void VehiclePhysicsComponent::SetPosition(const NiPoint3& pos) {
|
||||
if (pos == m_Position) return;
|
||||
m_DirtyPosition = true;
|
||||
m_Position = pos;
|
||||
}
|
||||
|
||||
void VehiclePhysicsComponent::SetRotation(const NiQuaternion& rot) {
|
||||
if (rot == m_Rotation) return;
|
||||
m_DirtyPosition = true;
|
||||
m_Rotation = rot;
|
||||
}
|
||||
|
||||
void VehiclePhysicsComponent::SetVelocity(const NiPoint3& vel) {
|
||||
if (vel == m_Velocity) return;
|
||||
m_DirtyPosition = true;
|
||||
m_Velocity = vel;
|
||||
}
|
||||
|
||||
void VehiclePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) {
|
||||
if (vel == m_AngularVelocity) return;
|
||||
m_DirtyPosition = true;
|
||||
m_AngularVelocity = vel;
|
||||
}
|
||||
|
||||
void VehiclePhysicsComponent::SetIsOnGround(bool val) {
|
||||
if (val == m_IsOnGround) return;
|
||||
m_DirtyPosition = true;
|
||||
m_IsOnGround = val;
|
||||
}
|
||||
|
||||
void VehiclePhysicsComponent::SetIsOnRail(bool val) {
|
||||
if (val == m_IsOnRail) return;
|
||||
m_DirtyPosition = true;
|
||||
m_IsOnRail = val;
|
||||
}
|
||||
|
||||
void VehiclePhysicsComponent::SetRemoteInputInfo(const RemoteInputInfo& remoteInputInfo) {
|
||||
if (m_RemoteInputInfo == remoteInputInfo) return;
|
||||
this->m_RemoteInputInfo = remoteInputInfo;
|
||||
m_DirtyRemoteInput = true;
|
||||
}
|
||||
|
||||
void VehiclePhysicsComponent::SetDirtyPosition(bool val) {
|
||||
m_DirtyPosition = val;
|
||||
}
|
||||
@@ -63,9 +76,15 @@ void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
|
||||
outBitStream->Write(bIsInitialUpdate || m_DirtyPosition);
|
||||
|
||||
if (bIsInitialUpdate || m_DirtyPosition) {
|
||||
outBitStream->Write(m_Position);
|
||||
m_DirtyPosition = false;
|
||||
outBitStream->Write(m_Position.x);
|
||||
outBitStream->Write(m_Position.y);
|
||||
outBitStream->Write(m_Position.z);
|
||||
|
||||
outBitStream->Write(m_Rotation);
|
||||
outBitStream->Write(m_Rotation.x);
|
||||
outBitStream->Write(m_Rotation.y);
|
||||
outBitStream->Write(m_Rotation.z);
|
||||
outBitStream->Write(m_Rotation.w);
|
||||
|
||||
outBitStream->Write(m_IsOnGround);
|
||||
outBitStream->Write(m_IsOnRail);
|
||||
@@ -73,20 +92,33 @@ void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
|
||||
outBitStream->Write(bIsInitialUpdate || m_DirtyVelocity);
|
||||
|
||||
if (bIsInitialUpdate || m_DirtyVelocity) {
|
||||
outBitStream->Write(m_Velocity);
|
||||
outBitStream->Write(m_Velocity.x);
|
||||
outBitStream->Write(m_Velocity.y);
|
||||
outBitStream->Write(m_Velocity.z);
|
||||
m_DirtyVelocity = false;
|
||||
}
|
||||
|
||||
outBitStream->Write(bIsInitialUpdate || m_DirtyAngularVelocity);
|
||||
|
||||
if (bIsInitialUpdate || m_DirtyAngularVelocity) {
|
||||
outBitStream->Write(m_AngularVelocity);
|
||||
outBitStream->Write(m_AngularVelocity.x);
|
||||
outBitStream->Write(m_AngularVelocity.y);
|
||||
outBitStream->Write(m_AngularVelocity.z);
|
||||
m_DirtyAngularVelocity = false;
|
||||
}
|
||||
|
||||
outBitStream->Write0();
|
||||
outBitStream->Write0(); // local_space_info. TODO: Implement this
|
||||
|
||||
outBitStream->Write0();
|
||||
outBitStream->Write(m_DirtyRemoteInput || bIsInitialUpdate); // remote_input_info
|
||||
if (m_DirtyRemoteInput || bIsInitialUpdate) {
|
||||
outBitStream->Write(m_RemoteInputInfo.m_RemoteInputX);
|
||||
outBitStream->Write(m_RemoteInputInfo.m_RemoteInputY);
|
||||
outBitStream->Write(m_RemoteInputInfo.m_IsPowersliding);
|
||||
outBitStream->Write(m_RemoteInputInfo.m_IsModified);
|
||||
m_DirtyRemoteInput = false;
|
||||
}
|
||||
|
||||
outBitStream->Write(0.0f);
|
||||
outBitStream->Write(125.0f); // remote_input_ping TODO: Figure out how this should be calculated as it seems to be constant through the whole race.
|
||||
|
||||
if (!bIsInitialUpdate) {
|
||||
outBitStream->Write0();
|
||||
@@ -95,7 +127,7 @@ void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
|
||||
|
||||
if (bIsInitialUpdate) {
|
||||
outBitStream->Write<uint8_t>(m_EndBehavior);
|
||||
outBitStream->Write1();
|
||||
outBitStream->Write1(); // is input locked?
|
||||
}
|
||||
|
||||
outBitStream->Write0();
|
||||
@@ -103,8 +135,7 @@ void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
|
||||
|
||||
void VehiclePhysicsComponent::Update(float deltaTime) {
|
||||
if (m_SoftUpdate > 5) {
|
||||
EntityManager::Instance()->SerializeEntity(m_Parent);
|
||||
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
m_SoftUpdate = 0;
|
||||
} else {
|
||||
m_SoftUpdate += deltaTime;
|
||||
|
||||
@@ -5,6 +5,24 @@
|
||||
#include "Component.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
struct RemoteInputInfo {
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
* Physics component for vehicles.
|
||||
*/
|
||||
@@ -94,6 +112,7 @@ public:
|
||||
void SetDirtyPosition(bool val);
|
||||
void SetDirtyVelocity(bool val);
|
||||
void SetDirtyAngularVelocity(bool val);
|
||||
void SetRemoteInputInfo(const RemoteInputInfo&);
|
||||
|
||||
private:
|
||||
bool m_DirtyPosition;
|
||||
@@ -110,4 +129,6 @@ private:
|
||||
|
||||
float m_SoftUpdate = 0;
|
||||
uint32_t m_EndBehavior;
|
||||
RemoteInputInfo m_RemoteInputInfo;
|
||||
bool m_DirtyRemoteInput;
|
||||
};
|
||||
|
||||
@@ -134,3 +134,7 @@ void VendorComponent::SetupConstants() {
|
||||
m_RefreshTimeSeconds = vendorComps[0].refreshTimeSeconds;
|
||||
m_LootMatrixID = vendorComps[0].LootMatrixIndex;
|
||||
}
|
||||
|
||||
bool VendorComponent::SellsItem(const LOT item) const {
|
||||
return m_Inventory.find(item) != m_Inventory.end();
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
* Called on startup of vendor to setup the variables for the component.
|
||||
*/
|
||||
void SetupConstants();
|
||||
|
||||
bool SellsItem(const LOT item) const;
|
||||
private:
|
||||
/**
|
||||
* The buy scalar.
|
||||
|
||||
Reference in New Issue
Block a user