mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
Rename some variables
- Add order for loading Components - Enforce all components have Entity* in the first argument
This commit is contained in:
parent
f555ba8c25
commit
6f057204be
@ -96,14 +96,14 @@ Entity::Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity)
|
||||
m_CollectibleID = 0;
|
||||
m_NetworkID = 0;
|
||||
m_Observers = 0;
|
||||
m_Groups = {};
|
||||
m_OwnerOverride = LWOOBJID_EMPTY;
|
||||
m_Timers = {};
|
||||
m_ChildEntities = {};
|
||||
m_Groups.clear();
|
||||
m_Timers.clear();
|
||||
m_ChildEntities.clear();
|
||||
m_TargetsInPhantom.clear();
|
||||
m_DieCallbacks.clear();
|
||||
m_PhantomCollisionCallbacks.clear();
|
||||
m_ScheduleKiller = nullptr;
|
||||
m_TargetsInPhantom = {};
|
||||
m_DieCallbacks = {};
|
||||
m_PhantomCollisionCallbacks = {};
|
||||
m_IsParentChildDirty = true;
|
||||
m_IsGhostingCandidate = false;
|
||||
m_PlayerIsReadyForUpdates = false;
|
||||
@ -378,6 +378,23 @@ void Entity::Initialize() {
|
||||
Game::logger->Log("Entity", "blah %i %i", componentId, m_TemplateID);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto&[componentId, component] : m_Components) {
|
||||
component->LoadTemplateData();
|
||||
}
|
||||
|
||||
for (const auto&[componentId, component] : m_Components) {
|
||||
component->LoadConfigData();
|
||||
}
|
||||
|
||||
for (const auto&[componentId, component] : m_Components) {
|
||||
component->Startup();
|
||||
}
|
||||
if (!IsPlayer()) return; // No save data to load for non players
|
||||
|
||||
for (const auto&[componentId, component] : m_Components) {
|
||||
component->LoadFromXml(m_Character->GetXMLDoc());
|
||||
}
|
||||
}
|
||||
|
||||
bool Entity::operator==(const Entity& other) const {
|
||||
|
@ -103,43 +103,43 @@ Entity::Initialize() {
|
||||
new PropertyEntranceComponent(propertyEntranceComponentID, this)));
|
||||
}
|
||||
|
||||
if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CONTROLLABLE_PHYSICS) > 0) {
|
||||
ControllablePhysicsComponent* controllablePhysics = new ControllablePhysicsComponent(this);
|
||||
// if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CONTROLLABLE_PHYSICS) > 0) {
|
||||
// ControllablePhysicsComponent* controllablePhysics = new ControllablePhysicsComponent(this);
|
||||
|
||||
if (m_Character) {
|
||||
controllablePhysics->LoadFromXml(m_Character->GetXMLDoc());
|
||||
// if (m_Character) {
|
||||
// controllablePhysics->LoadFromXml(m_Character->GetXMLDoc());
|
||||
|
||||
const auto mapID = Game::server->GetZoneID();
|
||||
// const auto mapID = Game::server->GetZoneID();
|
||||
|
||||
//If we came from another zone, put us in the starting loc
|
||||
if (m_Character->GetZoneID() != Game::server->GetZoneID() || mapID == 1603) { // Exception for Moon Base as you tend to spawn on the roof.
|
||||
NiPoint3 pos;
|
||||
NiQuaternion rot;
|
||||
// //If we came from another zone, put us in the starting loc
|
||||
// if (m_Character->GetZoneID() != Game::server->GetZoneID() || mapID == 1603) { // Exception for Moon Base as you tend to spawn on the roof.
|
||||
// NiPoint3 pos;
|
||||
// NiQuaternion rot;
|
||||
|
||||
const auto& targetSceneName = m_Character->GetTargetScene();
|
||||
auto* targetScene = EntityManager::Instance()->GetSpawnPointEntity(targetSceneName);
|
||||
// const auto& targetSceneName = m_Character->GetTargetScene();
|
||||
// auto* targetScene = EntityManager::Instance()->GetSpawnPointEntity(targetSceneName);
|
||||
|
||||
if (m_Character->HasBeenToWorld(mapID) && targetSceneName.empty()) {
|
||||
pos = m_Character->GetRespawnPoint(mapID);
|
||||
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||
} else if (targetScene != nullptr) {
|
||||
pos = targetScene->GetPosition();
|
||||
rot = targetScene->GetRotation();
|
||||
} else {
|
||||
pos = dZoneManager::Instance()->GetZone()->GetSpawnPos();
|
||||
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||
}
|
||||
// if (m_Character->HasBeenToWorld(mapID) && targetSceneName.empty()) {
|
||||
// pos = m_Character->GetRespawnPoint(mapID);
|
||||
// rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||
// } else if (targetScene != nullptr) {
|
||||
// pos = targetScene->GetPosition();
|
||||
// rot = targetScene->GetRotation();
|
||||
// } else {
|
||||
// pos = dZoneManager::Instance()->GetZone()->GetSpawnPos();
|
||||
// rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||
// }
|
||||
|
||||
controllablePhysics->SetPosition(pos);
|
||||
controllablePhysics->SetRotation(rot);
|
||||
}
|
||||
} else {
|
||||
controllablePhysics->SetPosition(m_DefaultPosition);
|
||||
controllablePhysics->SetRotation(m_DefaultRotation);
|
||||
}
|
||||
// controllablePhysics->SetPosition(pos);
|
||||
// controllablePhysics->SetRotation(rot);
|
||||
// }
|
||||
// } else {
|
||||
// controllablePhysics->SetPosition(m_DefaultPosition);
|
||||
// controllablePhysics->SetRotation(m_DefaultRotation);
|
||||
// }
|
||||
|
||||
m_Components.insert(std::make_pair(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysics));
|
||||
}
|
||||
// m_Components.insert(std::make_pair(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysics));
|
||||
// }
|
||||
|
||||
// If an entity is marked a phantom, simple physics is made into phantom phyics.
|
||||
bool markedAsPhantom = GetVar<bool>(u"markedAsPhantom");
|
||||
|
@ -65,10 +65,10 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
|
||||
|
||||
// Get aggro and tether radius from settings and use this if it is present. Only overwrite the
|
||||
// radii if it is greater than the one in the database.
|
||||
if (m_OwningEntity) {
|
||||
auto aggroRadius = m_OwningEntity->GetVar<float>(u"aggroRadius");
|
||||
if (m_ParentEntity) {
|
||||
auto aggroRadius = m_ParentEntity->GetVar<float>(u"aggroRadius");
|
||||
m_AggroRadius = aggroRadius != 0 ? aggroRadius : m_AggroRadius;
|
||||
auto tetherRadius = m_OwningEntity->GetVar<float>(u"tetherRadius");
|
||||
auto tetherRadius = m_ParentEntity->GetVar<float>(u"tetherRadius");
|
||||
m_HardTetherRadius = tetherRadius != 0 ? tetherRadius : m_HardTetherRadius;
|
||||
}
|
||||
|
||||
@ -120,14 +120,14 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
|
||||
}
|
||||
|
||||
//Create a phantom physics volume so we can detect when we're aggro'd.
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), m_AggroRadius);
|
||||
m_dpEntityEnemy = new dpEntity(m_OwningEntity->GetObjectID(), m_AggroRadius, false);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), m_AggroRadius);
|
||||
m_dpEntityEnemy = new dpEntity(m_ParentEntity->GetObjectID(), m_AggroRadius, false);
|
||||
|
||||
m_dpEntity->SetCollisionGroup(collisionGroup);
|
||||
m_dpEntityEnemy->SetCollisionGroup(collisionGroup);
|
||||
|
||||
m_dpEntity->SetPosition(m_OwningEntity->GetPosition());
|
||||
m_dpEntityEnemy->SetPosition(m_OwningEntity->GetPosition());
|
||||
m_dpEntity->SetPosition(m_ParentEntity->GetPosition());
|
||||
m_dpEntityEnemy->SetPosition(m_ParentEntity->GetPosition());
|
||||
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
dpWorld::Instance().AddEntity(m_dpEntityEnemy);
|
||||
@ -146,17 +146,17 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
|
||||
//First, we need to process physics:
|
||||
if (!m_dpEntity) return;
|
||||
|
||||
m_dpEntity->SetPosition(m_OwningEntity->GetPosition()); //make sure our position is synced with our dpEntity
|
||||
m_dpEntityEnemy->SetPosition(m_OwningEntity->GetPosition());
|
||||
m_dpEntity->SetPosition(m_ParentEntity->GetPosition()); //make sure our position is synced with our dpEntity
|
||||
m_dpEntityEnemy->SetPosition(m_ParentEntity->GetPosition());
|
||||
|
||||
//Process enter events
|
||||
for (auto en : m_dpEntity->GetNewObjects()) {
|
||||
m_OwningEntity->OnCollisionPhantom(en->GetObjectID());
|
||||
m_ParentEntity->OnCollisionPhantom(en->GetObjectID());
|
||||
}
|
||||
|
||||
//Process exit events
|
||||
for (auto en : m_dpEntity->GetRemovedObjects()) {
|
||||
m_OwningEntity->OnCollisionLeavePhantom(en->GetObjectID());
|
||||
m_ParentEntity->OnCollisionLeavePhantom(en->GetObjectID());
|
||||
}
|
||||
|
||||
// Check if we should stop the tether effect
|
||||
@ -165,32 +165,32 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
|
||||
const auto& info = m_MovementAI->GetInfo();
|
||||
if (m_Target != LWOOBJID_EMPTY || (NiPoint3::DistanceSquared(
|
||||
m_StartPosition,
|
||||
m_OwningEntity->GetPosition()) < 20 * 20 && m_TetherTime <= 0)
|
||||
m_ParentEntity->GetPosition()) < 20 * 20 && m_TetherTime <= 0)
|
||||
) {
|
||||
GameMessages::SendStopFXEffect(m_OwningEntity, true, "tether");
|
||||
GameMessages::SendStopFXEffect(m_ParentEntity, true, "tether");
|
||||
m_TetherEffectActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_SoftTimer <= 0.0f) {
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
m_SoftTimer = 5.0f;
|
||||
} else {
|
||||
m_SoftTimer -= deltaTime;
|
||||
}
|
||||
|
||||
if (m_Disabled || m_OwningEntity->GetIsDead())
|
||||
if (m_Disabled || m_ParentEntity->GetIsDead())
|
||||
return;
|
||||
bool stunnedThisFrame = m_Stunned;
|
||||
CalculateCombat(deltaTime); // Putting this here for now
|
||||
|
||||
if (m_StartPosition == NiPoint3::ZERO) {
|
||||
m_StartPosition = m_OwningEntity->GetPosition();
|
||||
m_StartPosition = m_ParentEntity->GetPosition();
|
||||
}
|
||||
|
||||
if (m_MovementAI == nullptr) {
|
||||
m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
|
||||
m_MovementAI = m_ParentEntity->GetComponent<MovementAIComponent>();
|
||||
if (m_MovementAI == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -244,7 +244,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
||||
bool hadRemainingDowntime = m_SkillTime > 0.0f;
|
||||
if (m_SkillTime > 0.0f) m_SkillTime -= deltaTime;
|
||||
|
||||
auto* rebuild = m_OwningEntity->GetComponent<RebuildComponent>();
|
||||
auto* rebuild = m_ParentEntity->GetComponent<RebuildComponent>();
|
||||
|
||||
if (rebuild != nullptr) {
|
||||
const auto state = rebuild->GetState();
|
||||
@ -254,7 +254,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
||||
}
|
||||
}
|
||||
|
||||
auto* skillComponent = m_OwningEntity->GetComponent<SkillComponent>();
|
||||
auto* skillComponent = m_ParentEntity->GetComponent<SkillComponent>();
|
||||
|
||||
if (skillComponent == nullptr) {
|
||||
return;
|
||||
@ -288,7 +288,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
||||
}
|
||||
|
||||
if (!m_TetherEffectActive && m_OutOfCombat && (m_OutOfCombatTime -= deltaTime) <= 0) {
|
||||
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
|
||||
auto* destroyableComponent = m_ParentEntity->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent != nullptr && destroyableComponent->HasFaction(4)) {
|
||||
auto serilizationRequired = false;
|
||||
@ -306,10 +306,10 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
|
||||
}
|
||||
|
||||
if (serilizationRequired) {
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 6270, u"tether", "tether");
|
||||
GameMessages::SendPlayFXEffect(m_ParentEntity->GetObjectID(), 6270, u"tether", "tether");
|
||||
|
||||
m_TetherEffectActive = true;
|
||||
|
||||
@ -497,10 +497,10 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
|
||||
std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
|
||||
std::vector<LWOOBJID> targets;
|
||||
|
||||
for (auto id : m_OwningEntity->GetTargetsInPhantom()) {
|
||||
for (auto id : m_ParentEntity->GetTargetsInPhantom()) {
|
||||
auto* other = EntityManager::Instance()->GetEntity(id);
|
||||
|
||||
const auto distance = Vector3::DistanceSquared(m_OwningEntity->GetPosition(), other->GetPosition());
|
||||
const auto distance = Vector3::DistanceSquared(m_ParentEntity->GetPosition(), other->GetPosition());
|
||||
|
||||
if (distance > m_AggroRadius * m_AggroRadius) continue;
|
||||
|
||||
@ -511,7 +511,7 @@ std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
|
||||
}
|
||||
|
||||
bool BaseCombatAIComponent::IsMech() {
|
||||
switch (m_OwningEntity->GetLOT()) {
|
||||
switch (m_ParentEntity->GetLOT()) {
|
||||
case 6253:
|
||||
return true;
|
||||
|
||||
@ -536,7 +536,7 @@ void BaseCombatAIComponent::SetAiState(AiState newState) {
|
||||
if (newState == this->m_State) return;
|
||||
this->m_State = newState;
|
||||
m_DirtyStateOrTarget = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
|
||||
@ -554,10 +554,10 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* referenceDestroyable = m_OwningEntity->GetComponent<DestroyableComponent>();
|
||||
auto* referenceDestroyable = m_ParentEntity->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (referenceDestroyable == nullptr) {
|
||||
Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_OwningEntity->GetObjectID());
|
||||
Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_ParentEntity->GetObjectID());
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -589,7 +589,7 @@ void BaseCombatAIComponent::SetTarget(const LWOOBJID target) {
|
||||
if (this->m_Target == target) return;
|
||||
m_Target = target;
|
||||
m_DirtyStateOrTarget = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
Entity* BaseCombatAIComponent::GetTargetEntity() const {
|
||||
@ -598,7 +598,7 @@ Entity* BaseCombatAIComponent::GetTargetEntity() const {
|
||||
|
||||
void BaseCombatAIComponent::Taunt(LWOOBJID offender, float threat) {
|
||||
// Can't taunt self
|
||||
if (offender == m_OwningEntity->GetObjectID())
|
||||
if (offender == m_ParentEntity->GetObjectID())
|
||||
return;
|
||||
|
||||
m_ThreatEntries[offender] += threat;
|
||||
@ -789,7 +789,7 @@ void BaseCombatAIComponent::LookAt(const NiPoint3& point) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_OwningEntity->SetRotation(NiQuaternion::LookAt(m_OwningEntity->GetPosition(), point));
|
||||
m_ParentEntity->SetRotation(NiQuaternion::LookAt(m_ParentEntity->GetPosition(), point));
|
||||
}
|
||||
|
||||
void BaseCombatAIComponent::SetDisabled(bool value) {
|
||||
|
@ -30,28 +30,28 @@ void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitia
|
||||
}
|
||||
|
||||
Entity* BouncerComponent::GetParentEntity() const {
|
||||
return m_OwningEntity;
|
||||
return m_ParentEntity;
|
||||
}
|
||||
|
||||
void BouncerComponent::SetPetEnabled(bool value) {
|
||||
m_PetEnabled = value;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void BouncerComponent::SetPetBouncerEnabled(bool value) {
|
||||
m_PetBouncerEnabled = value;
|
||||
|
||||
GameMessages::SendBouncerActiveStatus(m_OwningEntity->GetObjectID(), value, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendBouncerActiveStatus(m_ParentEntity->GetObjectID(), value, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
if (value) {
|
||||
m_OwningEntity->TriggerEvent(eTriggerEventType::PET_ON_SWITCH, m_OwningEntity);
|
||||
GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 1513, u"create", "PetOnSwitch", LWOOBJID_EMPTY, 1, 1, true);
|
||||
m_ParentEntity->TriggerEvent(eTriggerEventType::PET_ON_SWITCH, m_ParentEntity);
|
||||
GameMessages::SendPlayFXEffect(m_ParentEntity->GetObjectID(), 1513, u"create", "PetOnSwitch", LWOOBJID_EMPTY, 1, 1, true);
|
||||
} else {
|
||||
m_OwningEntity->TriggerEvent(eTriggerEventType::PET_OFF_SWITCH, m_OwningEntity);
|
||||
GameMessages::SendStopFXEffect(m_OwningEntity, true, "PetOnSwitch");
|
||||
m_ParentEntity->TriggerEvent(eTriggerEventType::PET_OFF_SWITCH, m_ParentEntity);
|
||||
GameMessages::SendStopFXEffect(m_ParentEntity, true, "PetOnSwitch");
|
||||
}
|
||||
|
||||
}
|
||||
@ -65,7 +65,7 @@ bool BouncerComponent::GetPetBouncerEnabled() const {
|
||||
}
|
||||
|
||||
void BouncerComponent::LookupPetSwitch() {
|
||||
const auto& groups = m_OwningEntity->GetGroups();
|
||||
const auto& groups = m_ParentEntity->GetGroups();
|
||||
|
||||
for (const auto& group : groups) {
|
||||
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup(group);
|
||||
@ -79,7 +79,7 @@ void BouncerComponent::LookupPetSwitch() {
|
||||
m_PetSwitchLoaded = true;
|
||||
m_PetEnabled = true;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
Game::logger->Log("BouncerComponent", "Loaded pet bouncer");
|
||||
}
|
||||
@ -89,7 +89,7 @@ void BouncerComponent::LookupPetSwitch() {
|
||||
if (!m_PetSwitchLoaded) {
|
||||
Game::logger->Log("BouncerComponent", "Failed to load pet bouncer");
|
||||
|
||||
m_OwningEntity->AddCallbackTimer(0.5f, [this]() {
|
||||
m_ParentEntity->AddCallbackTimer(0.5f, [this]() {
|
||||
LookupPetSwitch();
|
||||
});
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ void BuffComponent::Update(float deltaTime) {
|
||||
buff.second.tickTime = buff.second.tick;
|
||||
buff.second.stacks--;
|
||||
|
||||
SkillComponent::HandleUnmanaged(buff.second.behaviorID, m_OwningEntity->GetObjectID(), buff.second.source);
|
||||
SkillComponent::HandleUnmanaged(buff.second.behaviorID, m_ParentEntity->GetObjectID(), buff.second.source);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOO
|
||||
return;
|
||||
}
|
||||
|
||||
GameMessages::SendAddBuff(m_OwningEntity->GetObjectID(), source, (uint32_t)id,
|
||||
GameMessages::SendAddBuff(m_ParentEntity->GetObjectID(), source, (uint32_t)id,
|
||||
(uint32_t)duration * 1000, addImmunity, cancelOnDamaged, cancelOnDeath,
|
||||
cancelOnLogout, cancelOnRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone);
|
||||
|
||||
@ -132,7 +132,7 @@ void BuffComponent::RemoveBuff(int32_t id, bool fromUnEquip, bool removeImmunity
|
||||
return;
|
||||
}
|
||||
|
||||
GameMessages::SendRemoveBuff(m_OwningEntity, fromUnEquip, removeImmunity, id);
|
||||
GameMessages::SendRemoveBuff(m_ParentEntity, fromUnEquip, removeImmunity, id);
|
||||
|
||||
m_Buffs.erase(iter);
|
||||
|
||||
@ -234,7 +234,7 @@ void BuffComponent::ReApplyBuffs() {
|
||||
}
|
||||
|
||||
Entity* BuffComponent::GetParentEntity() const {
|
||||
return m_OwningEntity;
|
||||
return m_ParentEntity;
|
||||
}
|
||||
|
||||
void BuffComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
||||
|
@ -19,7 +19,7 @@ void BuildBorderComponent::OnUse(Entity* originator) {
|
||||
if (originator->GetCharacter()) {
|
||||
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup("PropertyPlaque");
|
||||
|
||||
auto buildArea = m_OwningEntity->GetObjectID();
|
||||
auto buildArea = m_ParentEntity->GetObjectID();
|
||||
|
||||
if (!entities.empty()) {
|
||||
buildArea = entities[0]->GetObjectID();
|
||||
@ -63,7 +63,7 @@ void BuildBorderComponent::OnUse(Entity* originator) {
|
||||
GameMessages::SendStartArrangingWithItem(originator, originator->GetSystemAddress(), true, buildArea, originator->GetPosition());
|
||||
}
|
||||
|
||||
auto* inv = m_OwningEntity->GetComponent<InventoryComponent>();
|
||||
auto* inv = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||
if (!inv) return;
|
||||
inv->PushEquippedItems(); // technically this is supposed to happen automatically... but it doesnt? so just keep this here
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ void CharacterComponent::TrackRaceCompleted(bool won) {
|
||||
}
|
||||
|
||||
void CharacterComponent::TrackPositionUpdate(const NiPoint3& newPosition) {
|
||||
const auto distance = NiPoint3::Distance(newPosition, m_OwningEntity->GetPosition());
|
||||
const auto distance = NiPoint3::Distance(newPosition, m_ParentEntity->GetPosition());
|
||||
|
||||
if (m_IsRacing) {
|
||||
UpdatePlayerStatistic(DistanceDriven, (uint64_t)distance);
|
||||
@ -731,8 +731,8 @@ void CharacterComponent::RemoveVentureVisionEffect(std::string ventureVisionType
|
||||
}
|
||||
|
||||
void CharacterComponent::UpdateClientMinimap(bool showFaction, std::string ventureVisionType) const {
|
||||
if (!m_OwningEntity) return;
|
||||
if (!m_ParentEntity) return;
|
||||
AMFArrayValue arrayToSend;
|
||||
arrayToSend.Insert(ventureVisionType, showFaction);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity ? m_OwningEntity->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", arrayToSend);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_ParentEntity, m_ParentEntity ? m_ParentEntity->GetSystemAddress() : UNASSIGNED_SYSTEM_ADDRESS, "SetFactionVisibility", arrayToSend);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
Component::Component(Entity* owningEntity) {
|
||||
DluAssert(owningEntity != nullptr);
|
||||
m_OwningEntity = owningEntity;
|
||||
m_ParentEntity = owningEntity;
|
||||
}
|
||||
|
||||
Component::~Component() {
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
* Gets the owner of this component
|
||||
* @return the owner of this component
|
||||
*/
|
||||
Entity* GetParentEntity() const { return m_OwningEntity; };
|
||||
Entity* GetParentEntity() const { return m_ParentEntity; };
|
||||
|
||||
/**
|
||||
* Event called when this component is being used, e.g. when some entity interacted with it
|
||||
@ -70,5 +70,5 @@ protected:
|
||||
/**
|
||||
* The entity that owns this component
|
||||
*/
|
||||
Entity* m_OwningEntity;
|
||||
Entity* m_ParentEntity;
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "BitStream.h"
|
||||
#include "dLogger.h"
|
||||
#include "Game.h"
|
||||
#include "dServer.h"
|
||||
|
||||
#include "dpWorld.h"
|
||||
#include "dpEntity.h"
|
||||
@ -51,17 +52,15 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Com
|
||||
m_ImmuneToStunTurnCount = 0;
|
||||
m_ImmuneToStunUseItemCount = 0;
|
||||
|
||||
if (entity->GetLOT() != 1) // Other physics entities we care about will be added by BaseCombatAI
|
||||
return;
|
||||
// Other physics entities we care about will be added by BaseCombatAI
|
||||
if (entity->GetLOT() != 1) return;
|
||||
|
||||
if (entity->GetLOT() == 1) {
|
||||
Game::logger->Log("ControllablePhysicsComponent", "Using patch to load minifig physics");
|
||||
Game::logger->Log("ControllablePhysicsComponent", "Using patch to load minifig physics");
|
||||
|
||||
float radius = 1.5f;
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), radius, false);
|
||||
m_dpEntity->SetCollisionGroup(COLLISION_GROUP_DYNAMIC | COLLISION_GROUP_FRIENDLY);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
}
|
||||
float radius = 1.5f;
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), radius, false);
|
||||
m_dpEntity->SetCollisionGroup(COLLISION_GROUP_DYNAMIC | COLLISION_GROUP_FRIENDLY);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
}
|
||||
|
||||
ControllablePhysicsComponent::~ControllablePhysicsComponent() {
|
||||
@ -70,7 +69,18 @@ ControllablePhysicsComponent::~ControllablePhysicsComponent() {
|
||||
}
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::Update(float deltaTime) {
|
||||
void ControllablePhysicsComponent::Startup() {
|
||||
NiPoint3 pos = m_ParentEntity->GetDefaultPosition();
|
||||
NiQuaternion rot = m_ParentEntity->GetDefaultRotation();
|
||||
SetPosition(pos);
|
||||
SetRotation(rot);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::LoadConfigData() {
|
||||
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::LoadTemplateData() {
|
||||
|
||||
}
|
||||
|
||||
@ -162,22 +172,45 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
||||
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
|
||||
if (!character) {
|
||||
tinyxml2::XMLElement* characterElem = doc->FirstChildElement("obj")->FirstChildElement("char");
|
||||
if (!characterElem) {
|
||||
Game::logger->Log("ControllablePhysicsComponent", "Failed to find char tag!");
|
||||
return;
|
||||
}
|
||||
|
||||
m_OwningEntity->GetCharacter()->LoadXmlRespawnCheckpoints();
|
||||
m_ParentEntity->GetCharacter()->LoadXmlRespawnCheckpoints();
|
||||
|
||||
character->QueryAttribute("lzx", &m_Position.x);
|
||||
character->QueryAttribute("lzy", &m_Position.y);
|
||||
character->QueryAttribute("lzz", &m_Position.z);
|
||||
character->QueryAttribute("lzrx", &m_Rotation.x);
|
||||
character->QueryAttribute("lzry", &m_Rotation.y);
|
||||
character->QueryAttribute("lzrz", &m_Rotation.z);
|
||||
character->QueryAttribute("lzrw", &m_Rotation.w);
|
||||
characterElem->QueryAttribute("lzx", &m_Position.x);
|
||||
characterElem->QueryAttribute("lzy", &m_Position.y);
|
||||
characterElem->QueryAttribute("lzz", &m_Position.z);
|
||||
characterElem->QueryAttribute("lzrx", &m_Rotation.x);
|
||||
characterElem->QueryAttribute("lzry", &m_Rotation.y);
|
||||
characterElem->QueryAttribute("lzrz", &m_Rotation.z);
|
||||
characterElem->QueryAttribute("lzrw", &m_Rotation.w);
|
||||
|
||||
auto* character = GetParentEntity()->GetCharacter();
|
||||
const auto mapID = Game::server->GetZoneID();
|
||||
|
||||
//If we came from another zone, put us in the starting loc
|
||||
if (character->GetZoneID() != Game::server->GetZoneID() || mapID == 1603) { // Exception for Moon Base as you tend to spawn on the roof.
|
||||
const auto& targetSceneName = character->GetTargetScene();
|
||||
auto* targetScene = EntityManager::Instance()->GetSpawnPointEntity(targetSceneName);
|
||||
|
||||
NiPoint3 pos;
|
||||
NiQuaternion rot;
|
||||
if (character->HasBeenToWorld(mapID) && targetSceneName.empty()) {
|
||||
pos = character->GetRespawnPoint(mapID);
|
||||
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||
} else if (targetScene) {
|
||||
pos = targetScene->GetPosition();
|
||||
rot = targetScene->GetRotation();
|
||||
} else {
|
||||
pos = dZoneManager::Instance()->GetZone()->GetSpawnPos();
|
||||
rot = dZoneManager::Instance()->GetZone()->GetSpawnRot();
|
||||
}
|
||||
SetPosition(pos);
|
||||
SetRotation(rot);
|
||||
}
|
||||
m_DirtyPosition = true;
|
||||
}
|
||||
|
||||
@ -208,9 +241,7 @@ void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::SetPosition(const NiPoint3& pos) {
|
||||
if (m_Static) {
|
||||
return;
|
||||
}
|
||||
if (m_Static || pos == m_Position) return;
|
||||
|
||||
m_Position.x = pos.x;
|
||||
m_Position.y = pos.y;
|
||||
@ -221,9 +252,7 @@ void ControllablePhysicsComponent::SetPosition(const NiPoint3& pos) {
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::SetRotation(const NiQuaternion& rot) {
|
||||
if (m_Static) {
|
||||
return;
|
||||
}
|
||||
if (m_Static || rot == m_Rotation) return;
|
||||
|
||||
m_Rotation = rot;
|
||||
m_DirtyPosition = true;
|
||||
@ -244,7 +273,7 @@ void ControllablePhysicsComponent::SetVelocity(const NiPoint3& vel) {
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) {
|
||||
if (m_Static) {
|
||||
if (m_Static || vel == m_AngularVelocity) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -254,13 +283,15 @@ void ControllablePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) {
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::SetIsOnGround(bool val) {
|
||||
m_DirtyPosition = true;
|
||||
if (m_IsOnGround == val) return;
|
||||
m_IsOnGround = val;
|
||||
m_DirtyPosition = true;
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::SetIsOnRail(bool val) {
|
||||
m_DirtyPosition = true;
|
||||
if (m_IsOnRail == val) return;
|
||||
m_IsOnRail = val;
|
||||
m_DirtyPosition = true;
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::SetDirtyPosition(bool val) {
|
||||
@ -300,7 +331,7 @@ void ControllablePhysicsComponent::RemovePickupRadiusScale(float value) {
|
||||
auto candidateRadius = m_ActivePickupRadiusScales[i];
|
||||
if (m_PickupRadius < candidateRadius) m_PickupRadius = candidateRadius;
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::AddSpeedboost(float value) {
|
||||
@ -321,16 +352,16 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) {
|
||||
// Recalculate speedboost since we removed one
|
||||
m_SpeedBoost = 0.0f;
|
||||
if (m_ActiveSpeedBoosts.empty()) { // no active speed boosts left, so return to base speed
|
||||
auto* levelProgressionComponent = m_OwningEntity->GetComponent<LevelProgressionComponent>();
|
||||
auto* levelProgressionComponent = m_ParentEntity->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_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims){
|
||||
void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims) {
|
||||
if (m_IsInBubble) {
|
||||
Game::logger->Log("ControllablePhysicsComponent", "Already in bubble");
|
||||
return;
|
||||
@ -339,13 +370,13 @@ void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bo
|
||||
m_IsInBubble = true;
|
||||
m_DirtyBubble = true;
|
||||
m_SpecialAnims = specialAnims;
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::DeactivateBubbleBuff(){
|
||||
void ControllablePhysicsComponent::DeactivateBubbleBuff() {
|
||||
m_DirtyBubble = true;
|
||||
m_IsInBubble = false;
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
};
|
||||
|
||||
void ControllablePhysicsComponent::SetStunImmunity(
|
||||
@ -357,9 +388,9 @@ void ControllablePhysicsComponent::SetStunImmunity(
|
||||
const bool bImmuneToStunJump,
|
||||
const bool bImmuneToStunMove,
|
||||
const bool bImmuneToStunTurn,
|
||||
const bool bImmuneToStunUseItem){
|
||||
const bool bImmuneToStunUseItem) {
|
||||
|
||||
if (state == eStateChangeType::POP){
|
||||
if (state == eStateChangeType::POP) {
|
||||
if (bImmuneToStunAttack && m_ImmuneToStunAttackCount > 0) m_ImmuneToStunAttackCount -= 1;
|
||||
if (bImmuneToStunEquip && m_ImmuneToStunEquipCount > 0) m_ImmuneToStunEquipCount -= 1;
|
||||
if (bImmuneToStunInteract && m_ImmuneToStunInteractCount > 0) m_ImmuneToStunInteractCount -= 1;
|
||||
@ -378,7 +409,7 @@ void ControllablePhysicsComponent::SetStunImmunity(
|
||||
}
|
||||
|
||||
GameMessages::SendSetStunImmunity(
|
||||
m_OwningEntity->GetObjectID(), state, m_OwningEntity->GetSystemAddress(), originator,
|
||||
m_ParentEntity->GetObjectID(), state, m_ParentEntity->GetSystemAddress(), originator,
|
||||
bImmuneToStunAttack,
|
||||
bImmuneToStunEquip,
|
||||
bImmuneToStunInteract,
|
||||
|
@ -26,11 +26,13 @@ public:
|
||||
ControllablePhysicsComponent(Entity* entity);
|
||||
~ControllablePhysicsComponent() override;
|
||||
|
||||
void Update(float deltaTime) override;
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||
void LoadFromXml(tinyxml2::XMLDocument* doc) override;
|
||||
void ResetFlags();
|
||||
void UpdateXml(tinyxml2::XMLDocument* doc) override;
|
||||
void Startup() override;
|
||||
void LoadConfigData() override;
|
||||
void LoadTemplateData() override;
|
||||
|
||||
/**
|
||||
* Sets the position of this entity, also ensures this update is serialized next tick.
|
||||
|
@ -185,7 +185,7 @@ void DestroyableComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* buffComponent = m_OwningEntity->GetComponent<BuffComponent>();
|
||||
auto* buffComponent = m_ParentEntity->GetComponent<BuffComponent>();
|
||||
|
||||
if (buffComponent != nullptr) {
|
||||
buffComponent->LoadFromXml(doc);
|
||||
@ -207,7 +207,7 @@ void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* buffComponent = m_OwningEntity->GetComponent<BuffComponent>();
|
||||
auto* buffComponent = m_ParentEntity->GetComponent<BuffComponent>();
|
||||
|
||||
if (buffComponent != nullptr) {
|
||||
buffComponent->UpdateXml(doc);
|
||||
@ -224,7 +224,7 @@ void DestroyableComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
|
||||
void DestroyableComponent::SetHealth(int32_t value) {
|
||||
m_DirtyHealth = true;
|
||||
|
||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
||||
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||
if (characterComponent != nullptr) {
|
||||
characterComponent->TrackHealthDelta(value - m_iHealth);
|
||||
}
|
||||
@ -244,16 +244,16 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) {
|
||||
|
||||
if (playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_OwningEntity->GetParentUser()) return;
|
||||
if (!m_ParentEntity->GetParentUser()) return;
|
||||
|
||||
AMFArrayValue args;
|
||||
args.Insert("amount", std::to_string(difference));
|
||||
args.Insert("type", "health");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_ParentEntity, m_ParentEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetArmor(int32_t value) {
|
||||
@ -262,14 +262,14 @@ void DestroyableComponent::SetArmor(int32_t value) {
|
||||
// If Destroyable Component already has zero armor do not trigger the passive ability again.
|
||||
bool hadArmor = m_iArmor > 0;
|
||||
|
||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
||||
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||
if (characterComponent != nullptr) {
|
||||
characterComponent->TrackArmorDelta(value - m_iArmor);
|
||||
}
|
||||
|
||||
m_iArmor = value;
|
||||
|
||||
auto* inventroyComponent = m_OwningEntity->GetComponent<InventoryComponent>();
|
||||
auto* inventroyComponent = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||
if (m_iArmor == 0 && inventroyComponent != nullptr && hadArmor) {
|
||||
inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::SentinelArmor);
|
||||
}
|
||||
@ -285,29 +285,29 @@ void DestroyableComponent::SetMaxArmor(float value, bool playAnim) {
|
||||
|
||||
if (playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_OwningEntity->GetParentUser()) return;
|
||||
if (!m_ParentEntity->GetParentUser()) return;
|
||||
|
||||
AMFArrayValue args;
|
||||
args.Insert("amount", std::to_string(value));
|
||||
args.Insert("type", "armor");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_ParentEntity, m_ParentEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetImagination(int32_t value) {
|
||||
m_DirtyHealth = true;
|
||||
|
||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
||||
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||
if (characterComponent != nullptr) {
|
||||
characterComponent->TrackImaginationDelta(value - m_iImagination);
|
||||
}
|
||||
|
||||
m_iImagination = value;
|
||||
|
||||
auto* inventroyComponent = m_OwningEntity->GetComponent<InventoryComponent>();
|
||||
auto* inventroyComponent = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||
if (m_iImagination == 0 && inventroyComponent != nullptr) {
|
||||
inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::AssemblyImagination);
|
||||
}
|
||||
@ -325,15 +325,15 @@ void DestroyableComponent::SetMaxImagination(float value, bool playAnim) {
|
||||
|
||||
if (playAnim) {
|
||||
// Now update the player bar
|
||||
if (!m_OwningEntity->GetParentUser()) return;
|
||||
if (!m_ParentEntity->GetParentUser()) return;
|
||||
|
||||
AMFArrayValue args;
|
||||
args.Insert("amount", std::to_string(difference));
|
||||
args.Insert("type", "imagination");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_OwningEntity, m_OwningEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
GameMessages::SendUIMessageServerToSingleClient(m_ParentEntity, m_ParentEntity->GetParentUser()->GetSystemAddress(), "MaxPlayerBarUpdate", args);
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetDamageToAbsorb(int32_t value) {
|
||||
@ -455,8 +455,8 @@ bool DestroyableComponent::IsImmune() const {
|
||||
}
|
||||
|
||||
bool DestroyableComponent::IsKnockbackImmune() const {
|
||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
||||
auto* inventoryComponent = m_OwningEntity->GetComponent<InventoryComponent>();
|
||||
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||
auto* inventoryComponent = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||
|
||||
if (characterComponent != nullptr && inventoryComponent != nullptr && characterComponent->GetCurrentActivity() == eGameActivity::QUICKBUILDING) {
|
||||
const auto hasPassive = inventoryComponent->HasAnyPassive({
|
||||
@ -532,7 +532,7 @@ void DestroyableComponent::Heal(const uint32_t health) {
|
||||
|
||||
SetHealth(current);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
|
||||
@ -550,7 +550,7 @@ void DestroyableComponent::Imagine(const int32_t deltaImagination) {
|
||||
|
||||
SetImagination(current);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
|
||||
@ -564,7 +564,7 @@ void DestroyableComponent::Repair(const uint32_t armor) {
|
||||
|
||||
SetArmor(current);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
|
||||
@ -616,13 +616,13 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
||||
SetIsShielded(absorb > 0);
|
||||
|
||||
// Dismount on the possessable hit
|
||||
auto* possessable = m_OwningEntity->GetComponent<PossessableComponent>();
|
||||
auto* possessable = m_ParentEntity->GetComponent<PossessableComponent>();
|
||||
if (possessable && possessable->GetDepossessOnHit()) {
|
||||
possessable->Dismount();
|
||||
}
|
||||
|
||||
// Dismount on the possessor hit
|
||||
auto* possessor = m_OwningEntity->GetComponent<PossessorComponent>();
|
||||
auto* possessor = m_ParentEntity->GetComponent<PossessorComponent>();
|
||||
if (possessor) {
|
||||
auto possessableId = possessor->GetPossessable();
|
||||
if (possessableId != LWOOBJID_EMPTY) {
|
||||
@ -633,17 +633,17 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
||||
}
|
||||
}
|
||||
|
||||
if (m_OwningEntity->GetLOT() != 1) {
|
||||
if (m_ParentEntity->GetLOT() != 1) {
|
||||
echo = true;
|
||||
}
|
||||
|
||||
if (echo) {
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
auto* attacker = EntityManager::Instance()->GetEntity(source);
|
||||
m_OwningEntity->OnHit(attacker);
|
||||
m_OwningEntity->OnHitOrHealResult(attacker, sourceDamage);
|
||||
m_ParentEntity->OnHit(attacker);
|
||||
m_ParentEntity->OnHitOrHealResult(attacker, sourceDamage);
|
||||
NotifySubscribers(attacker, sourceDamage);
|
||||
|
||||
for (const auto& cb : m_OnHitCallbacks) {
|
||||
@ -651,7 +651,7 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
||||
}
|
||||
|
||||
if (health != 0) {
|
||||
auto* combatComponent = m_OwningEntity->GetComponent<BaseCombatAIComponent>();
|
||||
auto* combatComponent = m_ParentEntity->GetComponent<BaseCombatAIComponent>();
|
||||
|
||||
if (combatComponent != nullptr) {
|
||||
combatComponent->Taunt(source, sourceDamage * 10); // * 10 is arbatrary
|
||||
@ -670,7 +670,7 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32
|
||||
|
||||
void DestroyableComponent::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd) {
|
||||
m_SubscribedScripts.insert(std::make_pair(scriptObjId, scriptToAdd));
|
||||
Game::logger->LogDebug("DestroyableComponent", "Added script %llu to entity %llu", scriptObjId, m_OwningEntity->GetObjectID());
|
||||
Game::logger->LogDebug("DestroyableComponent", "Added script %llu to entity %llu", scriptObjId, m_ParentEntity->GetObjectID());
|
||||
Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size());
|
||||
}
|
||||
|
||||
@ -678,16 +678,16 @@ void DestroyableComponent::Unsubscribe(LWOOBJID scriptObjId) {
|
||||
auto foundScript = m_SubscribedScripts.find(scriptObjId);
|
||||
if (foundScript != m_SubscribedScripts.end()) {
|
||||
m_SubscribedScripts.erase(foundScript);
|
||||
Game::logger->LogDebug("DestroyableComponent", "Removed script %llu from entity %llu", scriptObjId, m_OwningEntity->GetObjectID());
|
||||
Game::logger->LogDebug("DestroyableComponent", "Removed script %llu from entity %llu", scriptObjId, m_ParentEntity->GetObjectID());
|
||||
} else {
|
||||
Game::logger->LogDebug("DestroyableComponent", "Tried to remove a script for Entity %llu but script %llu didnt exist", m_OwningEntity->GetObjectID(), scriptObjId);
|
||||
Game::logger->LogDebug("DestroyableComponent", "Tried to remove a script for Entity %llu but script %llu didnt exist", m_ParentEntity->GetObjectID(), scriptObjId);
|
||||
}
|
||||
Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size());
|
||||
}
|
||||
|
||||
void DestroyableComponent::NotifySubscribers(Entity* attacker, uint32_t damage) {
|
||||
for (auto script : m_SubscribedScripts) {
|
||||
script.second->NotifyHitOrHealResult(m_OwningEntity, attacker, damage);
|
||||
script.second->NotifyHitOrHealResult(m_ParentEntity, attacker, damage);
|
||||
}
|
||||
}
|
||||
|
||||
@ -696,7 +696,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
SetArmor(0);
|
||||
SetHealth(0);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
m_KillerID = source;
|
||||
@ -708,12 +708,12 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
|
||||
auto* team = TeamManager::Instance()->GetTeam(owner->GetObjectID());
|
||||
|
||||
const auto isEnemy = m_OwningEntity->GetComponent<BaseCombatAIComponent>() != nullptr;
|
||||
const auto isEnemy = m_ParentEntity->GetComponent<BaseCombatAIComponent>() != nullptr;
|
||||
|
||||
auto* inventoryComponent = owner->GetComponent<InventoryComponent>();
|
||||
|
||||
if (inventoryComponent != nullptr && isEnemy) {
|
||||
inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_OwningEntity);
|
||||
inventoryComponent->TriggerPassiveAbility(PassiveAbilityTrigger::EnemySmashed, m_ParentEntity);
|
||||
}
|
||||
|
||||
auto* missions = owner->GetComponent<MissionComponent>();
|
||||
@ -729,28 +729,28 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
|
||||
if (memberMissions == nullptr) continue;
|
||||
|
||||
memberMissions->Progress(eMissionTaskType::SMASH, m_OwningEntity->GetLOT());
|
||||
memberMissions->Progress(eMissionTaskType::USE_SKILL, m_OwningEntity->GetLOT(), skillID);
|
||||
memberMissions->Progress(eMissionTaskType::SMASH, m_ParentEntity->GetLOT());
|
||||
memberMissions->Progress(eMissionTaskType::USE_SKILL, m_ParentEntity->GetLOT(), skillID);
|
||||
}
|
||||
} else {
|
||||
missions->Progress(eMissionTaskType::SMASH, m_OwningEntity->GetLOT());
|
||||
missions->Progress(eMissionTaskType::USE_SKILL, m_OwningEntity->GetLOT(), skillID);
|
||||
missions->Progress(eMissionTaskType::SMASH, m_ParentEntity->GetLOT());
|
||||
missions->Progress(eMissionTaskType::USE_SKILL, m_ParentEntity->GetLOT(), skillID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto isPlayer = m_OwningEntity->IsPlayer();
|
||||
const auto isPlayer = m_ParentEntity->IsPlayer();
|
||||
|
||||
GameMessages::SendDie(m_OwningEntity, source, source, true, killType, deathType, 0, 0, 0, isPlayer, false, 1);
|
||||
GameMessages::SendDie(m_ParentEntity, source, source, true, killType, deathType, 0, 0, 0, isPlayer, false, 1);
|
||||
|
||||
//NANI?!
|
||||
if (!isPlayer) {
|
||||
if (owner != nullptr) {
|
||||
auto* team = TeamManager::Instance()->GetTeam(owner->GetObjectID());
|
||||
|
||||
if (team != nullptr && m_OwningEntity->GetComponent<BaseCombatAIComponent>() != nullptr) {
|
||||
if (team != nullptr && m_ParentEntity->GetComponent<BaseCombatAIComponent>() != nullptr) {
|
||||
LWOOBJID specificOwner = LWOOBJID_EMPTY;
|
||||
auto* scriptedActivityComponent = m_OwningEntity->GetComponent<ScriptedActivityComponent>();
|
||||
auto* scriptedActivityComponent = m_ParentEntity->GetComponent<ScriptedActivityComponent>();
|
||||
uint32_t teamSize = team->members.size();
|
||||
uint32_t lootMatrixId = GetLootMatrixID();
|
||||
|
||||
@ -763,24 +763,24 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
|
||||
auto* member = EntityManager::Instance()->GetEntity(specificOwner);
|
||||
|
||||
if (member) LootGenerator::Instance().DropLoot(member, m_OwningEntity, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||
if (member) LootGenerator::Instance().DropLoot(member, m_ParentEntity, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||
} else {
|
||||
for (const auto memberId : team->members) { // Free for all
|
||||
auto* member = EntityManager::Instance()->GetEntity(memberId);
|
||||
|
||||
if (member == nullptr) continue;
|
||||
|
||||
LootGenerator::Instance().DropLoot(member, m_OwningEntity, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||
LootGenerator::Instance().DropLoot(member, m_ParentEntity, lootMatrixId, GetMinCoins(), GetMaxCoins());
|
||||
}
|
||||
}
|
||||
} else { // drop loot for non team user
|
||||
LootGenerator::Instance().DropLoot(owner, m_OwningEntity, GetLootMatrixID(), GetMinCoins(), GetMaxCoins());
|
||||
LootGenerator::Instance().DropLoot(owner, m_ParentEntity, GetLootMatrixID(), GetMinCoins(), GetMaxCoins());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//Check if this zone allows coin drops
|
||||
if (dZoneManager::Instance()->GetPlayerLoseCoinOnDeath()) {
|
||||
auto* character = m_OwningEntity->GetCharacter();
|
||||
auto* character = m_ParentEntity->GetCharacter();
|
||||
uint64_t coinsTotal = character->GetCoins();
|
||||
const uint64_t minCoinsToLose = dZoneManager::Instance()->GetWorldConfig()->coinsLostOnDeathMin;
|
||||
if (coinsTotal >= minCoinsToLose) {
|
||||
@ -792,27 +792,27 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType
|
||||
|
||||
coinsTotal -= coinsToLose;
|
||||
|
||||
LootGenerator::Instance().DropLoot(m_OwningEntity, m_OwningEntity, -1, coinsToLose, coinsToLose);
|
||||
LootGenerator::Instance().DropLoot(m_ParentEntity, m_ParentEntity, -1, coinsToLose, coinsToLose);
|
||||
character->SetCoins(coinsTotal, eLootSourceType::PICKUP);
|
||||
}
|
||||
}
|
||||
|
||||
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
|
||||
script->OnPlayerDied(zoneControl, m_OwningEntity);
|
||||
script->OnPlayerDied(zoneControl, m_ParentEntity);
|
||||
}
|
||||
|
||||
std::vector<Entity*> scriptedActs = EntityManager::Instance()->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)) {
|
||||
script->OnPlayerDied(scriptEntity, m_OwningEntity);
|
||||
script->OnPlayerDied(scriptEntity, m_ParentEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_OwningEntity->Kill(owner);
|
||||
m_ParentEntity->Kill(owner);
|
||||
}
|
||||
|
||||
void DestroyableComponent::SetFaction(int32_t factionID, bool ignoreChecks) {
|
||||
@ -858,7 +858,7 @@ void DestroyableComponent::SetStatusImmunity(
|
||||
}
|
||||
|
||||
GameMessages::SendSetStatusImmunity(
|
||||
m_OwningEntity->GetObjectID(), state, m_OwningEntity->GetSystemAddress(),
|
||||
m_ParentEntity->GetObjectID(), state, m_ParentEntity->GetSystemAddress(),
|
||||
bImmuneToBasicAttack,
|
||||
bImmuneToDamageOverTime,
|
||||
bImmuneToKnockback,
|
||||
@ -974,19 +974,19 @@ void DestroyableComponent::AddOnHitCallback(const std::function<void(Entity*)>&
|
||||
|
||||
void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
//check if this is a player:
|
||||
if (m_OwningEntity->IsPlayer()) {
|
||||
if (m_ParentEntity->IsPlayer()) {
|
||||
//remove hardcore_lose_uscore_on_death_percent from the player's uscore:
|
||||
auto* character = m_OwningEntity->GetComponent<CharacterComponent>();
|
||||
auto* character = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||
auto uscore = character->GetUScore();
|
||||
|
||||
auto uscoreToLose = uscore * (EntityManager::Instance()->GetHardcoreLoseUscoreOnDeathPercent() / 100);
|
||||
character->SetUScore(uscore - uscoreToLose);
|
||||
|
||||
GameMessages::SendModifyLEGOScore(m_OwningEntity, m_OwningEntity->GetSystemAddress(), -uscoreToLose, eLootSourceType::MISSION);
|
||||
GameMessages::SendModifyLEGOScore(m_ParentEntity, m_ParentEntity->GetSystemAddress(), -uscoreToLose, eLootSourceType::MISSION);
|
||||
|
||||
if (EntityManager::Instance()->GetHardcoreDropinventoryOnDeath()) {
|
||||
//drop all items from inventory:
|
||||
auto* inventory = m_OwningEntity->GetComponent<InventoryComponent>();
|
||||
auto* inventory = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||
if (inventory) {
|
||||
//get the items inventory:
|
||||
auto items = inventory->GetInventory(eInventoryType::ITEMS);
|
||||
@ -998,17 +998,17 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
if (!item.second) continue;
|
||||
// don't drop the thinkng cap
|
||||
if (item.second->GetLot() == 6086) continue;
|
||||
GameMessages::SendDropClientLoot(m_OwningEntity, source, item.second->GetLot(), 0, m_OwningEntity->GetPosition(), item.second->GetCount());
|
||||
GameMessages::SendDropClientLoot(m_ParentEntity, source, item.second->GetLot(), 0, m_ParentEntity->GetPosition(), item.second->GetCount());
|
||||
item.second->SetCount(0, false, false);
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//get character:
|
||||
auto* chars = m_OwningEntity->GetCharacter();
|
||||
auto* chars = m_ParentEntity->GetCharacter();
|
||||
if (chars) {
|
||||
auto coins = chars->GetCoins();
|
||||
|
||||
@ -1016,13 +1016,13 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
chars->SetCoins(0, eLootSourceType::NONE);
|
||||
|
||||
//drop all coins:
|
||||
GameMessages::SendDropClientLoot(m_OwningEntity, source, LOT_NULL, coins, m_OwningEntity->GetPosition());
|
||||
GameMessages::SendDropClientLoot(m_ParentEntity, source, LOT_NULL, coins, m_ParentEntity->GetPosition());
|
||||
}
|
||||
|
||||
// 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_OwningEntity);
|
||||
EntityManager::Instance()->ConstructEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->DestructEntity(m_ParentEntity);
|
||||
EntityManager::Instance()->ConstructEntity(m_ParentEntity);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1039,7 +1039,7 @@ void DestroyableComponent::DoHardcoreModeDrops(const LWOOBJID source){
|
||||
playerStats->SetUScore(playerStats->GetUScore() + uscore);
|
||||
GameMessages::SendModifyLEGOScore(player, player->GetSystemAddress(), uscore, eLootSourceType::MISSION);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
||||
|
||||
void HavokVehiclePhysicsComponent::Update(float deltaTime) {
|
||||
if (m_SoftUpdate > 5) {
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
m_SoftUpdate = 0;
|
||||
} else {
|
||||
|
@ -189,7 +189,7 @@ void InventoryComponent::AddItem(
|
||||
inventoryType = Inventory::FindInventoryTypeForLot(lot);
|
||||
}
|
||||
|
||||
auto* missions = m_OwningEntity->GetComponent<MissionComponent>();
|
||||
auto* missions = m_ParentEntity->GetComponent<MissionComponent>();
|
||||
|
||||
auto* inventory = GetInventory(inventoryType);
|
||||
|
||||
@ -276,7 +276,7 @@ void InventoryComponent::AddItem(
|
||||
|
||||
case 1:
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
GameMessages::SendDropClientLoot(this->m_OwningEntity, this->m_OwningEntity->GetObjectID(), lot, 0, this->m_OwningEntity->GetPosition(), 1);
|
||||
GameMessages::SendDropClientLoot(this->m_ParentEntity, this->m_ParentEntity->GetObjectID(), lot, 0, this->m_ParentEntity->GetPosition(), 1);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -378,7 +378,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in
|
||||
item->SetCount(item->GetCount() - delta, false, false);
|
||||
}
|
||||
|
||||
auto* missionComponent = m_OwningEntity->GetComponent<MissionComponent>();
|
||||
auto* missionComponent = m_ParentEntity->GetComponent<MissionComponent>();
|
||||
|
||||
if (missionComponent != nullptr) {
|
||||
if (IsTransferInventory(inventory)) {
|
||||
@ -479,7 +479,7 @@ bool InventoryComponent::HasSpaceForLoot(const std::unordered_map<LOT, int32_t>&
|
||||
}
|
||||
|
||||
if (slotsNeeded > 0) {
|
||||
GameMessages::SendNotifyNotEnoughInvSpace(m_OwningEntity->GetObjectID(), slotsNeeded, ITEMS, m_OwningEntity->GetSystemAddress());
|
||||
GameMessages::SendNotifyNotEnoughInvSpace(m_ParentEntity->GetObjectID(), slotsNeeded, ITEMS, m_ParentEntity->GetSystemAddress());
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -821,23 +821,23 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* character = m_OwningEntity->GetCharacter();
|
||||
auto* character = m_ParentEntity->GetCharacter();
|
||||
|
||||
if (character != nullptr && !skipChecks) {
|
||||
// Hacky proximity rocket
|
||||
if (item->GetLot() == 6416) {
|
||||
const auto rocketLauchPads = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::ROCKET_LAUNCHPAD_CONTROL);
|
||||
|
||||
const auto position = m_OwningEntity->GetPosition();
|
||||
const auto position = m_ParentEntity->GetPosition();
|
||||
|
||||
for (auto* lauchPad : rocketLauchPads) {
|
||||
if (Vector3::DistanceSquared(lauchPad->GetPosition(), position) > 13 * 13) continue;
|
||||
|
||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
||||
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||
|
||||
if (characterComponent != nullptr) characterComponent->SetLastRocketItemID(item->GetId());
|
||||
|
||||
lauchPad->OnUse(m_OwningEntity);
|
||||
lauchPad->OnUse(m_ParentEntity);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -853,7 +853,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
if (!building && (item->GetLot() == 6086 || type == eItemType::LOOT_MODEL || type == eItemType::VEHICLE)) return;
|
||||
|
||||
if (type != eItemType::LOOT_MODEL && type != eItemType::MODEL) {
|
||||
if (!item->GetBound() && !item->GetPreconditionExpression()->Check(m_OwningEntity)) {
|
||||
if (!item->GetBound() && !item->GetPreconditionExpression()->Check(m_ParentEntity)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -879,7 +879,7 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks) {
|
||||
|
||||
EquipScripts(item);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void InventoryComponent::UnEquipItem(Item* item) {
|
||||
@ -909,12 +909,12 @@ void InventoryComponent::UnEquipItem(Item* item) {
|
||||
|
||||
UnequipScripts(item);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
// Trigger property event
|
||||
if (PropertyManagementComponent::Instance() != nullptr && item->GetCount() > 0 && Inventory::FindInventoryTypeForLot(item->GetLot()) == MODELS) {
|
||||
PropertyManagementComponent::Instance()->GetParentEntity()->OnZonePropertyModelRemovedWhileEquipped(m_OwningEntity);
|
||||
dZoneManager::Instance()->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_OwningEntity);
|
||||
PropertyManagementComponent::Instance()->GetParentEntity()->OnZonePropertyModelRemovedWhileEquipped(m_ParentEntity);
|
||||
dZoneManager::Instance()->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_ParentEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -926,11 +926,11 @@ void InventoryComponent::EquipScripts(Item* equippedItem) {
|
||||
if (scriptComponentID > -1) {
|
||||
CDScriptComponentTable* scriptCompTable = CDClientManager::Instance().GetTable<CDScriptComponentTable>();
|
||||
CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID);
|
||||
auto* itemScript = CppScripts::GetScript(m_OwningEntity, scriptCompData.script_name);
|
||||
auto* itemScript = CppScripts::GetScript(m_ParentEntity, scriptCompData.script_name);
|
||||
if (!itemScript) {
|
||||
Game::logger->Log("InventoryComponent", "null script?");
|
||||
}
|
||||
itemScript->OnFactionTriggerItemEquipped(m_OwningEntity, equippedItem->GetId());
|
||||
itemScript->OnFactionTriggerItemEquipped(m_ParentEntity, equippedItem->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -941,19 +941,19 @@ void InventoryComponent::UnequipScripts(Item* unequippedItem) {
|
||||
if (scriptComponentID > -1) {
|
||||
CDScriptComponentTable* scriptCompTable = CDClientManager::Instance().GetTable<CDScriptComponentTable>();
|
||||
CDScriptComponent scriptCompData = scriptCompTable->GetByID(scriptComponentID);
|
||||
auto* itemScript = CppScripts::GetScript(m_OwningEntity, scriptCompData.script_name);
|
||||
auto* itemScript = CppScripts::GetScript(m_ParentEntity, scriptCompData.script_name);
|
||||
if (!itemScript) {
|
||||
Game::logger->Log("InventoryComponent", "null script?");
|
||||
}
|
||||
itemScript->OnFactionTriggerItemUnequipped(m_OwningEntity, unequippedItem->GetId());
|
||||
itemScript->OnFactionTriggerItemUnequipped(m_ParentEntity, unequippedItem->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
void InventoryComponent::HandlePossession(Item* item) {
|
||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
||||
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||
if (!characterComponent) return;
|
||||
|
||||
auto* possessorComponent = m_OwningEntity->GetComponent<PossessorComponent>();
|
||||
auto* possessorComponent = m_ParentEntity->GetComponent<PossessorComponent>();
|
||||
if (!possessorComponent) return;
|
||||
|
||||
// Don't do anything if we are busy dismounting
|
||||
@ -968,22 +968,22 @@ void InventoryComponent::HandlePossession(Item* item) {
|
||||
return;
|
||||
}
|
||||
|
||||
GameMessages::SendSetStunned(m_OwningEntity->GetObjectID(), eStateChangeType::PUSH, m_OwningEntity->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||
GameMessages::SendSetStunned(m_ParentEntity->GetObjectID(), eStateChangeType::PUSH, m_ParentEntity->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||
|
||||
// Set the mount Item ID so that we know what were handling
|
||||
possessorComponent->SetMountItemID(item->GetId());
|
||||
GameMessages::SendSetMountInventoryID(m_OwningEntity, item->GetId(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendSetMountInventoryID(m_ParentEntity, item->GetId(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
// Create entity to mount
|
||||
auto startRotation = m_OwningEntity->GetRotation();
|
||||
auto startRotation = m_ParentEntity->GetRotation();
|
||||
|
||||
EntityInfo info{};
|
||||
info.lot = item->GetLot();
|
||||
info.pos = m_OwningEntity->GetPosition();
|
||||
info.pos = m_ParentEntity->GetPosition();
|
||||
info.rot = startRotation;
|
||||
info.spawnerID = m_OwningEntity->GetObjectID();
|
||||
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||
|
||||
auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity);
|
||||
auto* mount = EntityManager::Instance()->CreateEntity(info, nullptr, m_ParentEntity);
|
||||
|
||||
// Check to see if the mount is a vehicle, if so, flip it
|
||||
auto* havokVehiclePhysicsComponent = mount->GetComponent<HavokVehiclePhysicsComponent>();
|
||||
@ -1010,29 +1010,29 @@ void InventoryComponent::HandlePossession(Item* item) {
|
||||
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
||||
if (possessableComponent) {
|
||||
possessableComponent->SetIsItemSpawned(true);
|
||||
possessableComponent->SetPossessor(m_OwningEntity->GetObjectID());
|
||||
possessableComponent->SetPossessor(m_ParentEntity->GetObjectID());
|
||||
// Possess it
|
||||
possessorComponent->SetPossessable(mount->GetObjectID());
|
||||
possessorComponent->SetPossessableType(possessableComponent->GetPossessionType());
|
||||
}
|
||||
|
||||
GameMessages::SendSetJetPackMode(m_OwningEntity, false);
|
||||
GameMessages::SendSetJetPackMode(m_ParentEntity, false);
|
||||
|
||||
// Make it go to the client
|
||||
EntityManager::Instance()->ConstructEntity(mount);
|
||||
// Update the possessor
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
// have to unlock the input so it vehicle can be driven
|
||||
if (havokVehiclePhysicsComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_OwningEntity->GetSystemAddress());
|
||||
GameMessages::SendMarkInventoryItemAsActive(m_OwningEntity->GetObjectID(), true, eUnequippableActiveType::MOUNT, item->GetId(), m_OwningEntity->GetSystemAddress());
|
||||
if (havokVehiclePhysicsComponent) GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_ParentEntity->GetSystemAddress());
|
||||
GameMessages::SendMarkInventoryItemAsActive(m_ParentEntity->GetObjectID(), true, eUnequippableActiveType::MOUNT, item->GetId(), m_ParentEntity->GetSystemAddress());
|
||||
}
|
||||
|
||||
void InventoryComponent::ApplyBuff(Item* item) const {
|
||||
const auto buffs = FindBuffs(item, true);
|
||||
|
||||
for (const auto buff : buffs) {
|
||||
SkillComponent::HandleUnmanaged(buff, m_OwningEntity->GetObjectID());
|
||||
SkillComponent::HandleUnmanaged(buff, m_ParentEntity->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1041,7 +1041,7 @@ void InventoryComponent::RemoveBuff(Item* item) const {
|
||||
const auto buffs = FindBuffs(item, false);
|
||||
|
||||
for (const auto buff : buffs) {
|
||||
SkillComponent::HandleUnCast(buff, m_OwningEntity->GetObjectID());
|
||||
SkillComponent::HandleUnCast(buff, m_ParentEntity->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1076,14 +1076,14 @@ void InventoryComponent::PopEquippedItems() {
|
||||
|
||||
m_Pushed.clear();
|
||||
|
||||
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
|
||||
auto* destroyableComponent = m_ParentEntity->GetComponent<DestroyableComponent>();
|
||||
|
||||
// Reset stats to full
|
||||
if (destroyableComponent) {
|
||||
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_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
m_Dirty = true;
|
||||
@ -1169,10 +1169,10 @@ void InventoryComponent::AddItemSkills(const LOT lot) {
|
||||
if (index != m_Skills.end()) {
|
||||
const auto old = index->second;
|
||||
|
||||
GameMessages::SendRemoveSkill(m_OwningEntity, old);
|
||||
GameMessages::SendRemoveSkill(m_ParentEntity, old);
|
||||
}
|
||||
|
||||
GameMessages::SendAddSkill(m_OwningEntity, skill, static_cast<int>(slot));
|
||||
GameMessages::SendAddSkill(m_ParentEntity, skill, static_cast<int>(slot));
|
||||
|
||||
m_Skills.insert_or_assign(slot, skill);
|
||||
}
|
||||
@ -1194,14 +1194,14 @@ void InventoryComponent::RemoveItemSkills(const LOT lot) {
|
||||
|
||||
const auto old = index->second;
|
||||
|
||||
GameMessages::SendRemoveSkill(m_OwningEntity, old);
|
||||
GameMessages::SendRemoveSkill(m_ParentEntity, old);
|
||||
|
||||
m_Skills.erase(slot);
|
||||
|
||||
if (slot == BehaviorSlot::Primary) {
|
||||
m_Skills.insert_or_assign(BehaviorSlot::Primary, 1);
|
||||
|
||||
GameMessages::SendAddSkill(m_OwningEntity, 1, static_cast<int>(BehaviorSlot::Primary));
|
||||
GameMessages::SendAddSkill(m_ParentEntity, 1, static_cast<int>(BehaviorSlot::Primary));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1227,7 +1227,7 @@ bool InventoryComponent::HasAnyPassive(const std::vector<eItemSetPassiveAbilityI
|
||||
}
|
||||
|
||||
void InventoryComponent::DespawnPet() {
|
||||
auto current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID());
|
||||
auto current = PetComponent::GetActivePet(m_ParentEntity->GetObjectID());
|
||||
|
||||
if (current != nullptr) {
|
||||
current->Deactivate();
|
||||
@ -1235,7 +1235,7 @@ void InventoryComponent::DespawnPet() {
|
||||
}
|
||||
|
||||
void InventoryComponent::SpawnPet(Item* item) {
|
||||
auto current = PetComponent::GetActivePet(m_OwningEntity->GetObjectID());
|
||||
auto current = PetComponent::GetActivePet(m_ParentEntity->GetObjectID());
|
||||
|
||||
if (current != nullptr) {
|
||||
current->Deactivate();
|
||||
@ -1246,18 +1246,18 @@ void InventoryComponent::SpawnPet(Item* item) {
|
||||
}
|
||||
|
||||
// First check if we can summon the pet. You need 1 imagination to do so.
|
||||
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
|
||||
auto* destroyableComponent = m_ParentEntity->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (Game::config->GetValue("pets_take_imagination") == "1" && destroyableComponent && destroyableComponent->GetImagination() <= 0) {
|
||||
GameMessages::SendUseItemRequirementsResponse(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet);
|
||||
GameMessages::SendUseItemRequirementsResponse(m_ParentEntity->GetObjectID(), m_ParentEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet);
|
||||
return;
|
||||
}
|
||||
|
||||
EntityInfo info{};
|
||||
info.lot = item->GetLot();
|
||||
info.pos = m_OwningEntity->GetPosition();
|
||||
info.pos = m_ParentEntity->GetPosition();
|
||||
info.rot = NiQuaternion::IDENTITY;
|
||||
info.spawnerID = m_OwningEntity->GetObjectID();
|
||||
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||
|
||||
auto* pet = EntityManager::Instance()->CreateEntity(info);
|
||||
|
||||
@ -1339,7 +1339,7 @@ std::vector<uint32_t> InventoryComponent::FindBuffs(Item* item, bool castOnEquip
|
||||
return entry.objectTemplate == static_cast<unsigned int>(item->GetLot());
|
||||
});
|
||||
|
||||
auto* missions = m_OwningEntity->GetComponent<MissionComponent>();
|
||||
auto* missions = m_ParentEntity->GetComponent<MissionComponent>();
|
||||
|
||||
for (const auto& result : results) {
|
||||
if (result.castOnType == 1) {
|
||||
@ -1376,7 +1376,7 @@ void InventoryComponent::SetNPCItems(const std::vector<LOT>& items) {
|
||||
UpdateSlot(info.equipLocation, { id, static_cast<LOT>(item), 1, slot++ }, true);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
InventoryComponent::~InventoryComponent() {
|
||||
|
@ -35,7 +35,7 @@ void LUPExhibitComponent::NextExhibit() {
|
||||
|
||||
m_Exhibit = m_Exhibits[m_ExhibitIndex];
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) {
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "CDRewardsTable.h"
|
||||
|
||||
LevelProgressionComponent::LevelProgressionComponent(Entity* parent) : Component(parent) {
|
||||
m_OwningEntity = parent;
|
||||
m_ParentEntity = parent;
|
||||
m_Level = 1;
|
||||
m_SpeedBase = 500.0f;
|
||||
m_CharacterVersion = eCharacterVersion::LIVE;
|
||||
@ -49,12 +49,12 @@ void LevelProgressionComponent::HandleLevelUp() {
|
||||
const auto& rewards = rewardsTable->GetByLevelID(m_Level);
|
||||
bool rewardingItem = rewards.size() > 0;
|
||||
|
||||
auto* inventoryComponent = m_OwningEntity->GetComponent<InventoryComponent>();
|
||||
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
auto* inventoryComponent = m_ParentEntity->GetComponent<InventoryComponent>();
|
||||
auto* controllablePhysicsComponent = m_ParentEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (!inventoryComponent || !controllablePhysicsComponent) return;
|
||||
// Tell the client we beginning to send level rewards.
|
||||
if (rewardingItem) GameMessages::NotifyLevelRewards(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress(), m_Level, rewardingItem);
|
||||
if (rewardingItem) GameMessages::NotifyLevelRewards(m_ParentEntity->GetObjectID(), m_ParentEntity->GetSystemAddress(), m_Level, rewardingItem);
|
||||
|
||||
for (auto* reward : rewards) {
|
||||
switch (reward->rewardType) {
|
||||
@ -79,11 +79,11 @@ void LevelProgressionComponent::HandleLevelUp() {
|
||||
}
|
||||
}
|
||||
// Tell the client we have finished sending level rewards.
|
||||
if (rewardingItem) GameMessages::NotifyLevelRewards(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress(), m_Level, !rewardingItem);
|
||||
if (rewardingItem) GameMessages::NotifyLevelRewards(m_ParentEntity->GetObjectID(), m_ParentEntity->GetSystemAddress(), m_Level, !rewardingItem);
|
||||
}
|
||||
|
||||
void LevelProgressionComponent::SetRetroactiveBaseSpeed(){
|
||||
if (m_Level >= 20) m_SpeedBase = 525.0f;
|
||||
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
auto* controllablePhysicsComponent = m_ParentEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
if (controllablePhysicsComponent) controllablePhysicsComponent->SetSpeedMultiplier(m_SpeedBase / 500.0f);
|
||||
}
|
||||
|
@ -103,9 +103,9 @@ void MissionComponent::AcceptMission(const uint32_t missionId, const bool skipCh
|
||||
if (missionId == 1728) {
|
||||
//Needs to send a mail
|
||||
|
||||
auto address = m_OwningEntity->GetSystemAddress();
|
||||
auto address = m_ParentEntity->GetSystemAddress();
|
||||
|
||||
Mail::HandleNotificationRequest(address, m_OwningEntity->GetObjectID());
|
||||
Mail::HandleNotificationRequest(address, m_ParentEntity->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,14 +109,14 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
|
||||
if (mission != nullptr) {
|
||||
if (specifiedMissionId <= 0) {
|
||||
// Handles the odd case where the offer object should not display the mission again
|
||||
if (!mission->IsComplete() && mission->GetClientInfo().offer_objectID == m_OwningEntity->GetLOT() && mission->GetClientInfo().target_objectID != m_OwningEntity->GetLOT() && mission->IsFetchMission()) {
|
||||
if (!mission->IsComplete() && mission->GetClientInfo().offer_objectID == m_ParentEntity->GetLOT() && mission->GetClientInfo().target_objectID != m_ParentEntity->GetLOT() && mission->IsFetchMission()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// We have the mission, if it is not complete, offer it
|
||||
if (mission->IsActive() || mission->IsReadyToComplete()) {
|
||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_ParentEntity->GetObjectID());
|
||||
|
||||
offered.push_back(missionId);
|
||||
|
||||
@ -162,7 +162,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
|
||||
const auto& iter = std::find(randomMissionPool.begin(), randomMissionPool.end(), specifiedMissionId);
|
||||
|
||||
if (iter != randomMissionPool.end() && MissionPrerequisites::CanAccept(specifiedMissionId, missionComponent->GetMissions())) {
|
||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), specifiedMissionId, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), specifiedMissionId, m_ParentEntity->GetObjectID());
|
||||
|
||||
return;
|
||||
}
|
||||
@ -184,7 +184,7 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
|
||||
continue;
|
||||
}
|
||||
|
||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), sample, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), sample, m_ParentEntity->GetObjectID());
|
||||
|
||||
canAcceptPool.clear();
|
||||
|
||||
@ -202,9 +202,9 @@ void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifi
|
||||
|
||||
const auto selected = canAcceptPool[GeneralUtils::GenerateRandomNumber<int>(0, canAcceptPool.size() - 1)];
|
||||
|
||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), selected, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), selected, m_ParentEntity->GetObjectID());
|
||||
} else if (std::find(offered.begin(), offered.end(), missionId) == offered.end() && offeredMission->GetOfferMission()) {
|
||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendOfferMission(entity->GetObjectID(), entity->GetSystemAddress(), missionId, m_ParentEntity->GetObjectID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,17 @@
|
||||
#include "Entity.h"
|
||||
|
||||
ModelBehaviorComponent::ModelBehaviorComponent(Entity* parent) : Component(parent) {
|
||||
m_OriginalPosition = m_OwningEntity->GetDefaultPosition();
|
||||
m_OriginalRotation = m_OwningEntity->GetDefaultRotation();
|
||||
m_OriginalPosition = m_ParentEntity->GetDefaultPosition();
|
||||
m_OriginalRotation = m_ParentEntity->GetDefaultRotation();
|
||||
|
||||
m_userModelID = m_OwningEntity->GetVarAs<LWOOBJID>(u"userModelID");
|
||||
m_userModelID = m_ParentEntity->GetVarAs<LWOOBJID>(u"userModelID");
|
||||
}
|
||||
|
||||
void ModelBehaviorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||
// ItemComponent Serialization. Pets do not get this serialization.
|
||||
if (!m_OwningEntity->HasComponent(eReplicaComponentType::PET)) {
|
||||
if (!m_ParentEntity->HasComponent(eReplicaComponentType::PET)) {
|
||||
outBitStream->Write1();
|
||||
outBitStream->Write<LWOOBJID>(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_OwningEntity->GetObjectID());
|
||||
outBitStream->Write<LWOOBJID>(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_ParentEntity->GetObjectID());
|
||||
outBitStream->Write<int>(0);
|
||||
outBitStream->Write0();
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) :
|
||||
|
||||
m_BaseCombatAI = nullptr;
|
||||
|
||||
m_BaseCombatAI = m_OwningEntity->GetComponent<BaseCombatAIComponent>();
|
||||
m_BaseCombatAI = m_ParentEntity->GetComponent<BaseCombatAIComponent>();
|
||||
|
||||
//Try and fix the insane values:
|
||||
if (m_Info.wanderRadius > 5.0f) m_Info.wanderRadius = m_Info.wanderRadius * 0.5f;
|
||||
if (m_Info.wanderRadius > 8.0f) m_Info.wanderRadius = 8.0f;
|
||||
if (m_Info.wanderSpeed > 0.5f) m_Info.wanderSpeed = m_Info.wanderSpeed * 0.5f;
|
||||
|
||||
m_BaseSpeed = GetBaseSpeed(m_OwningEntity->GetLOT());
|
||||
m_BaseSpeed = GetBaseSpeed(m_ParentEntity->GetLOT());
|
||||
|
||||
m_NextWaypoint = GetCurrentPosition();
|
||||
m_Acceleration = 0.4f;
|
||||
@ -149,7 +149,7 @@ nextAction:
|
||||
|
||||
SetVelocity(velocity);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
const MovementAIInfo& MovementAIComponent::GetInfo() const {
|
||||
@ -179,7 +179,7 @@ NiPoint3 MovementAIComponent::GetNextWaypoint() const {
|
||||
}
|
||||
|
||||
NiPoint3 MovementAIComponent::GetCurrentPosition() const {
|
||||
return m_OwningEntity->GetPosition();
|
||||
return m_ParentEntity->GetPosition();
|
||||
}
|
||||
|
||||
NiPoint3 MovementAIComponent::ApproximateLocation() const {
|
||||
@ -221,7 +221,7 @@ bool MovementAIComponent::Warp(const NiPoint3& point) {
|
||||
|
||||
SetPosition(destination);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -253,7 +253,7 @@ void MovementAIComponent::Stop() {
|
||||
|
||||
m_CurrentSpeed = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void MovementAIComponent::PullToPoint(const NiPoint3& point) {
|
||||
@ -322,7 +322,7 @@ foundComponent:
|
||||
}
|
||||
|
||||
void MovementAIComponent::SetPosition(const NiPoint3& value) {
|
||||
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
auto* controllablePhysicsComponent = m_ParentEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllablePhysicsComponent != nullptr) {
|
||||
controllablePhysicsComponent->SetPosition(value);
|
||||
@ -330,7 +330,7 @@ void MovementAIComponent::SetPosition(const NiPoint3& value) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>();
|
||||
auto* simplePhysicsComponent = m_ParentEntity->GetComponent<SimplePhysicsComponent>();
|
||||
|
||||
if (simplePhysicsComponent != nullptr) {
|
||||
simplePhysicsComponent->SetPosition(value);
|
||||
@ -342,7 +342,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
auto* controllablePhysicsComponent = m_ParentEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllablePhysicsComponent != nullptr) {
|
||||
controllablePhysicsComponent->SetRotation(value);
|
||||
@ -350,7 +350,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>();
|
||||
auto* simplePhysicsComponent = m_ParentEntity->GetComponent<SimplePhysicsComponent>();
|
||||
|
||||
if (simplePhysicsComponent != nullptr) {
|
||||
simplePhysicsComponent->SetRotation(value);
|
||||
@ -358,7 +358,7 @@ void MovementAIComponent::SetRotation(const NiQuaternion& value) {
|
||||
}
|
||||
|
||||
void MovementAIComponent::SetVelocity(const NiPoint3& value) {
|
||||
auto* controllablePhysicsComponent = m_OwningEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
auto* controllablePhysicsComponent = m_ParentEntity->GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllablePhysicsComponent != nullptr) {
|
||||
controllablePhysicsComponent->SetVelocity(value);
|
||||
@ -366,7 +366,7 @@ void MovementAIComponent::SetVelocity(const NiPoint3& value) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* simplePhysicsComponent = m_OwningEntity->GetComponent<SimplePhysicsComponent>();
|
||||
auto* simplePhysicsComponent = m_ParentEntity->GetComponent<SimplePhysicsComponent>();
|
||||
|
||||
if (simplePhysicsComponent != nullptr) {
|
||||
simplePhysicsComponent->SetVelocity(value);
|
||||
|
@ -57,7 +57,7 @@ void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIniti
|
||||
|
||||
MovingPlatformComponent::MovingPlatformComponent(Entity* parent, const std::string& pathName) : Component(parent) {
|
||||
m_MoverSubComponentType = eMoverSubComponentType::mover;
|
||||
m_MoverSubComponent = new MoverSubComponent(m_OwningEntity->GetDefaultPosition());
|
||||
m_MoverSubComponent = new MoverSubComponent(m_ParentEntity->GetDefaultPosition());
|
||||
m_PathName = GeneralUtils::ASCIIToUTF16(pathName);
|
||||
m_Path = dZoneManager::Instance()->GetZone()->GetPath(pathName);
|
||||
m_NoAutoStart = false;
|
||||
@ -133,7 +133,7 @@ void MovingPlatformComponent::SetMovementState(eMovementPlatformState value) {
|
||||
|
||||
subComponent->mState = value;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint) {
|
||||
@ -147,7 +147,7 @@ void MovingPlatformComponent::GotoWaypoint(uint32_t index, bool stopAtWaypoint)
|
||||
}
|
||||
|
||||
void MovingPlatformComponent::StartPathing() {
|
||||
//GameMessages::SendStartPathing(m_OwningEntity);
|
||||
//GameMessages::SendStartPathing(m_ParentEntity);
|
||||
m_PathingStopped = false;
|
||||
|
||||
auto* subComponent = static_cast<MoverSubComponent*>(m_MoverSubComponent);
|
||||
@ -167,14 +167,14 @@ void MovingPlatformComponent::StartPathing() {
|
||||
|
||||
targetPosition = nextWaypoint.position;
|
||||
} else {
|
||||
subComponent->mPosition = m_OwningEntity->GetPosition();
|
||||
subComponent->mPosition = m_ParentEntity->GetPosition();
|
||||
subComponent->mSpeed = 1.0f;
|
||||
subComponent->mWaitTime = 2.0f;
|
||||
|
||||
targetPosition = m_OwningEntity->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f);
|
||||
targetPosition = m_ParentEntity->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f);
|
||||
}
|
||||
|
||||
m_OwningEntity->AddCallbackTimer(subComponent->mWaitTime, [this] {
|
||||
m_ParentEntity->AddCallbackTimer(subComponent->mWaitTime, [this] {
|
||||
SetMovementState(eMovementPlatformState::Moving);
|
||||
});
|
||||
|
||||
@ -182,19 +182,19 @@ void MovingPlatformComponent::StartPathing() {
|
||||
|
||||
const auto travelNext = subComponent->mWaitTime + travelTime;
|
||||
|
||||
m_OwningEntity->AddCallbackTimer(travelTime, [subComponent, this] {
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
||||
script->OnWaypointReached(m_OwningEntity, subComponent->mNextWaypointIndex);
|
||||
m_ParentEntity->AddCallbackTimer(travelTime, [subComponent, this] {
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||
script->OnWaypointReached(m_ParentEntity, subComponent->mNextWaypointIndex);
|
||||
}
|
||||
});
|
||||
|
||||
m_OwningEntity->AddCallbackTimer(travelNext, [this] {
|
||||
m_ParentEntity->AddCallbackTimer(travelNext, [this] {
|
||||
ContinuePathing();
|
||||
});
|
||||
|
||||
//GameMessages::SendPlatformResync(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
//GameMessages::SendPlatformResync(m_ParentEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void MovingPlatformComponent::ContinuePathing() {
|
||||
@ -222,17 +222,17 @@ void MovingPlatformComponent::ContinuePathing() {
|
||||
|
||||
targetPosition = nextWaypoint.position;
|
||||
} else {
|
||||
subComponent->mPosition = m_OwningEntity->GetPosition();
|
||||
subComponent->mPosition = m_ParentEntity->GetPosition();
|
||||
subComponent->mSpeed = 1.0f;
|
||||
subComponent->mWaitTime = 2.0f;
|
||||
|
||||
targetPosition = m_OwningEntity->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f);
|
||||
targetPosition = m_ParentEntity->GetPosition() + NiPoint3(0.0f, 10.0f, 0.0f);
|
||||
|
||||
pathSize = 1;
|
||||
behavior = PathBehavior::Loop;
|
||||
}
|
||||
|
||||
if (m_OwningEntity->GetLOT() == 9483) {
|
||||
if (m_ParentEntity->GetLOT() == 9483) {
|
||||
behavior = PathBehavior::Bounce;
|
||||
} else {
|
||||
return;
|
||||
@ -242,7 +242,7 @@ void MovingPlatformComponent::ContinuePathing() {
|
||||
subComponent->mCurrentWaypointIndex = pathSize;
|
||||
switch (behavior) {
|
||||
case PathBehavior::Once:
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
return;
|
||||
|
||||
case PathBehavior::Bounce:
|
||||
@ -271,7 +271,7 @@ void MovingPlatformComponent::ContinuePathing() {
|
||||
subComponent->mCurrentWaypointIndex = 1;
|
||||
*/
|
||||
|
||||
//GameMessages::SendPlatformResync(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
//GameMessages::SendPlatformResync(m_ParentEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
if (subComponent->mCurrentWaypointIndex == subComponent->mDesiredWaypointIndex) {
|
||||
// TODO: Send event?
|
||||
@ -280,35 +280,35 @@ void MovingPlatformComponent::ContinuePathing() {
|
||||
return;
|
||||
}
|
||||
|
||||
m_OwningEntity->CancelCallbackTimers();
|
||||
m_ParentEntity->CancelCallbackTimers();
|
||||
|
||||
m_OwningEntity->AddCallbackTimer(subComponent->mWaitTime, [this] {
|
||||
m_ParentEntity->AddCallbackTimer(subComponent->mWaitTime, [this] {
|
||||
SetMovementState(eMovementPlatformState::Moving);
|
||||
});
|
||||
|
||||
auto travelTime = Vector3::Distance(targetPosition, subComponent->mPosition) / subComponent->mSpeed + 1.5;
|
||||
|
||||
if (m_OwningEntity->GetLOT() == 9483) {
|
||||
if (m_ParentEntity->GetLOT() == 9483) {
|
||||
travelTime += 20;
|
||||
}
|
||||
|
||||
const auto travelNext = subComponent->mWaitTime + travelTime;
|
||||
|
||||
m_OwningEntity->AddCallbackTimer(travelTime, [subComponent, this] {
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
||||
script->OnWaypointReached(m_OwningEntity, subComponent->mNextWaypointIndex);
|
||||
m_ParentEntity->AddCallbackTimer(travelTime, [subComponent, this] {
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||
script->OnWaypointReached(m_ParentEntity, subComponent->mNextWaypointIndex);
|
||||
}
|
||||
});
|
||||
|
||||
m_OwningEntity->AddCallbackTimer(travelNext, [this] {
|
||||
m_ParentEntity->AddCallbackTimer(travelNext, [this] {
|
||||
ContinuePathing();
|
||||
});
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void MovingPlatformComponent::StopPathing() {
|
||||
//m_OwningEntity->CancelCallbackTimers();
|
||||
//m_ParentEntity->CancelCallbackTimers();
|
||||
|
||||
auto* subComponent = static_cast<MoverSubComponent*>(m_MoverSubComponent);
|
||||
|
||||
@ -318,9 +318,9 @@ void MovingPlatformComponent::StopPathing() {
|
||||
subComponent->mDesiredWaypointIndex = -1;
|
||||
subComponent->mShouldStopAtDesiredWaypoint = false;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
//GameMessages::SendPlatformResync(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
//GameMessages::SendPlatformResync(m_ParentEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
void MovingPlatformComponent::SetSerialized(bool value) {
|
||||
@ -338,10 +338,10 @@ void MovingPlatformComponent::SetNoAutoStart(const bool value) {
|
||||
void MovingPlatformComponent::WarpToWaypoint(size_t index) {
|
||||
const auto& waypoint = m_Path->pathWaypoints[index];
|
||||
|
||||
m_OwningEntity->SetPosition(waypoint.position);
|
||||
m_OwningEntity->SetRotation(waypoint.rotation);
|
||||
m_ParentEntity->SetPosition(waypoint.position);
|
||||
m_ParentEntity->SetRotation(waypoint.rotation);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
size_t MovingPlatformComponent::GetLastWaypointIndex() const {
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include "CharacterComponent.h"
|
||||
|
||||
MultiZoneEntranceComponent::MultiZoneEntranceComponent(Entity* parent) : Component(parent) {
|
||||
m_OwningEntity = parent;
|
||||
std::string zoneString = GeneralUtils::UTF16ToWTF8(m_OwningEntity->GetVar<std::u16string>(u"MultiZoneIDs"));
|
||||
m_ParentEntity = parent;
|
||||
std::string zoneString = GeneralUtils::UTF16ToWTF8(m_ParentEntity->GetVar<std::u16string>(u"MultiZoneIDs"));
|
||||
std::stringstream ss(zoneString);
|
||||
for (int i; ss >> i;) {
|
||||
m_LUPWorlds.push_back(i);
|
||||
@ -21,11 +21,11 @@ void MultiZoneEntranceComponent::OnUse(Entity* originator) {
|
||||
if (!rocket) return;
|
||||
|
||||
// the LUP world menu is just the property menu, the client knows how to handle it
|
||||
GameMessages::SendPropertyEntranceBegin(m_OwningEntity->GetObjectID(), m_OwningEntity->GetSystemAddress());
|
||||
GameMessages::SendPropertyEntranceBegin(m_ParentEntity->GetObjectID(), m_ParentEntity->GetSystemAddress());
|
||||
}
|
||||
|
||||
void MultiZoneEntranceComponent::OnSelectWorld(Entity* originator, uint32_t index) {
|
||||
auto* rocketLaunchpadControlComponent = m_OwningEntity->GetComponent<RocketLaunchpadControlComponent>();
|
||||
auto* rocketLaunchpadControlComponent = m_ParentEntity->GetComponent<RocketLaunchpadControlComponent>();
|
||||
if (!rocketLaunchpadControlComponent) return;
|
||||
|
||||
rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0);
|
||||
|
@ -173,7 +173,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* movementAIComponent = m_OwningEntity->GetComponent<MovementAIComponent>();
|
||||
auto* movementAIComponent = m_ParentEntity->GetComponent<MovementAIComponent>();
|
||||
|
||||
if (movementAIComponent != nullptr) {
|
||||
movementAIComponent->Stop();
|
||||
@ -181,7 +181,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
|
||||
inventoryComponent->DespawnPet();
|
||||
|
||||
const auto& cached = buildCache.find(m_OwningEntity->GetLOT());
|
||||
const auto& cached = buildCache.find(m_ParentEntity->GetLOT());
|
||||
int32_t imaginationCost = 0;
|
||||
|
||||
std::string buildFile;
|
||||
@ -189,7 +189,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
if (cached == buildCache.end()) {
|
||||
auto query = CDClientDatabase::CreatePreppedStmt(
|
||||
"SELECT ValidPiecesLXF, PuzzleModelLot, Timelimit, NumValidPieces, imagCostPerBuild FROM TamingBuildPuzzles WHERE NPCLot = ?;");
|
||||
query.bind(1, (int)m_OwningEntity->GetLOT());
|
||||
query.bind(1, (int)m_ParentEntity->GetLOT());
|
||||
|
||||
auto result = query.execQuery();
|
||||
|
||||
@ -216,7 +216,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
if (data.timeLimit <= 0) data.timeLimit = 60;
|
||||
imaginationCost = data.imaginationCost;
|
||||
|
||||
buildCache[m_OwningEntity->GetLOT()] = data;
|
||||
buildCache[m_ParentEntity->GetLOT()] = data;
|
||||
|
||||
result.finalize();
|
||||
} else {
|
||||
@ -245,13 +245,13 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto petPosition = m_OwningEntity->GetPosition();
|
||||
auto petPosition = m_ParentEntity->GetPosition();
|
||||
|
||||
auto originatorPosition = originator->GetPosition();
|
||||
|
||||
m_OwningEntity->SetRotation(NiQuaternion::LookAt(petPosition, originatorPosition));
|
||||
m_ParentEntity->SetRotation(NiQuaternion::LookAt(petPosition, originatorPosition));
|
||||
|
||||
float interactionDistance = m_OwningEntity->GetVar<float>(u"interaction_distance");
|
||||
float interactionDistance = m_ParentEntity->GetVar<float>(u"interaction_distance");
|
||||
|
||||
if (interactionDistance <= 0) {
|
||||
interactionDistance = 15;
|
||||
@ -259,7 +259,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
|
||||
auto position = originatorPosition;
|
||||
|
||||
NiPoint3 forward = NiQuaternion::LookAt(m_OwningEntity->GetPosition(), originator->GetPosition()).GetForwardVector();
|
||||
NiPoint3 forward = NiQuaternion::LookAt(m_ParentEntity->GetPosition(), originator->GetPosition()).GetForwardVector();
|
||||
forward.y = 0;
|
||||
|
||||
if (dpWorld::Instance().IsLoaded()) {
|
||||
@ -268,7 +268,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(attempt);
|
||||
|
||||
while (std::abs(y - petPosition.y) > 4 && interactionDistance > 10) {
|
||||
const NiPoint3 forward = m_OwningEntity->GetRotation().GetForwardVector();
|
||||
const NiPoint3 forward = m_ParentEntity->GetRotation().GetForwardVector();
|
||||
|
||||
attempt = originatorPosition + forward * interactionDistance;
|
||||
|
||||
@ -287,7 +287,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
|
||||
GameMessages::SendNotifyPetTamingMinigame(
|
||||
originator->GetObjectID(),
|
||||
m_OwningEntity->GetObjectID(),
|
||||
m_ParentEntity->GetObjectID(),
|
||||
LWOOBJID_EMPTY,
|
||||
true,
|
||||
ePetTamingNotifyType::BEGIN,
|
||||
@ -298,7 +298,7 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
);
|
||||
|
||||
GameMessages::SendNotifyPetTamingMinigame(
|
||||
m_OwningEntity->GetObjectID(),
|
||||
m_ParentEntity->GetObjectID(),
|
||||
LWOOBJID_EMPTY,
|
||||
originator->GetObjectID(),
|
||||
true,
|
||||
@ -314,17 +314,17 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
m_Tamer = originator->GetObjectID();
|
||||
SetStatus(5);
|
||||
|
||||
currentActivities.insert_or_assign(m_Tamer, m_OwningEntity->GetObjectID());
|
||||
currentActivities.insert_or_assign(m_Tamer, m_ParentEntity->GetObjectID());
|
||||
|
||||
// Notify the start of a pet taming minigame
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
||||
script->OnNotifyPetTamingMinigame(m_OwningEntity, originator, ePetTamingNotifyType::BEGIN);
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||
script->OnNotifyPetTamingMinigame(m_ParentEntity, originator, ePetTamingNotifyType::BEGIN);
|
||||
}
|
||||
}
|
||||
|
||||
void PetComponent::Update(float deltaTime) {
|
||||
if (m_StartPosition == NiPoint3::ZERO) {
|
||||
m_StartPosition = m_OwningEntity->GetPosition();
|
||||
m_StartPosition = m_ParentEntity->GetPosition();
|
||||
}
|
||||
|
||||
if (m_Owner == LWOOBJID_EMPTY) {
|
||||
@ -344,7 +344,7 @@ void PetComponent::Update(float deltaTime) {
|
||||
|
||||
if (m_Timer <= 0) {
|
||||
Wander();
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
} else {
|
||||
m_Timer = 5;
|
||||
@ -357,13 +357,13 @@ void PetComponent::Update(float deltaTime) {
|
||||
auto* owner = GetOwner();
|
||||
|
||||
if (owner == nullptr) {
|
||||
m_OwningEntity->Kill();
|
||||
m_ParentEntity->Kill();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_MovementAI == nullptr) {
|
||||
m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
|
||||
m_MovementAI = m_ParentEntity->GetComponent<MovementAIComponent>();
|
||||
if (!m_MovementAI) return;
|
||||
}
|
||||
|
||||
@ -381,9 +381,9 @@ void PetComponent::Update(float deltaTime) {
|
||||
m_MovementAI->Stop();
|
||||
|
||||
if (m_TresureTime <= 0) {
|
||||
m_OwningEntity->SetOwnerOverride(m_Owner);
|
||||
m_ParentEntity->SetOwnerOverride(m_Owner);
|
||||
|
||||
tresure->Smash(m_OwningEntity->GetObjectID());
|
||||
tresure->Smash(m_ParentEntity->GetObjectID());
|
||||
|
||||
m_Interaction = LWOOBJID_EMPTY;
|
||||
|
||||
@ -429,7 +429,7 @@ void PetComponent::Update(float deltaTime) {
|
||||
float distance = Vector3::DistanceSquared(position, switchPosition);
|
||||
if (distance < 3 * 3) {
|
||||
m_Interaction = closestSwitch->GetParentEntity()->GetObjectID();
|
||||
closestSwitch->EntityEnter(m_OwningEntity);
|
||||
closestSwitch->EntityEnter(m_ParentEntity);
|
||||
} else if (distance < 20 * 20) {
|
||||
haltDistance = 1;
|
||||
|
||||
@ -442,7 +442,7 @@ void PetComponent::Update(float deltaTime) {
|
||||
|
||||
if (closestTresure != nullptr) {
|
||||
// Skeleton Dragon Pat special case for bone digging
|
||||
if (closestTresure->GetLOT() == 12192 && m_OwningEntity->GetLOT() != 13067) {
|
||||
if (closestTresure->GetLOT() == 12192 && m_ParentEntity->GetLOT() != 13067) {
|
||||
goto skipTresure;
|
||||
}
|
||||
|
||||
@ -483,7 +483,7 @@ void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& cached = buildCache.find(m_OwningEntity->GetLOT());
|
||||
const auto& cached = buildCache.find(m_ParentEntity->GetLOT());
|
||||
|
||||
if (cached == buildCache.end()) return;
|
||||
|
||||
@ -523,7 +523,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& cached = buildCache.find(m_OwningEntity->GetLOT());
|
||||
const auto& cached = buildCache.find(m_ParentEntity->GetLOT());
|
||||
|
||||
if (cached == buildCache.end()) {
|
||||
return;
|
||||
@ -546,7 +546,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
|
||||
GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress());
|
||||
|
||||
GameMessages::SendPetResponse(m_Tamer, m_OwningEntity->GetObjectID(), 0, 10, 0, tamer->GetSystemAddress());
|
||||
GameMessages::SendPetResponse(m_Tamer, m_ParentEntity->GetObjectID(), 0, 10, 0, tamer->GetSystemAddress());
|
||||
|
||||
auto* inventoryComponent = tamer->GetComponent<InventoryComponent>();
|
||||
|
||||
@ -564,13 +564,13 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
std::string petName = tamer->GetCharacter()->GetName();
|
||||
petName += "'s Pet";
|
||||
|
||||
GameMessages::SendAddPetToPlayer(m_Tamer, 0, GeneralUtils::UTF8ToUTF16(petName), petSubKey, m_OwningEntity->GetLOT(), tamer->GetSystemAddress());
|
||||
GameMessages::SendAddPetToPlayer(m_Tamer, 0, GeneralUtils::UTF8ToUTF16(petName), petSubKey, m_ParentEntity->GetLOT(), tamer->GetSystemAddress());
|
||||
|
||||
GameMessages::SendRegisterPetID(m_Tamer, m_OwningEntity->GetObjectID(), tamer->GetSystemAddress());
|
||||
GameMessages::SendRegisterPetID(m_Tamer, m_ParentEntity->GetObjectID(), tamer->GetSystemAddress());
|
||||
|
||||
GameMessages::SendRegisterPetDBID(m_Tamer, petSubKey, tamer->GetSystemAddress());
|
||||
|
||||
inventoryComponent->AddItem(m_OwningEntity->GetLOT(), 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey);
|
||||
inventoryComponent->AddItem(m_ParentEntity->GetLOT(), 1, eLootSourceType::ACTIVITY, eInventoryType::MODELS, {}, LWOOBJID_EMPTY, true, false, petSubKey);
|
||||
auto* item = inventoryComponent->FindItemBySubKey(petSubKey, MODELS);
|
||||
|
||||
if (item == nullptr) {
|
||||
@ -579,7 +579,7 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
|
||||
DatabasePet databasePet{};
|
||||
|
||||
databasePet.lot = m_OwningEntity->GetLOT();
|
||||
databasePet.lot = m_ParentEntity->GetLOT();
|
||||
databasePet.moderationState = 1;
|
||||
databasePet.name = petName;
|
||||
|
||||
@ -602,14 +602,14 @@ void PetComponent::NotifyTamingBuildSuccess(NiPoint3 position) {
|
||||
);
|
||||
|
||||
// Triggers the catch a pet missions
|
||||
if (petFlags.find(m_OwningEntity->GetLOT()) != petFlags.end()) {
|
||||
tamer->GetCharacter()->SetPlayerFlag(petFlags.at(m_OwningEntity->GetLOT()), true);
|
||||
if (petFlags.find(m_ParentEntity->GetLOT()) != petFlags.end()) {
|
||||
tamer->GetCharacter()->SetPlayerFlag(petFlags.at(m_ParentEntity->GetLOT()), true);
|
||||
}
|
||||
|
||||
auto* missionComponent = tamer->GetComponent<MissionComponent>();
|
||||
|
||||
if (missionComponent != nullptr) {
|
||||
missionComponent->Progress(eMissionTaskType::PET_TAMING, m_OwningEntity->GetLOT());
|
||||
missionComponent->Progress(eMissionTaskType::PET_TAMING, m_ParentEntity->GetLOT());
|
||||
}
|
||||
|
||||
SetStatus(1);
|
||||
@ -660,18 +660,18 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
||||
//Save our pet's new name to the db:
|
||||
SetPetNameForModeration(GeneralUtils::UTF16ToWTF8(name));
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
std::u16string u16name = GeneralUtils::UTF8ToUTF16(m_Name);
|
||||
std::u16string u16ownerName = GeneralUtils::UTF8ToUTF16(m_OwnerName);
|
||||
GameMessages::SendSetPetName(m_Tamer, u16name, m_DatabaseId, tamer->GetSystemAddress());
|
||||
GameMessages::SendSetPetName(m_Tamer, u16name, LWOOBJID_EMPTY, tamer->GetSystemAddress());
|
||||
GameMessages::SendPetNameChanged(m_OwningEntity->GetObjectID(), m_ModerationStatus, u16name, u16ownerName, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendPetNameChanged(m_ParentEntity->GetObjectID(), m_ModerationStatus, u16name, u16ownerName, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendSetPetNameModerated(m_Tamer, m_DatabaseId, m_ModerationStatus, tamer->GetSystemAddress());
|
||||
|
||||
GameMessages::SendNotifyPetTamingMinigame(
|
||||
m_Tamer,
|
||||
m_OwningEntity->GetObjectID(),
|
||||
m_ParentEntity->GetObjectID(),
|
||||
m_Tamer,
|
||||
false,
|
||||
ePetTamingNotifyType::SUCCESS,
|
||||
@ -681,7 +681,7 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
||||
UNASSIGNED_SYSTEM_ADDRESS
|
||||
);
|
||||
|
||||
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||
|
||||
auto* modelEntity = EntityManager::Instance()->GetEntity(m_ModelId);
|
||||
|
||||
@ -694,8 +694,8 @@ void PetComponent::RequestSetPetName(std::u16string name) {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
|
||||
// Notify the end of a pet taming minigame
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
||||
script->OnNotifyPetTamingMinigame(m_OwningEntity, tamer, ePetTamingNotifyType::SUCCESS);
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||
script->OnNotifyPetTamingMinigame(m_ParentEntity, tamer, ePetTamingNotifyType::SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -712,7 +712,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
||||
|
||||
GameMessages::SendNotifyPetTamingMinigame(
|
||||
m_Tamer,
|
||||
m_OwningEntity->GetObjectID(),
|
||||
m_ParentEntity->GetObjectID(),
|
||||
m_Tamer,
|
||||
false,
|
||||
ePetTamingNotifyType::QUIT,
|
||||
@ -724,7 +724,7 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
||||
|
||||
GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress());
|
||||
|
||||
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||
|
||||
currentActivities.erase(m_Tamer);
|
||||
|
||||
@ -732,16 +732,16 @@ void PetComponent::ClientExitTamingMinigame(bool voluntaryExit) {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
m_Timer = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
// Notify the end of a pet taming minigame
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
||||
script->OnNotifyPetTamingMinigame(m_OwningEntity, tamer, ePetTamingNotifyType::QUIT);
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||
script->OnNotifyPetTamingMinigame(m_ParentEntity, tamer, ePetTamingNotifyType::QUIT);
|
||||
}
|
||||
}
|
||||
|
||||
void PetComponent::StartTimer() {
|
||||
const auto& cached = buildCache.find(m_OwningEntity->GetLOT());
|
||||
const auto& cached = buildCache.find(m_ParentEntity->GetLOT());
|
||||
|
||||
if (cached == buildCache.end()) {
|
||||
return;
|
||||
@ -763,7 +763,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
||||
|
||||
GameMessages::SendNotifyPetTamingMinigame(
|
||||
m_Tamer,
|
||||
m_OwningEntity->GetObjectID(),
|
||||
m_ParentEntity->GetObjectID(),
|
||||
m_Tamer,
|
||||
false,
|
||||
ePetTamingNotifyType::FAILED,
|
||||
@ -775,7 +775,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
||||
|
||||
GameMessages::SendNotifyTamingModelLoadedOnServer(m_Tamer, tamer->GetSystemAddress());
|
||||
|
||||
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendTerminateInteraction(m_Tamer, eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||
|
||||
currentActivities.erase(m_Tamer);
|
||||
|
||||
@ -783,16 +783,16 @@ void PetComponent::ClientFailTamingMinigame() {
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
m_Timer = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
// Notify the end of a pet taming minigame
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
||||
script->OnNotifyPetTamingMinigame(m_OwningEntity, tamer, ePetTamingNotifyType::FAILED);
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||
script->OnNotifyPetTamingMinigame(m_ParentEntity, tamer, ePetTamingNotifyType::FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
void PetComponent::Wander() {
|
||||
if (!m_MovementAI) m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
|
||||
if (!m_MovementAI) m_MovementAI = m_ParentEntity->GetComponent<MovementAIComponent>();
|
||||
|
||||
if (m_MovementAI == nullptr || !m_MovementAI->AtFinalWaypoint()) {
|
||||
return;
|
||||
@ -882,18 +882,18 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) {
|
||||
|
||||
GameMessages::SendMarkInventoryItemAsActive(m_Owner, true, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress());
|
||||
|
||||
activePets[m_Owner] = m_OwningEntity->GetObjectID();
|
||||
activePets[m_Owner] = m_ParentEntity->GetObjectID();
|
||||
|
||||
m_Timer = 3;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
owner->GetCharacter()->SetPlayerFlag(ePlayerFlag::FIRST_MANUAL_PET_HIBERNATE, true);
|
||||
|
||||
if (registerPet) {
|
||||
GameMessages::SendAddPetToPlayer(m_Owner, 0, GeneralUtils::UTF8ToUTF16(m_Name), m_DatabaseId, m_OwningEntity->GetLOT(), owner->GetSystemAddress());
|
||||
GameMessages::SendAddPetToPlayer(m_Owner, 0, GeneralUtils::UTF8ToUTF16(m_Name), m_DatabaseId, m_ParentEntity->GetLOT(), owner->GetSystemAddress());
|
||||
|
||||
GameMessages::SendRegisterPetID(m_Owner, m_OwningEntity->GetObjectID(), owner->GetSystemAddress());
|
||||
GameMessages::SendRegisterPetID(m_Owner, m_ParentEntity->GetObjectID(), owner->GetSystemAddress());
|
||||
|
||||
GameMessages::SendRegisterPetDBID(m_Owner, m_DatabaseId, owner->GetSystemAddress());
|
||||
}
|
||||
@ -920,7 +920,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
|
||||
if (!fromTaming) playerDestroyableComponent->Imagine(-1);
|
||||
|
||||
// Set this to a variable so when this is called back from the player the timer doesn't fire off.
|
||||
m_OwningEntity->AddCallbackTimer(imaginationDrainRate, [playerDestroyableComponent, this, item]() {
|
||||
m_ParentEntity->AddCallbackTimer(imaginationDrainRate, [playerDestroyableComponent, this, item]() {
|
||||
if (!playerDestroyableComponent) {
|
||||
Game::logger->Log("PetComponent", "No petComponent and/or no playerDestroyableComponent");
|
||||
return;
|
||||
@ -940,13 +940,13 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) {
|
||||
}
|
||||
|
||||
void PetComponent::Deactivate() {
|
||||
GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), -1, u"despawn", "", LWOOBJID_EMPTY, 1, 1, true);
|
||||
GameMessages::SendPlayFXEffect(m_ParentEntity->GetObjectID(), -1, u"despawn", "", LWOOBJID_EMPTY, 1, 1, true);
|
||||
|
||||
GameMessages::SendMarkInventoryItemAsActive(m_Owner, false, eUnequippableActiveType::PET, m_ItemId, GetOwner()->GetSystemAddress());
|
||||
|
||||
activePets.erase(m_Owner);
|
||||
|
||||
m_OwningEntity->Kill();
|
||||
m_ParentEntity->Kill();
|
||||
|
||||
auto* owner = GetOwner();
|
||||
|
||||
@ -986,7 +986,7 @@ void PetComponent::Command(NiPoint3 position, LWOOBJID source, int32_t commandTy
|
||||
|
||||
if (commandType == 1) {
|
||||
// Emotes
|
||||
GameMessages::SendPlayEmote(m_OwningEntity->GetObjectID(), typeId, owner->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendPlayEmote(m_ParentEntity->GetObjectID(), typeId, owner->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
} else if (commandType == 3) {
|
||||
// Follow me, ???
|
||||
} else if (commandType == 6) {
|
||||
@ -1075,7 +1075,7 @@ PetComponent* PetComponent::GetActivePet(LWOOBJID owner) {
|
||||
}
|
||||
|
||||
Entity* PetComponent::GetParentEntity() const {
|
||||
return m_OwningEntity;
|
||||
return m_ParentEntity;
|
||||
}
|
||||
|
||||
PetComponent::~PetComponent() {
|
||||
|
@ -28,9 +28,9 @@
|
||||
#include "dpShapeSphere.h"
|
||||
|
||||
PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(parent) {
|
||||
m_Position = m_OwningEntity->GetDefaultPosition();
|
||||
m_Rotation = m_OwningEntity->GetDefaultRotation();
|
||||
m_Scale = m_OwningEntity->GetDefaultScale();
|
||||
m_Position = m_ParentEntity->GetDefaultPosition();
|
||||
m_Rotation = m_ParentEntity->GetDefaultRotation();
|
||||
m_Scale = m_ParentEntity->GetDefaultScale();
|
||||
m_dpEntity = nullptr;
|
||||
|
||||
m_EffectInfoDirty = false;
|
||||
@ -47,17 +47,17 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
||||
m_IsDirectional = false;
|
||||
m_Direction = NiPoint3(); // * m_DirectionalMultiplier
|
||||
|
||||
if (m_OwningEntity->GetVar<bool>(u"create_physics")) {
|
||||
if (m_ParentEntity->GetVar<bool>(u"create_physics")) {
|
||||
CreatePhysics();
|
||||
}
|
||||
|
||||
if (m_OwningEntity->GetVar<bool>(u"respawnVol")) {
|
||||
if (m_ParentEntity->GetVar<bool>(u"respawnVol")) {
|
||||
m_IsRespawnVolume = true;
|
||||
}
|
||||
|
||||
if (m_IsRespawnVolume) {
|
||||
{
|
||||
auto respawnString = std::stringstream(m_OwningEntity->GetVarAsString(u"rspPos"));
|
||||
auto respawnString = std::stringstream(m_ParentEntity->GetVarAsString(u"rspPos"));
|
||||
|
||||
std::string segment;
|
||||
std::vector<std::string> seglist;
|
||||
@ -70,7 +70,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
||||
}
|
||||
|
||||
{
|
||||
auto respawnString = std::stringstream(m_OwningEntity->GetVarAsString(u"rspRot"));
|
||||
auto respawnString = std::stringstream(m_ParentEntity->GetVarAsString(u"rspRot"));
|
||||
|
||||
std::string segment;
|
||||
std::vector<std::string> seglist;
|
||||
@ -84,7 +84,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
||||
}
|
||||
|
||||
// HF - RespawnPoints. Legacy respawn entity.
|
||||
if (m_OwningEntity->GetLOT() == 4945) {
|
||||
if (m_ParentEntity->GetLOT() == 4945) {
|
||||
m_IsRespawnVolume = true;
|
||||
m_RespawnPos = m_Position;
|
||||
m_RespawnRot = m_Rotation;
|
||||
@ -133,7 +133,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
||||
}
|
||||
}
|
||||
|
||||
if (m_OwningEntity->GetLOT() == 4945) // HF - RespawnPoints
|
||||
if (m_ParentEntity->GetLOT() == 4945) // HF - RespawnPoints
|
||||
{
|
||||
m_IsRespawnVolume = true;
|
||||
m_RespawnPos = m_Position;
|
||||
@ -145,7 +145,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
||||
|
||||
if (!m_HasCreatedPhysics) {
|
||||
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||
auto componentID = compRegistryTable->GetByIDAndType(m_OwningEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
||||
auto componentID = compRegistryTable->GetByIDAndType(m_ParentEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
||||
|
||||
CDPhysicsComponentTable* physComp = CDClientManager::Instance().GetTable<CDPhysicsComponentTable>();
|
||||
|
||||
@ -156,7 +156,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
||||
|
||||
//temp test
|
||||
if (info->physicsAsset == "miscellaneous\\misc_phys_10x1x5.hkx") {
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 10.0f, 5.0f, 1.0f);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 10.0f, 5.0f, 1.0f);
|
||||
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
@ -167,7 +167,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
||||
// Move this down by 13.521004 units so it is still effectively at the same height as before
|
||||
m_Position = m_Position - NiPoint3::UNIT_Y * 13.521004f;
|
||||
// TODO Fix physics simulation to do simulation at high velocities due to bullet through paper problem...
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f);
|
||||
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
@ -175,49 +175,49 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
||||
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
} else if (info->physicsAsset == "env\\trigger_wall_tall.hkx") {
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 10.0f, 25.0f, 1.0f);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 10.0f, 25.0f, 1.0f);
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_dpEntity->SetPosition(m_Position);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
} else if (info->physicsAsset == "env\\env_gen_placeholderphysics.hkx") {
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 20.0f, 20.0f, 20.0f);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 20.0f, 20.0f, 20.0f);
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_dpEntity->SetPosition(m_Position);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
} else if (info->physicsAsset == "env\\POI_trigger_wall.hkx") {
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 1.0f, 12.5f, 20.0f); // Not sure what the real size is
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1.0f, 12.5f, 20.0f); // Not sure what the real size is
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_dpEntity->SetPosition(m_Position);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
} else if (info->physicsAsset == "env\\NG_NinjaGo\\env_ng_gen_gate_chamber_puzzle_ceiling_tile_falling_phantom.hkx") {
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 18.0f, 5.0f, 15.0f);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 18.0f, 5.0f, 15.0f);
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 7.5f);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
} else if (info->physicsAsset == "env\\NG_NinjaGo\\ng_flamejet_brick_phantom.HKX") {
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 1.0f, 1.0f, 12.0f);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1.0f, 1.0f, 12.0f);
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 6.0f);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
} else if (info->physicsAsset == "env\\Ring_Trigger.hkx") {
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 6.0f, 6.0f, 6.0f);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 6.0f, 6.0f, 6.0f);
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_dpEntity->SetPosition(m_Position);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
} else if (info->physicsAsset == "env\\vfx_propertyImaginationBall.hkx") {
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 4.5f);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 4.5f);
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_dpEntity->SetPosition(m_Position);
|
||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||
} else if (info->physicsAsset == "env\\env_won_fv_gas-blocking-volume.hkx"){
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true);
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_Position.y -= (111.467964f * m_Scale) / 2;
|
||||
@ -227,7 +227,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
||||
//Game::logger->Log("PhantomPhysicsComponent", "This one is supposed to have %s", info->physicsAsset.c_str());
|
||||
|
||||
//add fallback cube:
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), 2.0f, 2.0f, 2.0f);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 2.0f, 2.0f, 2.0f);
|
||||
m_dpEntity->SetScale(m_Scale);
|
||||
m_dpEntity->SetRotation(m_Rotation);
|
||||
m_dpEntity->SetPosition(m_Position);
|
||||
@ -255,14 +255,14 @@ void PhantomPhysicsComponent::CreatePhysics() {
|
||||
float width = 0.0f; //aka "radius"
|
||||
float height = 0.0f;
|
||||
|
||||
if (m_OwningEntity->HasVar(u"primitiveModelType")) {
|
||||
type = m_OwningEntity->GetVar<int32_t>(u"primitiveModelType");
|
||||
x = m_OwningEntity->GetVar<float>(u"primitiveModelValueX");
|
||||
y = m_OwningEntity->GetVar<float>(u"primitiveModelValueY");
|
||||
z = m_OwningEntity->GetVar<float>(u"primitiveModelValueZ");
|
||||
if (m_ParentEntity->HasVar(u"primitiveModelType")) {
|
||||
type = m_ParentEntity->GetVar<int32_t>(u"primitiveModelType");
|
||||
x = m_ParentEntity->GetVar<float>(u"primitiveModelValueX");
|
||||
y = m_ParentEntity->GetVar<float>(u"primitiveModelValueY");
|
||||
z = m_ParentEntity->GetVar<float>(u"primitiveModelValueZ");
|
||||
} else {
|
||||
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||
auto componentID = compRegistryTable->GetByIDAndType(m_OwningEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
||||
auto componentID = compRegistryTable->GetByIDAndType(m_ParentEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
||||
|
||||
CDPhysicsComponentTable* physComp = CDClientManager::Instance().GetTable<CDPhysicsComponentTable>();
|
||||
|
||||
@ -292,7 +292,7 @@ void PhantomPhysicsComponent::CreatePhysics() {
|
||||
boxSize = NiPoint3(width, height, width);
|
||||
}
|
||||
|
||||
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), boxSize);
|
||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), boxSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -358,7 +358,7 @@ void PhantomPhysicsComponent::Update(float deltaTime) {
|
||||
|
||||
//Process enter events
|
||||
for (auto en : m_dpEntity->GetNewObjects()) {
|
||||
m_OwningEntity->OnCollisionPhantom(en->GetObjectID());
|
||||
m_ParentEntity->OnCollisionPhantom(en->GetObjectID());
|
||||
|
||||
//If we are a respawn volume, inform the client:
|
||||
if (m_IsRespawnVolume) {
|
||||
@ -374,7 +374,7 @@ void PhantomPhysicsComponent::Update(float deltaTime) {
|
||||
|
||||
//Process exit events
|
||||
for (auto en : m_dpEntity->GetRemovedObjects()) {
|
||||
m_OwningEntity->OnCollisionLeavePhantom(en->GetObjectID());
|
||||
m_ParentEntity->OnCollisionLeavePhantom(en->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ void PhantomPhysicsComponent::SetDirection(const NiPoint3& pos) {
|
||||
void PhantomPhysicsComponent::SpawnVertices() {
|
||||
if (!m_dpEntity) return;
|
||||
|
||||
std::cout << m_OwningEntity->GetObjectID() << std::endl;
|
||||
std::cout << m_ParentEntity->GetObjectID() << std::endl;
|
||||
auto box = static_cast<dpShapeBox*>(m_dpEntity->GetShape());
|
||||
for (auto vert : box->GetVertices()) {
|
||||
std::cout << vert.x << ", " << vert.y << ", " << vert.z << std::endl;
|
||||
@ -400,7 +400,7 @@ void PhantomPhysicsComponent::SpawnVertices() {
|
||||
info.lot = 33;
|
||||
info.pos = vert;
|
||||
info.spawner = nullptr;
|
||||
info.spawnerID = m_OwningEntity->GetObjectID();
|
||||
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||
info.spawnerNodeID = 0;
|
||||
|
||||
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "PlayerForcedMovementComponent.h"
|
||||
|
||||
PlayerForcedMovementComponent::PlayerForcedMovementComponent(Entity* parent) : Component(parent) {
|
||||
m_OwningEntity = parent;
|
||||
m_ParentEntity = parent;
|
||||
}
|
||||
|
||||
PlayerForcedMovementComponent::~PlayerForcedMovementComponent() {}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId) : Component(parent) {
|
||||
m_Possessor = LWOOBJID_EMPTY;
|
||||
CDItemComponent item = Inventory::FindItemComponent(m_OwningEntity->GetLOT());
|
||||
CDItemComponent item = Inventory::FindItemComponent(m_ParentEntity->GetLOT());
|
||||
m_AnimationFlag = static_cast<eAnimationFlags>(item.animationFlag);
|
||||
|
||||
// Get the possession Type from the CDClient
|
||||
@ -44,12 +44,12 @@ void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn
|
||||
|
||||
void PossessableComponent::Dismount() {
|
||||
SetPossessor(LWOOBJID_EMPTY);
|
||||
if (m_ItemSpawned) m_OwningEntity->ScheduleKillAfterUpdate();
|
||||
if (m_ItemSpawned) m_ParentEntity->ScheduleKillAfterUpdate();
|
||||
}
|
||||
|
||||
void PossessableComponent::OnUse(Entity* originator) {
|
||||
auto* possessor = originator->GetComponent<PossessorComponent>();
|
||||
if (possessor) {
|
||||
possessor->Mount(m_OwningEntity);
|
||||
possessor->Mount(m_ParentEntity);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ PossessorComponent::~PossessorComponent() {
|
||||
auto* possessable = mount->GetComponent<PossessableComponent>();
|
||||
if (possessable) {
|
||||
if (possessable->GetIsItemSpawned()) {
|
||||
GameMessages::SendMarkInventoryItemAsActive(m_OwningEntity->GetObjectID(), false, eUnequippableActiveType::MOUNT, GetMountItemID(), m_OwningEntity->GetSystemAddress());
|
||||
GameMessages::SendMarkInventoryItemAsActive(m_ParentEntity->GetObjectID(), false, eUnequippableActiveType::MOUNT, GetMountItemID(), m_ParentEntity->GetSystemAddress());
|
||||
}
|
||||
possessable->Dismount();
|
||||
}
|
||||
@ -42,23 +42,23 @@ void PossessorComponent::Mount(Entity* mount) {
|
||||
// Don't do anything if we are busy dismounting
|
||||
if (GetIsDismounting() || !mount) return;
|
||||
|
||||
GameMessages::SendSetMountInventoryID(m_OwningEntity, mount->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendSetMountInventoryID(m_ParentEntity, mount->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
auto* possessableComponent = mount->GetComponent<PossessableComponent>();
|
||||
if (possessableComponent) {
|
||||
possessableComponent->SetPossessor(m_OwningEntity->GetObjectID());
|
||||
possessableComponent->SetPossessor(m_ParentEntity->GetObjectID());
|
||||
SetPossessable(mount->GetObjectID());
|
||||
SetPossessableType(possessableComponent->GetPossessionType());
|
||||
}
|
||||
|
||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
||||
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||
if (characterComponent) characterComponent->SetIsRacing(true);
|
||||
|
||||
// GM's to send
|
||||
GameMessages::SendSetJetPackMode(m_OwningEntity, false);
|
||||
GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_OwningEntity->GetSystemAddress());
|
||||
GameMessages::SendSetStunned(m_OwningEntity->GetObjectID(), eStateChangeType::PUSH, m_OwningEntity->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||
GameMessages::SendSetJetPackMode(m_ParentEntity, false);
|
||||
GameMessages::SendVehicleUnlockInput(mount->GetObjectID(), false, m_ParentEntity->GetSystemAddress());
|
||||
GameMessages::SendSetStunned(m_ParentEntity->GetObjectID(), eStateChangeType::PUSH, m_ParentEntity->GetSystemAddress(), LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
EntityManager::Instance()->SerializeEntity(mount);
|
||||
}
|
||||
|
||||
@ -73,12 +73,12 @@ void PossessorComponent::Dismount(Entity* mount, bool forceDismount) {
|
||||
possessableComponent->SetPossessor(LWOOBJID_EMPTY);
|
||||
if (forceDismount) possessableComponent->ForceDepossess();
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
EntityManager::Instance()->SerializeEntity(mount);
|
||||
|
||||
auto* characterComponent = m_OwningEntity->GetComponent<CharacterComponent>();
|
||||
auto* characterComponent = m_ParentEntity->GetComponent<CharacterComponent>();
|
||||
if (characterComponent) characterComponent->SetIsRacing(false);
|
||||
}
|
||||
// Make sure we don't have wacky controls
|
||||
GameMessages::SendSetPlayerControlScheme(m_OwningEntity, eControlScheme::SCHEME_A);
|
||||
GameMessages::SendSetPlayerControlScheme(m_ParentEntity, eControlScheme::SCHEME_A);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "eObjectBits.h"
|
||||
#include "eGameMasterLevel.h"
|
||||
|
||||
PropertyEntranceComponent::PropertyEntranceComponent(uint32_t componentID, Entity* parent) : Component(parent) {
|
||||
PropertyEntranceComponent::PropertyEntranceComponent(Entity* parent, uint32_t componentID) : Component(parent) {
|
||||
this->propertyQueries = {};
|
||||
|
||||
auto table = CDClientManager::Instance().GetTable<CDPropertyEntranceComponentTable>();
|
||||
@ -32,7 +32,7 @@ void PropertyEntranceComponent::OnUse(Entity* entity) {
|
||||
auto* rocket = entity->GetComponent<CharacterComponent>()->RocketEquip(entity);
|
||||
if (!rocket) return;
|
||||
|
||||
GameMessages::SendPropertyEntranceBegin(m_OwningEntity->GetObjectID(), entity->GetSystemAddress());
|
||||
GameMessages::SendPropertyEntranceBegin(m_ParentEntity->GetObjectID(), entity->GetSystemAddress());
|
||||
|
||||
AMFArrayValue args;
|
||||
|
||||
@ -63,7 +63,7 @@ void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index,
|
||||
cloneId = query[index].CloneId;
|
||||
}
|
||||
|
||||
auto* launcher = m_OwningEntity->GetComponent<RocketLaunchpadControlComponent>();
|
||||
auto* launcher = m_ParentEntity->GetComponent<RocketLaunchpadControlComponent>();
|
||||
|
||||
if (launcher == nullptr) {
|
||||
return;
|
||||
@ -330,5 +330,5 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
||||
delete propertiesLeft;
|
||||
propertiesLeft = nullptr;
|
||||
|
||||
GameMessages::SendPropertySelectQuery(m_OwningEntity->GetObjectID(), startIndex, numberOfProperties - (startIndex + numResults) > 0, character->GetPropertyCloneID(), false, true, entries, sysAddr);
|
||||
GameMessages::SendPropertySelectQuery(m_ParentEntity->GetObjectID(), startIndex, numberOfProperties - (startIndex + numResults) > 0, character->GetPropertyCloneID(), false, true, entries, sysAddr);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
class PropertyEntranceComponent : public Component {
|
||||
public:
|
||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PROPERTY_ENTRANCE;
|
||||
explicit PropertyEntranceComponent(uint32_t componentID, Entity* parent);
|
||||
explicit PropertyEntranceComponent(Entity* parent, uint32_t componentID);
|
||||
|
||||
/**
|
||||
* Handles an OnUse request for some other entity, rendering the property browse menu
|
||||
|
@ -206,7 +206,7 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId) {
|
||||
std::string name = zone->GetZoneName();
|
||||
std::string description = "";
|
||||
|
||||
auto prop_path = zone->GetPath(m_OwningEntity->GetVarAsString(u"propertyName"));
|
||||
auto prop_path = zone->GetPath(m_ParentEntity->GetVarAsString(u"propertyName"));
|
||||
|
||||
if (prop_path){
|
||||
if (!prop_path->property.displayName.empty()) name = prop_path->property.displayName;
|
||||
@ -395,7 +395,7 @@ void PropertyManagementComponent::UpdateModelPosition(const LWOOBJID id, const N
|
||||
|
||||
models.insert_or_assign(model->GetObjectID(), spawnerId);
|
||||
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), position, m_OwningEntity->GetObjectID(), 14, originalRotation);
|
||||
GameMessages::SendPlaceModelResponse(entity->GetObjectID(), entity->GetSystemAddress(), position, m_ParentEntity->GetObjectID(), 14, originalRotation);
|
||||
|
||||
GameMessages::SendUGCEquipPreCreateBasedOnEditMode(entity->GetObjectID(), entity->GetSystemAddress(), 0, spawnerId);
|
||||
|
||||
@ -783,7 +783,7 @@ PropertyManagementComponent* PropertyManagementComponent::Instance() {
|
||||
|
||||
void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr, LWOOBJID author) {
|
||||
if (author == LWOOBJID_EMPTY) {
|
||||
author = m_OwningEntity->GetObjectID();
|
||||
author = m_ParentEntity->GetObjectID();
|
||||
}
|
||||
|
||||
const auto& worldId = dZoneManager::Instance()->GetZone()->GetZoneID();
|
||||
@ -861,7 +861,7 @@ void PropertyManagementComponent::OnQueryPropertyData(Entity* originator, const
|
||||
|
||||
void PropertyManagementComponent::OnUse(Entity* originator) {
|
||||
OnQueryPropertyData(originator, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendOpenPropertyManagment(m_OwningEntity->GetObjectID(), originator->GetSystemAddress());
|
||||
GameMessages::SendOpenPropertyManagment(m_ParentEntity->GetObjectID(), originator->GetSystemAddress());
|
||||
}
|
||||
|
||||
void PropertyManagementComponent::SetOwnerId(const LWOOBJID value) {
|
||||
|
@ -21,7 +21,7 @@ void PropertyVendorComponent::OnUse(Entity* originator) {
|
||||
if (PropertyManagementComponent::Instance()->GetOwnerId() == LWOOBJID_EMPTY) {
|
||||
Game::logger->Log("PropertyVendorComponent", "Property vendor opening!");
|
||||
|
||||
GameMessages::SendOpenPropertyVendor(m_OwningEntity->GetObjectID(), originator->GetSystemAddress());
|
||||
GameMessages::SendOpenPropertyVendor(m_ParentEntity->GetObjectID(), originator->GetSystemAddress());
|
||||
|
||||
return;
|
||||
}
|
||||
@ -30,7 +30,7 @@ void PropertyVendorComponent::OnUse(Entity* originator) {
|
||||
void PropertyVendorComponent::OnQueryPropertyData(Entity* originator, const SystemAddress& sysAddr) {
|
||||
if (PropertyManagementComponent::Instance() == nullptr) return;
|
||||
|
||||
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, sysAddr, m_OwningEntity->GetObjectID());
|
||||
PropertyManagementComponent::Instance()->OnQueryPropertyData(originator, sysAddr, m_ParentEntity->GetObjectID());
|
||||
}
|
||||
|
||||
void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool confirmed, const LOT lot, const uint32_t count) {
|
||||
@ -41,11 +41,11 @@ void PropertyVendorComponent::OnBuyFromVendor(Entity* originator, const bool con
|
||||
return;
|
||||
}
|
||||
|
||||
GameMessages::SendPropertyRentalResponse(m_OwningEntity->GetObjectID(), 0, 0, 0, 0, originator->GetSystemAddress());
|
||||
GameMessages::SendPropertyRentalResponse(m_ParentEntity->GetObjectID(), 0, 0, 0, 0, originator->GetSystemAddress());
|
||||
|
||||
auto* controller = dZoneManager::Instance()->GetZoneControlObject();
|
||||
|
||||
controller->OnFireEventServerSide(m_OwningEntity, "propertyRented");
|
||||
controller->OnFireEventServerSide(m_ParentEntity, "propertyRented");
|
||||
|
||||
PropertyManagementComponent::Instance()->SetOwner(originator);
|
||||
|
||||
|
@ -25,8 +25,8 @@ ProximityMonitorComponent::~ProximityMonitorComponent() {
|
||||
}
|
||||
|
||||
void ProximityMonitorComponent::SetProximityRadius(float proxRadius, const std::string& name) {
|
||||
dpEntity* en = new dpEntity(m_OwningEntity->GetObjectID(), proxRadius);
|
||||
en->SetPosition(m_OwningEntity->GetPosition());
|
||||
dpEntity* en = new dpEntity(m_ParentEntity->GetObjectID(), proxRadius);
|
||||
en->SetPosition(m_ParentEntity->GetPosition());
|
||||
|
||||
dpWorld::Instance().AddEntity(en);
|
||||
m_ProximitiesData.insert(std::make_pair(name, en));
|
||||
@ -34,7 +34,7 @@ void ProximityMonitorComponent::SetProximityRadius(float proxRadius, const std::
|
||||
|
||||
void ProximityMonitorComponent::SetProximityRadius(dpEntity* entity, const std::string& name) {
|
||||
dpWorld::Instance().AddEntity(entity);
|
||||
entity->SetPosition(m_OwningEntity->GetPosition());
|
||||
entity->SetPosition(m_ParentEntity->GetPosition());
|
||||
m_ProximitiesData.insert(std::make_pair(name, entity));
|
||||
}
|
||||
|
||||
@ -66,12 +66,12 @@ void ProximityMonitorComponent::Update(float deltaTime) {
|
||||
|
||||
//Process enter events
|
||||
for (auto* en : prox.second->GetNewObjects()) {
|
||||
m_OwningEntity->OnCollisionProximity(en->GetObjectID(), prox.first, "ENTER");
|
||||
m_ParentEntity->OnCollisionProximity(en->GetObjectID(), prox.first, "ENTER");
|
||||
}
|
||||
|
||||
//Process exit events
|
||||
for (auto* en : prox.second->GetRemovedObjects()) {
|
||||
m_OwningEntity->OnCollisionProximity(en->GetObjectID(), prox.first, "LEAVE");
|
||||
m_ParentEntity->OnCollisionProximity(en->GetObjectID(), prox.first, "LEAVE");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,13 +132,13 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
info.lot = 8092;
|
||||
info.pos = startPosition;
|
||||
info.rot = startRotation;
|
||||
info.spawnerID = m_OwningEntity->GetObjectID();
|
||||
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||
|
||||
auto* carEntity =
|
||||
EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity);
|
||||
EntityManager::Instance()->CreateEntity(info, nullptr, m_ParentEntity);
|
||||
|
||||
// Make the vehicle a child of the racing controller.
|
||||
m_OwningEntity->AddChild(carEntity);
|
||||
m_ParentEntity->AddChild(carEntity);
|
||||
|
||||
auto* destroyableComponent = carEntity->GetComponent<DestroyableComponent>();
|
||||
|
||||
@ -205,17 +205,17 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(carEntity);
|
||||
EntityManager::Instance()->SerializeEntity(player);
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
GameMessages::SendRacingSetPlayerResetInfo(
|
||||
m_OwningEntity->GetObjectID(), 0, 0, player->GetObjectID(), startPosition, 1,
|
||||
m_ParentEntity->GetObjectID(), 0, 0, player->GetObjectID(), startPosition, 1,
|
||||
UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
const auto playerID = player->GetObjectID();
|
||||
|
||||
// Reset the player to the start position during downtime, in case something
|
||||
// went wrong.
|
||||
m_OwningEntity->AddCallbackTimer(1, [this, playerID]() {
|
||||
m_ParentEntity->AddCallbackTimer(1, [this, playerID]() {
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
|
||||
if (player == nullptr) {
|
||||
@ -223,14 +223,14 @@ void RacingControlComponent::LoadPlayerVehicle(Entity* player,
|
||||
}
|
||||
|
||||
GameMessages::SendRacingResetPlayerToLastReset(
|
||||
m_OwningEntity->GetObjectID(), playerID, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
m_ParentEntity->GetObjectID(), playerID, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
});
|
||||
|
||||
GameMessages::SendSetJetPackMode(player, false);
|
||||
|
||||
// Set the vehicle's state.
|
||||
GameMessages::SendNotifyVehicleOfRacingObject(carEntity->GetObjectID(),
|
||||
m_OwningEntity->GetObjectID(),
|
||||
m_ParentEntity->GetObjectID(),
|
||||
UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
GameMessages::SendVehicleSetWheelLockState(carEntity->GetObjectID(), false,
|
||||
@ -253,7 +253,7 @@ void RacingControlComponent::OnRacingClientReady(Entity* player) {
|
||||
if (racingPlayer.playerID != player->GetObjectID()) {
|
||||
if (racingPlayer.playerLoaded) {
|
||||
GameMessages::SendRacingPlayerLoaded(
|
||||
m_OwningEntity->GetObjectID(), racingPlayer.playerID,
|
||||
m_ParentEntity->GetObjectID(), racingPlayer.playerID,
|
||||
racingPlayer.vehicleID, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
@ -263,11 +263,11 @@ void RacingControlComponent::OnRacingClientReady(Entity* player) {
|
||||
racingPlayer.playerLoaded = true;
|
||||
|
||||
GameMessages::SendRacingPlayerLoaded(
|
||||
m_OwningEntity->GetObjectID(), racingPlayer.playerID,
|
||||
m_ParentEntity->GetObjectID(), racingPlayer.playerID,
|
||||
racingPlayer.vehicleID, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void RacingControlComponent::OnRequestDie(Entity* player) {
|
||||
@ -300,15 +300,15 @@ void RacingControlComponent::OnRequestDie(Entity* player) {
|
||||
|
||||
// Respawn the player in 2 seconds, as was done in live. Not sure if this value is in a setting somewhere else...
|
||||
vehicle->AddCallbackTimer(2.0f, [=]() {
|
||||
if (!vehicle || !this->m_OwningEntity) return;
|
||||
if (!vehicle || !this->m_ParentEntity) return;
|
||||
GameMessages::SendRacingResetPlayerToLastReset(
|
||||
m_OwningEntity->GetObjectID(), racingPlayer.playerID,
|
||||
m_ParentEntity->GetObjectID(), racingPlayer.playerID,
|
||||
UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
GameMessages::SendVehicleStopBoost(vehicle, player->GetSystemAddress(), true);
|
||||
|
||||
GameMessages::SendRacingSetPlayerResetInfo(
|
||||
m_OwningEntity->GetObjectID(), racingPlayer.lap,
|
||||
m_ParentEntity->GetObjectID(), racingPlayer.lap,
|
||||
racingPlayer.respawnIndex, player->GetObjectID(),
|
||||
racingPlayer.respawnPosition, racingPlayer.respawnIndex + 1,
|
||||
UNASSIGNED_SYSTEM_ADDRESS);
|
||||
@ -326,12 +326,12 @@ void RacingControlComponent::OnRequestDie(Entity* player) {
|
||||
}
|
||||
} else {
|
||||
GameMessages::SendRacingSetPlayerResetInfo(
|
||||
m_OwningEntity->GetObjectID(), racingPlayer.lap,
|
||||
m_ParentEntity->GetObjectID(), racingPlayer.lap,
|
||||
racingPlayer.respawnIndex, player->GetObjectID(),
|
||||
racingPlayer.respawnPosition, racingPlayer.respawnIndex + 1,
|
||||
UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendRacingResetPlayerToLastReset(
|
||||
m_OwningEntity->GetObjectID(), racingPlayer.playerID,
|
||||
m_ParentEntity->GetObjectID(), racingPlayer.playerID,
|
||||
UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
}
|
||||
@ -375,11 +375,11 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu
|
||||
// Calculate the score, different loot depending on player count
|
||||
const auto score = m_LoadedPlayers * 10 + data->finished;
|
||||
|
||||
LootGenerator::Instance().GiveActivityLoot(player, m_OwningEntity, m_ActivityID, score);
|
||||
LootGenerator::Instance().GiveActivityLoot(player, m_ParentEntity, m_ActivityID, score);
|
||||
|
||||
// Giving rewards
|
||||
GameMessages::SendNotifyRacingClient(
|
||||
m_OwningEntity->GetObjectID(), 2, 0, LWOOBJID_EMPTY, u"",
|
||||
m_ParentEntity->GetObjectID(), 2, 0, LWOOBJID_EMPTY, u"",
|
||||
player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||
@ -409,7 +409,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu
|
||||
|
||||
// Exiting race
|
||||
GameMessages::SendNotifyRacingClient(
|
||||
m_OwningEntity->GetObjectID(), 3, 0, LWOOBJID_EMPTY, u"",
|
||||
m_ParentEntity->GetObjectID(), 3, 0, LWOOBJID_EMPTY, u"",
|
||||
player->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
auto* playerInstance = dynamic_cast<Player*>(player);
|
||||
@ -617,7 +617,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
// Setup for racing
|
||||
if (m_StartTimer == 0) {
|
||||
GameMessages::SendNotifyRacingClient(
|
||||
m_OwningEntity->GetObjectID(), 1, 0, LWOOBJID_EMPTY, u"",
|
||||
m_ParentEntity->GetObjectID(), 1, 0, LWOOBJID_EMPTY, u"",
|
||||
LWOOBJID_EMPTY, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
for (const auto& player : m_RacingPlayers) {
|
||||
@ -700,14 +700,14 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
}
|
||||
|
||||
// Start the race
|
||||
GameMessages::SendActivityStart(m_OwningEntity->GetObjectID(),
|
||||
GameMessages::SendActivityStart(m_ParentEntity->GetObjectID(),
|
||||
UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
m_Started = true;
|
||||
|
||||
Game::logger->Log("RacingControlComponent", "Starting race");
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
m_StartTime = std::time(nullptr);
|
||||
}
|
||||
@ -738,7 +738,7 @@ void RacingControlComponent::Update(float deltaTime) {
|
||||
// If the player is this far below the map, safe to assume they should
|
||||
// be smashed by death plane
|
||||
if (vehiclePosition.y < -500) {
|
||||
GameMessages::SendDie(vehicle, m_OwningEntity->GetObjectID(),
|
||||
GameMessages::SendDie(vehicle, m_ParentEntity->GetObjectID(),
|
||||
LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0,
|
||||
true, false, 0);
|
||||
|
||||
|
@ -43,7 +43,7 @@ RailActivatorComponent::RailActivatorComponent(Entity* parent, int32_t component
|
||||
RailActivatorComponent::~RailActivatorComponent() = default;
|
||||
|
||||
void RailActivatorComponent::OnUse(Entity* originator) {
|
||||
auto* rebuildComponent = m_OwningEntity->GetComponent<RebuildComponent>();
|
||||
auto* rebuildComponent = m_ParentEntity->GetComponent<RebuildComponent>();
|
||||
if (rebuildComponent != nullptr && rebuildComponent->GetState() != eRebuildState::COMPLETED)
|
||||
return;
|
||||
|
||||
@ -67,7 +67,7 @@ void RailActivatorComponent::OnUse(Entity* originator) {
|
||||
|
||||
const auto originatorID = originator->GetObjectID();
|
||||
|
||||
m_OwningEntity->AddCallbackTimer(animationLength, [originatorID, this]() {
|
||||
m_ParentEntity->AddCallbackTimer(animationLength, [originatorID, this]() {
|
||||
auto* originator = EntityManager::Instance()->GetEntity(originatorID);
|
||||
|
||||
if (originator == nullptr) {
|
||||
@ -78,7 +78,7 @@ void RailActivatorComponent::OnUse(Entity* originator) {
|
||||
m_loopSound, m_StopSound, originator->GetSystemAddress(),
|
||||
m_PathStart, m_PathDirection, m_DamageImmune, m_NoAggro, m_NotifyArrived,
|
||||
m_ShowNameBillboard, m_CameraLocked, m_CollisionEnabled, m_UseDB, m_ComponentID,
|
||||
m_OwningEntity->GetObjectID());
|
||||
m_ParentEntity->GetObjectID());
|
||||
});
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ void RailActivatorComponent::OnRailMovementReady(Entity* originator) const {
|
||||
|
||||
GameMessages::SendSetRailMovement(originator->GetObjectID(), m_PathDirection, m_Path, m_PathStart,
|
||||
originator->GetSystemAddress(), m_ComponentID,
|
||||
m_OwningEntity->GetObjectID());
|
||||
m_ParentEntity->GetObjectID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ void RailActivatorComponent::OnCancelRailMovement(Entity* originator) {
|
||||
true, true, true, true, true, true, true
|
||||
);
|
||||
|
||||
auto* rebuildComponent = m_OwningEntity->GetComponent<RebuildComponent>();
|
||||
auto* rebuildComponent = m_ParentEntity->GetComponent<RebuildComponent>();
|
||||
|
||||
if (rebuildComponent != nullptr) {
|
||||
// Set back reset time
|
||||
|
@ -33,14 +33,14 @@ RebuildComponent::RebuildComponent(Entity* entity) : Component(entity) {
|
||||
|
||||
// Should a setting that has the build activator position exist, fetch that setting here and parse it for position.
|
||||
// It is assumed that the user who sets this setting uses the correct character delimiter (character 31 or in hex 0x1F)
|
||||
auto positionAsVector = GeneralUtils::SplitString(m_OwningEntity->GetVarAsString(u"rebuild_activators"), 0x1F);
|
||||
auto positionAsVector = GeneralUtils::SplitString(m_ParentEntity->GetVarAsString(u"rebuild_activators"), 0x1F);
|
||||
if (positionAsVector.size() == 3 &&
|
||||
GeneralUtils::TryParse(positionAsVector[0], m_ActivatorPosition.x) &&
|
||||
GeneralUtils::TryParse(positionAsVector[1], m_ActivatorPosition.y) &&
|
||||
GeneralUtils::TryParse(positionAsVector[2], m_ActivatorPosition.z)) {
|
||||
} else {
|
||||
Game::logger->Log("RebuildComponent", "Failed to find activator position for lot %i. Defaulting to parents position.", m_OwningEntity->GetLOT());
|
||||
m_ActivatorPosition = m_OwningEntity->GetPosition();
|
||||
Game::logger->Log("RebuildComponent", "Failed to find activator position for lot %i. Defaulting to parents position.", m_ParentEntity->GetLOT());
|
||||
m_ActivatorPosition = m_ParentEntity->GetPosition();
|
||||
}
|
||||
|
||||
SpawnActivator();
|
||||
@ -58,7 +58,7 @@ RebuildComponent::~RebuildComponent() {
|
||||
}
|
||||
|
||||
void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||
if (!m_OwningEntity->GetComponent<DestroyableComponent>()) {
|
||||
if (!m_ParentEntity->GetComponent<DestroyableComponent>()) {
|
||||
if (bIsInitialUpdate) {
|
||||
outBitStream->Write(false);
|
||||
}
|
||||
@ -120,7 +120,7 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
else {
|
||||
m_SoftTimer = 5.0f;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}*/
|
||||
|
||||
switch (m_State) {
|
||||
@ -128,7 +128,7 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
SpawnActivator();
|
||||
m_TimeBeforeDrain = 0;
|
||||
|
||||
auto* spawner = m_OwningEntity->GetSpawner();
|
||||
auto* spawner = m_ParentEntity->GetSpawner();
|
||||
const bool isSmashGroup = spawner != nullptr ? spawner->GetIsSpawnSmashGroup() : false;
|
||||
|
||||
if (isSmashGroup) {
|
||||
@ -139,13 +139,13 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
||||
m_ShowResetEffect = true;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash) {
|
||||
m_Builder = LWOOBJID_EMPTY;
|
||||
|
||||
GameMessages::SendDieNoImplCode(m_OwningEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
GameMessages::SendDieNoImplCode(m_ParentEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
|
||||
ResetRebuild(false);
|
||||
}
|
||||
@ -163,13 +163,13 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
if (!m_ShowResetEffect) {
|
||||
m_ShowResetEffect = true;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Timer >= m_ResetTime) {
|
||||
|
||||
GameMessages::SendDieNoImplCode(m_OwningEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
GameMessages::SendDieNoImplCode(m_ParentEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
|
||||
ResetRebuild(false);
|
||||
}
|
||||
@ -225,13 +225,13 @@ void RebuildComponent::Update(float deltaTime) {
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash - 4.0f) {
|
||||
m_ShowResetEffect = true;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
if (m_TimerIncomplete >= m_TimeBeforeSmash) {
|
||||
m_Builder = LWOOBJID_EMPTY;
|
||||
|
||||
GameMessages::SendDieNoImplCode(m_OwningEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
GameMessages::SendDieNoImplCode(m_ParentEntity, LWOOBJID_EMPTY, LWOOBJID_EMPTY, eKillType::VIOLENT, u"", 0.0f, 0.0f, 0.0f, false, true);
|
||||
|
||||
ResetRebuild(false);
|
||||
}
|
||||
@ -260,16 +260,16 @@ void RebuildComponent::SpawnActivator() {
|
||||
EntityInfo info;
|
||||
|
||||
info.lot = 6604;
|
||||
info.spawnerID = m_OwningEntity->GetObjectID();
|
||||
info.pos = m_ActivatorPosition == NiPoint3::ZERO ? m_OwningEntity->GetPosition() : m_ActivatorPosition;
|
||||
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||
info.pos = m_ActivatorPosition == NiPoint3::ZERO ? m_ParentEntity->GetPosition() : m_ActivatorPosition;
|
||||
|
||||
m_Activator = EntityManager::Instance()->CreateEntity(info, nullptr, m_OwningEntity);
|
||||
m_Activator = EntityManager::Instance()->CreateEntity(info, nullptr, m_ParentEntity);
|
||||
if (m_Activator) {
|
||||
m_ActivatorId = m_Activator->GetObjectID();
|
||||
EntityManager::Instance()->ConstructEntity(m_Activator);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -405,25 +405,25 @@ void RebuildComponent::StartRebuild(Entity* user) {
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(user);
|
||||
|
||||
GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::BUILDING, user->GetObjectID());
|
||||
GameMessages::SendEnableRebuild(m_OwningEntity, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID());
|
||||
GameMessages::SendRebuildNotifyState(m_ParentEntity, m_State, eRebuildState::BUILDING, user->GetObjectID());
|
||||
GameMessages::SendEnableRebuild(m_ParentEntity, true, false, false, eQuickBuildFailReason::NOT_GIVEN, 0.0f, user->GetObjectID());
|
||||
|
||||
m_State = eRebuildState::BUILDING;
|
||||
m_StateDirty = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
auto* movingPlatform = m_OwningEntity->GetComponent<MovingPlatformComponent>();
|
||||
auto* movingPlatform = m_ParentEntity->GetComponent<MovingPlatformComponent>();
|
||||
if (movingPlatform != nullptr) {
|
||||
movingPlatform->OnRebuildInitilized();
|
||||
}
|
||||
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
||||
script->OnRebuildStart(m_OwningEntity, user);
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||
script->OnRebuildStart(m_ParentEntity, user);
|
||||
}
|
||||
|
||||
// Notify scripts and possible subscribers
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity))
|
||||
script->OnRebuildNotifyState(m_OwningEntity, m_State);
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity))
|
||||
script->OnRebuildNotifyState(m_ParentEntity, m_State);
|
||||
for (const auto& cb : m_RebuildStateCallbacks)
|
||||
cb(m_State);
|
||||
}
|
||||
@ -445,10 +445,10 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(user);
|
||||
|
||||
GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::COMPLETED, user->GetObjectID());
|
||||
GameMessages::SendPlayFXEffect(m_OwningEntity, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true);
|
||||
GameMessages::SendEnableRebuild(m_OwningEntity, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID());
|
||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendRebuildNotifyState(m_ParentEntity, m_State, eRebuildState::COMPLETED, user->GetObjectID());
|
||||
GameMessages::SendPlayFXEffect(m_ParentEntity, 507, u"create", "BrickFadeUpVisCompleteEffect", LWOOBJID_EMPTY, 0.4f, 1.0f, true);
|
||||
GameMessages::SendEnableRebuild(m_ParentEntity, false, false, true, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, user->GetObjectID());
|
||||
GameMessages::SendTerminateInteraction(user->GetObjectID(), eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||
|
||||
|
||||
m_State = eRebuildState::COMPLETED;
|
||||
@ -456,7 +456,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
m_Timer = 0.0f;
|
||||
m_DrainedImagination = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
// 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.
|
||||
@ -468,7 +468,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
DespawnActivator();
|
||||
|
||||
// Set owner override so that entities smashed by this quickbuild will result in the builder getting rewards.
|
||||
m_OwningEntity->SetOwnerOverride(user->GetObjectID());
|
||||
m_ParentEntity->SetOwnerOverride(user->GetObjectID());
|
||||
|
||||
auto* builder = GetBuilder();
|
||||
|
||||
@ -486,13 +486,13 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
auto* missionComponent = builder->GetComponent<MissionComponent>();
|
||||
if (missionComponent) missionComponent->Progress(eMissionTaskType::ACTIVITY, m_ActivityId);
|
||||
}
|
||||
LootGenerator::Instance().DropActivityLoot(builder, m_OwningEntity, m_ActivityId, 1);
|
||||
LootGenerator::Instance().DropActivityLoot(builder, m_ParentEntity, m_ActivityId, 1);
|
||||
}
|
||||
|
||||
// Notify scripts
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
||||
script->OnRebuildComplete(m_OwningEntity, user);
|
||||
script->OnRebuildNotifyState(m_OwningEntity, m_State);
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||
script->OnRebuildComplete(m_ParentEntity, user);
|
||||
script->OnRebuildNotifyState(m_ParentEntity, m_State);
|
||||
}
|
||||
|
||||
// Notify subscribers
|
||||
@ -501,9 +501,9 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
for (const auto& callback : m_RebuildCompleteCallbacks)
|
||||
callback(user);
|
||||
|
||||
m_OwningEntity->TriggerEvent(eTriggerEventType::REBUILD_COMPLETE, user);
|
||||
m_ParentEntity->TriggerEvent(eTriggerEventType::REBUILD_COMPLETE, user);
|
||||
|
||||
auto* movingPlatform = m_OwningEntity->GetComponent<MovingPlatformComponent>();
|
||||
auto* movingPlatform = m_ParentEntity->GetComponent<MovingPlatformComponent>();
|
||||
if (movingPlatform != nullptr) {
|
||||
movingPlatform->OnCompleteRebuild();
|
||||
}
|
||||
@ -512,7 +512,7 @@ void RebuildComponent::CompleteRebuild(Entity* user) {
|
||||
auto* character = user->GetCharacter();
|
||||
|
||||
if (character != nullptr) {
|
||||
const auto flagNumber = m_OwningEntity->GetVar<int32_t>(u"quickbuild_single_build_player_flag");
|
||||
const auto flagNumber = m_ParentEntity->GetVar<int32_t>(u"quickbuild_single_build_player_flag");
|
||||
|
||||
if (flagNumber != 0) {
|
||||
character->SetPlayerFlag(flagNumber, true);
|
||||
@ -525,14 +525,14 @@ void RebuildComponent::ResetRebuild(bool failed) {
|
||||
Entity* builder = GetBuilder();
|
||||
|
||||
if (m_State == eRebuildState::BUILDING && builder) {
|
||||
GameMessages::SendEnableRebuild(m_OwningEntity, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID());
|
||||
GameMessages::SendEnableRebuild(m_ParentEntity, false, false, failed, eQuickBuildFailReason::NOT_GIVEN, m_ResetTime, builder->GetObjectID());
|
||||
|
||||
if (failed) {
|
||||
RenderComponent::PlayAnimation(builder, u"rebuild-fail");
|
||||
}
|
||||
}
|
||||
|
||||
GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::RESETTING, LWOOBJID_EMPTY);
|
||||
GameMessages::SendRebuildNotifyState(m_ParentEntity, m_State, eRebuildState::RESETTING, LWOOBJID_EMPTY);
|
||||
|
||||
m_State = eRebuildState::RESETTING;
|
||||
m_StateDirty = true;
|
||||
@ -541,15 +541,15 @@ void RebuildComponent::ResetRebuild(bool failed) {
|
||||
m_ShowResetEffect = false;
|
||||
m_DrainedImagination = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
// Notify scripts and possible subscribers
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity))
|
||||
script->OnRebuildNotifyState(m_OwningEntity, m_State);
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity))
|
||||
script->OnRebuildNotifyState(m_ParentEntity, m_State);
|
||||
for (const auto& cb : m_RebuildStateCallbacks)
|
||||
cb(m_State);
|
||||
|
||||
m_OwningEntity->ScheduleKillAfterUpdate();
|
||||
m_ParentEntity->ScheduleKillAfterUpdate();
|
||||
|
||||
if (m_Activator) {
|
||||
m_Activator->ScheduleKillAfterUpdate();
|
||||
@ -564,24 +564,24 @@ void RebuildComponent::CancelRebuild(Entity* entity, eQuickBuildFailReason failR
|
||||
const auto entityID = entity != nullptr ? entity->GetObjectID() : LWOOBJID_EMPTY;
|
||||
|
||||
// Notify the client that a state has changed
|
||||
GameMessages::SendRebuildNotifyState(m_OwningEntity, m_State, eRebuildState::INCOMPLETE, entityID);
|
||||
GameMessages::SendEnableRebuild(m_OwningEntity, false, true, false, failReason, m_Timer, entityID);
|
||||
GameMessages::SendRebuildNotifyState(m_ParentEntity, m_State, eRebuildState::INCOMPLETE, entityID);
|
||||
GameMessages::SendEnableRebuild(m_ParentEntity, false, true, false, failReason, m_Timer, entityID);
|
||||
|
||||
// Now terminate any interaction with the rebuild
|
||||
GameMessages::SendTerminateInteraction(entityID, eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendTerminateInteraction(m_OwningEntity->GetObjectID(), eTerminateType::FROM_INTERACTION, m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendTerminateInteraction(entityID, eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||
GameMessages::SendTerminateInteraction(m_ParentEntity->GetObjectID(), eTerminateType::FROM_INTERACTION, m_ParentEntity->GetObjectID());
|
||||
|
||||
// Now update the component itself
|
||||
m_State = eRebuildState::INCOMPLETE;
|
||||
m_StateDirty = true;
|
||||
|
||||
// Notify scripts and possible subscribers
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity))
|
||||
script->OnRebuildNotifyState(m_OwningEntity, m_State);
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity))
|
||||
script->OnRebuildNotifyState(m_ParentEntity, m_State);
|
||||
for (const auto& cb : m_RebuildStateCallbacks)
|
||||
cb(m_State);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
if (entity == nullptr) {
|
||||
|
@ -141,7 +141,7 @@ void RenderComponent::Update(const float deltaTime) {
|
||||
void RenderComponent::PlayEffect(const int32_t effectId, const std::u16string& effectType, const std::string& name, const LWOOBJID secondary, const float priority, const float scale, const bool serialize) {
|
||||
RemoveEffect(name);
|
||||
|
||||
GameMessages::SendPlayFXEffect(m_OwningEntity, effectId, effectType, name, secondary, priority, scale, serialize);
|
||||
GameMessages::SendPlayFXEffect(m_ParentEntity, effectId, effectType, name, secondary, priority, scale, serialize);
|
||||
|
||||
auto* effect = AddEffect(effectId, name, effectType);
|
||||
|
||||
@ -180,7 +180,7 @@ void RenderComponent::PlayEffect(const int32_t effectId, const std::u16string& e
|
||||
}
|
||||
|
||||
void RenderComponent::StopEffect(const std::string& name, const bool killImmediate) {
|
||||
GameMessages::SendStopFXEffect(m_OwningEntity, killImmediate, name);
|
||||
GameMessages::SendStopFXEffect(m_ParentEntity, killImmediate, name);
|
||||
|
||||
RemoveEffect(name);
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include "Entity.h"
|
||||
|
||||
RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* parent) : Component(parent) {
|
||||
m_Position = m_OwningEntity->GetDefaultPosition();
|
||||
m_Rotation = m_OwningEntity->GetDefaultRotation();
|
||||
m_Position = m_ParentEntity->GetDefaultPosition();
|
||||
m_Rotation = m_ParentEntity->GetDefaultRotation();
|
||||
m_IsDirty = true;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ void RocketLaunchpadControlComponent::Launch(Entity* originator, LWOMAPID mapId,
|
||||
|
||||
SetSelectedMapId(originator->GetObjectID(), zone);
|
||||
|
||||
GameMessages::SendFireEventClientSide(m_OwningEntity->GetObjectID(), originator->GetSystemAddress(), u"RocketEquipped", rocket->GetId(), cloneId, -1, originator->GetObjectID());
|
||||
GameMessages::SendFireEventClientSide(m_ParentEntity->GetObjectID(), originator->GetSystemAddress(), u"RocketEquipped", rocket->GetId(), cloneId, -1, originator->GetObjectID());
|
||||
|
||||
GameMessages::SendChangeObjectWorldState(rocket->GetId(), eObjectWorldState::ATTACHED, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
@ -89,12 +89,12 @@ void RocketLaunchpadControlComponent::OnUse(Entity* originator) {
|
||||
// instead we let their OnUse handlers do their things
|
||||
// which components of an Object have their OnUse called when using them
|
||||
// so we don't need to call it here
|
||||
auto* propertyEntrance = m_OwningEntity->GetComponent<PropertyEntranceComponent>();
|
||||
auto* propertyEntrance = m_ParentEntity->GetComponent<PropertyEntranceComponent>();
|
||||
if (propertyEntrance) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* multiZoneEntranceComponent = m_OwningEntity->GetComponent<MultiZoneEntranceComponent>();
|
||||
auto* multiZoneEntranceComponent = m_ParentEntity->GetComponent<MultiZoneEntranceComponent>();
|
||||
if (multiZoneEntranceComponent) {
|
||||
return;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit
|
||||
}
|
||||
}
|
||||
|
||||
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
|
||||
auto* destroyableComponent = m_ParentEntity->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent) {
|
||||
// check for LMIs and set the loot LMIs
|
||||
@ -137,11 +137,11 @@ void ScriptedActivityComponent::PlayerJoin(Entity* player) {
|
||||
instance->AddParticipant(player);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void ScriptedActivityComponent::PlayerJoinLobby(Entity* player) {
|
||||
if (!m_OwningEntity->HasComponent(eReplicaComponentType::QUICK_BUILD))
|
||||
if (!m_ParentEntity->HasComponent(eReplicaComponentType::QUICK_BUILD))
|
||||
GameMessages::SendMatchResponse(player, player->GetSystemAddress(), 0); // tell the client they joined a lobby
|
||||
LobbyPlayer* newLobbyPlayer = new LobbyPlayer();
|
||||
newLobbyPlayer->entityID = player->GetObjectID();
|
||||
@ -304,7 +304,7 @@ bool ScriptedActivityComponent::HasLobby() const {
|
||||
bool ScriptedActivityComponent::IsValidActivity(Entity* player) {
|
||||
// Makes it so that scripted activities with an unimplemented map cannot be joined
|
||||
/*if (player->GetGMLevel() < eGameMasterLevel::DEVELOPER && (m_ActivityInfo.instanceMapID == 1302 || m_ActivityInfo.instanceMapID == 1301)) {
|
||||
if (m_OwningEntity->GetLOT() == 4860) {
|
||||
if (m_ParentEntity->GetLOT() == 4860) {
|
||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||
missionComponent->CompleteMission(229);
|
||||
}
|
||||
@ -390,7 +390,7 @@ void ScriptedActivityComponent::PlayerReady(Entity* player, bool bReady) {
|
||||
}
|
||||
|
||||
ActivityInstance* ScriptedActivityComponent::NewInstance() {
|
||||
auto* instance = new ActivityInstance(m_OwningEntity, m_ActivityInfo);
|
||||
auto* instance = new ActivityInstance(m_ParentEntity, m_ActivityInfo);
|
||||
m_Instances.push_back(instance);
|
||||
return instance;
|
||||
}
|
||||
@ -445,7 +445,7 @@ void ScriptedActivityComponent::RemoveActivityPlayerData(LWOOBJID playerID) {
|
||||
m_ActivityPlayers[i] = nullptr;
|
||||
|
||||
m_ActivityPlayers.erase(m_ActivityPlayers.begin() + i);
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -458,7 +458,7 @@ ActivityPlayer* ScriptedActivityComponent::AddActivityPlayerData(LWOOBJID player
|
||||
return data;
|
||||
|
||||
m_ActivityPlayers.push_back(new ActivityPlayer{ playerID, {} });
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
|
||||
return GetActivityPlayerData(playerID);
|
||||
}
|
||||
@ -480,7 +480,7 @@ void ScriptedActivityComponent::SetActivityValue(LWOOBJID playerID, uint32_t ind
|
||||
data->values[std::min(index, (uint32_t)9)] = value;
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void ScriptedActivityComponent::PlayerRemove(LWOOBJID playerID) {
|
||||
@ -576,7 +576,7 @@ void ActivityInstance::RewardParticipant(Entity* participant) {
|
||||
maxCoins = currencyTable[0].maxvalue;
|
||||
}
|
||||
|
||||
LootGenerator::Instance().DropLoot(participant, m_OwningEntity, activityRewards[0].LootMatrixIndex, minCoins, maxCoins);
|
||||
LootGenerator::Instance().DropLoot(participant, m_ParentEntity, activityRewards[0].LootMatrixIndex, minCoins, maxCoins);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
class ActivityInstance {
|
||||
public:
|
||||
ActivityInstance(Entity* parent, CDActivities activityInfo) { m_OwningEntity = parent; m_ActivityInfo = activityInfo; };
|
||||
ActivityInstance(Entity* parent, CDActivities activityInfo) { m_ParentEntity = parent; m_ActivityInfo = activityInfo; };
|
||||
//~ActivityInstance();
|
||||
|
||||
/**
|
||||
@ -86,7 +86,7 @@ private:
|
||||
/**
|
||||
* The entity that owns this activity (the entity that has the ScriptedActivityComponent)
|
||||
*/
|
||||
Entity* m_OwningEntity;
|
||||
Entity* m_ParentEntity;
|
||||
|
||||
/**
|
||||
* All the participants of this activity
|
||||
|
@ -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_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const {
|
||||
|
@ -13,12 +13,12 @@
|
||||
|
||||
#include "Entity.h"
|
||||
|
||||
SimplePhysicsComponent::SimplePhysicsComponent(uint32_t componentID, Entity* parent) : Component(parent) {
|
||||
m_Position = m_OwningEntity->GetDefaultPosition();
|
||||
m_Rotation = m_OwningEntity->GetDefaultRotation();
|
||||
SimplePhysicsComponent::SimplePhysicsComponent(Entity* parent, uint32_t componentID) : Component(parent) {
|
||||
m_Position = m_ParentEntity->GetDefaultPosition();
|
||||
m_Rotation = m_ParentEntity->GetDefaultRotation();
|
||||
m_IsDirty = true;
|
||||
|
||||
const auto& climbable_type = m_OwningEntity->GetVar<std::u16string>(u"climbable");
|
||||
const auto& climbable_type = m_ParentEntity->GetVar<std::u16string>(u"climbable");
|
||||
if (climbable_type == u"wall") {
|
||||
SetClimbableType(eClimbableType::CLIMBABLE_TYPE_WALL);
|
||||
} else if (climbable_type == u"ladder") {
|
||||
|
@ -30,7 +30,7 @@ class SimplePhysicsComponent : public Component {
|
||||
public:
|
||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::SIMPLE_PHYSICS;
|
||||
|
||||
SimplePhysicsComponent(uint32_t componentID, Entity* parent);
|
||||
SimplePhysicsComponent(Entity* parent, uint32_t componentID);
|
||||
~SimplePhysicsComponent() override;
|
||||
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||
|
@ -32,9 +32,9 @@ ProjectileSyncEntry::ProjectileSyncEntry() {
|
||||
std::unordered_map<uint32_t, uint32_t> SkillComponent::m_skillBehaviorCache = {};
|
||||
|
||||
bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t skillUid, RakNet::BitStream* bitStream, const LWOOBJID target, uint32_t skillID) {
|
||||
auto* context = new BehaviorContext(this->m_OwningEntity->GetObjectID());
|
||||
auto* context = new BehaviorContext(this->m_ParentEntity->GetObjectID());
|
||||
|
||||
context->caster = m_OwningEntity->GetObjectID();
|
||||
context->caster = m_ParentEntity->GetObjectID();
|
||||
|
||||
context->skillID = skillID;
|
||||
|
||||
@ -130,11 +130,11 @@ void SkillComponent::RegisterPlayerProjectile(const LWOOBJID projectileId, Behav
|
||||
}
|
||||
|
||||
void SkillComponent::Update(const float deltaTime) {
|
||||
if (!m_OwningEntity->HasComponent(eReplicaComponentType::BASE_COMBAT_AI) && m_OwningEntity->GetLOT() != 1) {
|
||||
if (!m_ParentEntity->HasComponent(eReplicaComponentType::BASE_COMBAT_AI) && m_ParentEntity->GetLOT() != 1) {
|
||||
CalculateUpdate(deltaTime);
|
||||
}
|
||||
|
||||
if (m_OwningEntity->IsPlayer()) {
|
||||
if (m_ParentEntity->IsPlayer()) {
|
||||
for (const auto& pair : this->m_managedBehaviors) pair.second->UpdatePlayerSyncs(deltaTime);
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ void SkillComponent::Reset() {
|
||||
|
||||
void SkillComponent::Interrupt() {
|
||||
// TODO: need to check immunities on the destroyable component, but they aren't implemented
|
||||
auto* combat = m_OwningEntity->GetComponent<BaseCombatAIComponent>();
|
||||
auto* combat = m_ParentEntity->GetComponent<BaseCombatAIComponent>();
|
||||
if (combat != nullptr && combat->GetStunImmune()) return;
|
||||
|
||||
for (const auto& behavior : this->m_managedBehaviors) {
|
||||
@ -201,7 +201,7 @@ void SkillComponent::Interrupt() {
|
||||
behaviorEndEntry.behavior->End(behavior.second, behaviorEndEntry.branchContext, behaviorEndEntry.second);
|
||||
}
|
||||
behavior.second->endEntries.clear();
|
||||
if (m_OwningEntity->IsPlayer()) continue;
|
||||
if (m_ParentEntity->IsPlayer()) continue;
|
||||
behavior.second->Interrupt();
|
||||
}
|
||||
|
||||
@ -256,9 +256,9 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
|
||||
|
||||
auto* behavior = Behavior::CreateBehavior(behaviorId);
|
||||
|
||||
auto* context = new BehaviorContext(originatorOverride != LWOOBJID_EMPTY ? originatorOverride : this->m_OwningEntity->GetObjectID(), true);
|
||||
auto* context = new BehaviorContext(originatorOverride != LWOOBJID_EMPTY ? originatorOverride : this->m_ParentEntity->GetObjectID(), true);
|
||||
|
||||
context->caster = m_OwningEntity->GetObjectID();
|
||||
context->caster = m_ParentEntity->GetObjectID();
|
||||
|
||||
context->skillID = skillId;
|
||||
|
||||
@ -268,8 +268,8 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
|
||||
|
||||
behavior->Calculate(context, bitStream, { target, 0 });
|
||||
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_OwningEntity)) {
|
||||
script->OnSkillCast(m_OwningEntity, skillId);
|
||||
for (auto* script : CppScripts::GetEntityScripts(m_ParentEntity)) {
|
||||
script->OnSkillCast(m_ParentEntity, skillId);
|
||||
}
|
||||
|
||||
if (!context->foundTarget) {
|
||||
@ -305,7 +305,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c
|
||||
RakNet::BitStream message;
|
||||
|
||||
PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
message.Write(this->m_OwningEntity->GetObjectID());
|
||||
message.Write(this->m_ParentEntity->GetObjectID());
|
||||
start.Serialize(&message);
|
||||
|
||||
Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||
@ -431,14 +431,14 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry)
|
||||
DoClientProjectileImpact projectileImpact;
|
||||
|
||||
projectileImpact.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed());
|
||||
projectileImpact.i64OwnerID = this->m_OwningEntity->GetObjectID();
|
||||
projectileImpact.i64OwnerID = this->m_ParentEntity->GetObjectID();
|
||||
projectileImpact.i64OrgID = entry.id;
|
||||
projectileImpact.i64TargetID = entry.branchContext.target;
|
||||
|
||||
RakNet::BitStream message;
|
||||
|
||||
PacketUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
message.Write(this->m_OwningEntity->GetObjectID());
|
||||
message.Write(this->m_ParentEntity->GetObjectID());
|
||||
projectileImpact.Serialize(&message);
|
||||
|
||||
Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||
|
@ -76,7 +76,7 @@ void SoundTriggerComponent::ActivateMusicCue(const std::string& name) {
|
||||
-1.0f
|
||||
});
|
||||
dirty = true;
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ std::vector<SwitchComponent*> SwitchComponent::petSwitches;
|
||||
SwitchComponent::SwitchComponent(Entity* parent) : Component(parent) {
|
||||
m_Active = false;
|
||||
|
||||
m_ResetTime = m_OwningEntity->GetVarAs<int32_t>(u"switch_reset_time");
|
||||
m_ResetTime = m_ParentEntity->GetVarAs<int32_t>(u"switch_reset_time");
|
||||
|
||||
m_Rebuild = m_OwningEntity->GetComponent<RebuildComponent>();
|
||||
m_Rebuild = m_ParentEntity->GetComponent<RebuildComponent>();
|
||||
}
|
||||
|
||||
SwitchComponent::~SwitchComponent() {
|
||||
@ -43,10 +43,10 @@ void SwitchComponent::EntityEnter(Entity* entity) {
|
||||
if (m_Rebuild->GetState() != eRebuildState::COMPLETED) return;
|
||||
}
|
||||
m_Active = true;
|
||||
if (!m_OwningEntity) return;
|
||||
m_OwningEntity->TriggerEvent(eTriggerEventType::ACTIVATED, entity);
|
||||
if (!m_ParentEntity) return;
|
||||
m_ParentEntity->TriggerEvent(eTriggerEventType::ACTIVATED, entity);
|
||||
|
||||
const auto grpName = m_OwningEntity->GetVarAsString(u"grp_name");
|
||||
const auto grpName = m_ParentEntity->GetVarAsString(u"grp_name");
|
||||
|
||||
if (!grpName.empty()) {
|
||||
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
|
||||
@ -59,11 +59,11 @@ void SwitchComponent::EntityEnter(Entity* entity) {
|
||||
m_Timer = m_ResetTime;
|
||||
|
||||
if (m_PetBouncer != nullptr) {
|
||||
GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true);
|
||||
RenderComponent::PlayAnimation(m_OwningEntity, u"engaged");
|
||||
GameMessages::SendPlayFXEffect(m_ParentEntity->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true);
|
||||
RenderComponent::PlayAnimation(m_ParentEntity, u"engaged");
|
||||
m_PetBouncer->SetPetBouncerEnabled(true);
|
||||
} else {
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
}
|
||||
@ -79,10 +79,10 @@ void SwitchComponent::Update(float deltaTime) {
|
||||
|
||||
if (m_Timer <= 0.0f) {
|
||||
m_Active = false;
|
||||
if (!m_OwningEntity) return;
|
||||
m_OwningEntity->TriggerEvent(eTriggerEventType::DEACTIVATED, m_OwningEntity);
|
||||
if (!m_ParentEntity) return;
|
||||
m_ParentEntity->TriggerEvent(eTriggerEventType::DEACTIVATED, m_ParentEntity);
|
||||
|
||||
const auto grpName = m_OwningEntity->GetVarAsString(u"grp_name");
|
||||
const auto grpName = m_ParentEntity->GetVarAsString(u"grp_name");
|
||||
|
||||
if (!grpName.empty()) {
|
||||
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
|
||||
@ -95,14 +95,14 @@ void SwitchComponent::Update(float deltaTime) {
|
||||
if (m_PetBouncer != nullptr) {
|
||||
m_PetBouncer->SetPetBouncerEnabled(false);
|
||||
} else {
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Entity* SwitchComponent::GetParentEntity() const {
|
||||
return m_OwningEntity;
|
||||
return m_ParentEntity;
|
||||
}
|
||||
|
||||
SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) {
|
||||
@ -110,7 +110,7 @@ SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) {
|
||||
SwitchComponent* closest = nullptr;
|
||||
|
||||
for (SwitchComponent* petSwitch : petSwitches) {
|
||||
float distance = Vector3::DistanceSquared(petSwitch->m_OwningEntity->GetPosition(), position);
|
||||
float distance = Vector3::DistanceSquared(petSwitch->m_ParentEntity->GetPosition(), position);
|
||||
|
||||
if (closest == nullptr || distance < closestDistance) {
|
||||
closestDistance = distance;
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo): Component(parent) {
|
||||
m_OwningEntity = parent;
|
||||
m_ParentEntity = parent;
|
||||
m_Trigger = nullptr;
|
||||
|
||||
std::vector<std::string> tokens = GeneralUtils::SplitString(triggerInfo, ':');
|
||||
@ -116,7 +116,7 @@ void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity
|
||||
HandleCastSkill(targetEntity, command->args);
|
||||
break;
|
||||
case eTriggerCommandType::DISPLAY_ZONE_SUMMARY:
|
||||
GameMessages::SendDisplayZoneSummary(targetEntity->GetObjectID(), targetEntity->GetSystemAddress(), false, command->args == "1", m_OwningEntity->GetObjectID());
|
||||
GameMessages::SendDisplayZoneSummary(targetEntity->GetObjectID(), targetEntity->GetSystemAddress(), false, command->args == "1", m_ParentEntity->GetObjectID());
|
||||
break;
|
||||
case eTriggerCommandType::SET_PHYSICS_VOLUME_EFFECT:
|
||||
HandleSetPhysicsVolumeEffect(targetEntity, argArray);
|
||||
@ -164,7 +164,7 @@ void TriggerComponent::HandleTriggerCommand(LUTriggers::Command* command, Entity
|
||||
std::vector<Entity*> TriggerComponent::GatherTargets(LUTriggers::Command* command, Entity* optionalTarget) {
|
||||
std::vector<Entity*> entities = {};
|
||||
|
||||
if (command->target == "self") entities.push_back(m_OwningEntity);
|
||||
if (command->target == "self") entities.push_back(m_ParentEntity);
|
||||
else if (command->target == "zone") { /*TODO*/ }
|
||||
else if (command->target == "target" && optionalTarget) entities.push_back(optionalTarget);
|
||||
else if (command->target == "targetTeam" && optionalTarget) {
|
||||
@ -185,14 +185,14 @@ std::vector<Entity*> TriggerComponent::GatherTargets(LUTriggers::Command* comman
|
||||
|
||||
void TriggerComponent::HandleFireEvent(Entity* targetEntity, std::string args) {
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(targetEntity)) {
|
||||
script->OnFireEventServerSide(targetEntity, m_OwningEntity, args, 0, 0, 0);
|
||||
script->OnFireEventServerSide(targetEntity, m_ParentEntity, args, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){
|
||||
uint32_t killType;
|
||||
GeneralUtils::TryParse<uint32_t>(args, killType);
|
||||
targetEntity->Smash(m_OwningEntity->GetObjectID(), static_cast<eKillType>(killType));
|
||||
targetEntity->Smash(m_ParentEntity->GetObjectID(), static_cast<eKillType>(killType));
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){
|
||||
@ -237,7 +237,7 @@ 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_OwningEntity->GetComponent<PhantomPhysicsComponent>();
|
||||
auto* phantomPhysicsComponent = m_ParentEntity->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!phantomPhysicsComponent) {
|
||||
Game::logger->LogDebug("TriggerComponent::HandlePushObject", "Phantom Physics component not found!");
|
||||
return;
|
||||
@ -249,12 +249,12 @@ 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_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
|
||||
void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args){
|
||||
auto* phantomPhysicsComponent = m_OwningEntity->GetComponent<PhantomPhysicsComponent>();
|
||||
auto* phantomPhysicsComponent = m_ParentEntity->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!phantomPhysicsComponent) {
|
||||
Game::logger->LogDebug("TriggerComponent::HandleRepelObject", "Phantom Physics component not found!");
|
||||
return;
|
||||
@ -265,7 +265,7 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args)
|
||||
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
|
||||
phantomPhysicsComponent->SetDirectionalMultiplier(forceMultiplier);
|
||||
|
||||
auto triggerPos = m_OwningEntity->GetPosition();
|
||||
auto triggerPos = m_ParentEntity->GetPosition();
|
||||
auto targetPos = targetEntity->GetPosition();
|
||||
|
||||
// normalize the vectors to get the direction
|
||||
@ -274,7 +274,7 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args)
|
||||
NiPoint3 direction = delta / length;
|
||||
phantomPhysicsComponent->SetDirection(direction);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
|
||||
EntityManager::Instance()->SerializeEntity(m_ParentEntity);
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::string> argArray){
|
||||
@ -284,11 +284,11 @@ void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::str
|
||||
}
|
||||
float time = 0.0;
|
||||
GeneralUtils::TryParse<float>(argArray.at(1), time);
|
||||
m_OwningEntity->AddTimer(argArray.at(0), time);
|
||||
m_ParentEntity->AddTimer(argArray.at(0), time);
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleCancelTimer(Entity* targetEntity, std::string args){
|
||||
m_OwningEntity->CancelTimer(args);
|
||||
m_ParentEntity->CancelTimer(args);
|
||||
}
|
||||
|
||||
void TriggerComponent::HandlePlayCinematic(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||
|
@ -24,8 +24,8 @@ void VendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitial
|
||||
}
|
||||
|
||||
void VendorComponent::OnUse(Entity* originator) {
|
||||
GameMessages::SendVendorOpenWindow(m_OwningEntity, originator->GetSystemAddress());
|
||||
GameMessages::SendVendorStatusUpdate(m_OwningEntity, originator->GetSystemAddress());
|
||||
GameMessages::SendVendorOpenWindow(m_ParentEntity, originator->GetSystemAddress());
|
||||
GameMessages::SendVendorStatusUpdate(m_ParentEntity, originator->GetSystemAddress());
|
||||
}
|
||||
|
||||
float VendorComponent::GetBuyScalar() const {
|
||||
@ -50,12 +50,12 @@ std::map<LOT, int>& VendorComponent::GetInventory() {
|
||||
|
||||
bool VendorComponent::HasCraftingStation() {
|
||||
// As far as we know, only Umami has a crafting station
|
||||
return m_OwningEntity->GetLOT() == 13800;
|
||||
return m_ParentEntity->GetLOT() == 13800;
|
||||
}
|
||||
|
||||
void VendorComponent::RefreshInventory(bool isCreation) {
|
||||
//Custom code for Max vanity NPC
|
||||
if (m_OwningEntity->GetLOT() == 9749 && Game::server->GetZoneID() == 1201) {
|
||||
if (m_ParentEntity->GetLOT() == 9749 && Game::server->GetZoneID() == 1201) {
|
||||
if (!isCreation) return;
|
||||
m_Inventory.insert({ 11909, 0 }); //Top hat w frog
|
||||
m_Inventory.insert({ 7785, 0 }); //Flash bulb
|
||||
@ -97,7 +97,7 @@ void VendorComponent::RefreshInventory(bool isCreation) {
|
||||
}
|
||||
|
||||
//Because I want a vendor to sell these cameras
|
||||
if (m_OwningEntity->GetLOT() == 13569) {
|
||||
if (m_ParentEntity->GetLOT() == 13569) {
|
||||
auto randomCamera = GeneralUtils::GenerateRandomNumber<int32_t>(0, 2);
|
||||
|
||||
switch (randomCamera) {
|
||||
@ -116,15 +116,15 @@ void VendorComponent::RefreshInventory(bool isCreation) {
|
||||
}
|
||||
|
||||
// Callback timer to refresh this inventory.
|
||||
m_OwningEntity->AddCallbackTimer(m_RefreshTimeSeconds, [this]() {
|
||||
m_ParentEntity->AddCallbackTimer(m_RefreshTimeSeconds, [this]() {
|
||||
RefreshInventory();
|
||||
});
|
||||
GameMessages::SendVendorStatusUpdate(m_OwningEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
GameMessages::SendVendorStatusUpdate(m_ParentEntity, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
void VendorComponent::SetupConstants() {
|
||||
auto* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||
int componentID = compRegistryTable->GetByIDAndType(m_OwningEntity->GetLOT(), eReplicaComponentType::VENDOR);
|
||||
int componentID = compRegistryTable->GetByIDAndType(m_ParentEntity->GetLOT(), eReplicaComponentType::VENDOR);
|
||||
|
||||
auto* vendorComponentTable = CDClientManager::Instance().GetTable<CDVendorComponentTable>();
|
||||
std::vector<CDVendorComponent> vendorComps = vendorComponentTable->Query([=](CDVendorComponent entry) { return (entry.id == componentID); });
|
||||
|
@ -19,7 +19,7 @@ ScriptComponent::~ScriptComponent() {
|
||||
|
||||
void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||
if (bIsInitialUpdate) {
|
||||
const auto& networkSettings = m_OwningEntity->GetNetworkSettings();
|
||||
const auto& networkSettings = m_ParentEntity->GetNetworkSettings();
|
||||
auto hasNetworkSettings = !networkSettings.empty();
|
||||
outBitStream->Write(hasNetworkSettings);
|
||||
|
||||
@ -52,5 +52,5 @@ void ScriptComponent::SetScript(const std::string& scriptName) {
|
||||
return;
|
||||
}*/
|
||||
|
||||
m_Script = CppScripts::GetScript(m_OwningEntity, scriptName);
|
||||
m_Script = CppScripts::GetScript(m_ParentEntity, scriptName);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user