Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Rewrite Entity Component System #1110

Draft
wants to merge 122 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
c168f6c
Break out the model component
aronwk-aaron Feb 11, 2023
5097862
Merge branch 'main' into item-component
aronwk-aaron Feb 11, 2023
2ae9a92
fix cmake
aronwk-aaron Feb 11, 2023
c2d5be0
include
aronwk-aaron Mar 21, 2023
5e9a956
Merge branch 'main' into item-component
aronwk-aaron Mar 21, 2023
15988af
hey it compiles
aronwk-aaron Mar 21, 2023
716a5fc
Rename some variables in Component
EmosewaMC Jun 7, 2023
ea9d0d8
I hope this works
EmosewaMC Jun 7, 2023
9e9e4dc
Move to shared pointer
EmosewaMC Jun 7, 2023
d11e2db
update component names, document heirarchy
aronwk-aaron Jun 8, 2023
ec00f5f
holy mother of const
EmosewaMC Jun 9, 2023
62aa863
Remove shared pointer, ODR of componentType variable
EmosewaMC Jun 9, 2023
e2dfa18
Replace all auto with auto*
EmosewaMC Jun 9, 2023
f555ba8
Rename from GetOwningEntity to GetParentEntity
EmosewaMC Jun 9, 2023
6f05720
Rename some variables
EmosewaMC Jun 9, 2023
5da776a
Add blank classes for some Components
EmosewaMC Jun 9, 2023
f2d28cc
Update CMakeLists.txt
EmosewaMC Jun 9, 2023
0b37dc1
Update includes for propertyEnteranceComponent
EmosewaMC Jun 9, 2023
e3a716a
Further re-implement Entity::Initialize
EmosewaMC Jun 9, 2023
ddc5f0e
Merge branch 'main' into components-wheeeee
EmosewaMC Jun 9, 2023
a68fa69
Rename RebuildComponent to QuickbuildComponent
aronwk-aaron Jun 9, 2023
1c23f3c
Add test for component Whitelists
EmosewaMC Jun 10, 2023
2a27997
More robust tests
EmosewaMC Jun 10, 2023
5714ac5
Use std algorithms
EmosewaMC Jun 10, 2023
cebe3c7
Update to actually work with component list
EmosewaMC Jun 10, 2023
b91f84d
Collectible, Item, further re-implement initialize
EmosewaMC Jun 10, 2023
0b5df9f
Destroyable
EmosewaMC Jun 10, 2023
77dc6ff
Continued re-integration of Entity::Initialize
EmosewaMC Jun 11, 2023
5f139c7
Quickbuild and Destroyable reintegration
EmosewaMC Jun 11, 2023
b43e5c2
doesnt have a component
EmosewaMC Jun 11, 2023
f78ea1b
whitespace and comments in quickbuild
EmosewaMC Jun 11, 2023
fc719cb
Comment out done code
EmosewaMC Jun 11, 2023
36c44ec
Fully re-implemented initialize
EmosewaMC Jun 12, 2023
6f38a15
Minor formatting change
EmosewaMC Jun 12, 2023
262b6eb
Remove old Entity Initialize
EmosewaMC Jun 12, 2023
5be9146
Specify auto ptr
EmosewaMC Jun 12, 2023
3f38105
Extra * on one auto
EmosewaMC Jun 12, 2023
f9ac0a9
few more pointer specifiers
EmosewaMC Jun 12, 2023
d224a86
Use only 1 script component per Entity
EmosewaMC Jun 12, 2023
326c495
Use more clear control paths
EmosewaMC Jun 12, 2023
b2fee29
Better log and comment
EmosewaMC Jun 12, 2023
45bcc80
doesnt compile
EmosewaMC Jun 12, 2023
e389a61
update heirarchy
aronwk-aaron Jun 13, 2023
d8e2e92
use get
EmosewaMC Jun 14, 2023
31be1fb
remove script stuff
EmosewaMC Jun 14, 2023
fdd98ab
fix other script calls
aronwk-aaron Jun 14, 2023
83065df
I havent checked if this compiled
EmosewaMC Jun 15, 2023
451f7e7
switch to unique_ptrs for callback timers
EmosewaMC Jun 15, 2023
355f4f4
Update Entity.cpp
EmosewaMC Jun 15, 2023
2a8f40f
Finish file
EmosewaMC Jun 15, 2023
4d57eff
Update includes
EmosewaMC Jun 15, 2023
35e5d84
Remove empty destructors
EmosewaMC Jun 15, 2023
ea97596
Fix typo
EmosewaMC Jun 16, 2023
9a9b9aa
Merge branch 'components-wheeeee' of https://github.com/DarkflameUniv…
EmosewaMC Jun 16, 2023
9200612
Another consistency pass
EmosewaMC Jun 16, 2023
8916482
Organize Entity header
EmosewaMC Jun 16, 2023
a992a28
Merge from upstream
EmosewaMC Jun 16, 2023
be17d1a
Update DestroyableComponent.cpp
EmosewaMC Jun 16, 2023
68a5cc1
Use better API terminology for radii
EmosewaMC Jun 17, 2023
1bdec00
More organization of header
EmosewaMC Jun 17, 2023
e180430
Finish header re-ordering
EmosewaMC Jun 18, 2023
dc96fcb
Vendor cleanup and start Donation Vendor impl
aronwk-aaron Jun 23, 2023
907e045
some tweaks
aronwk-aaron Jun 23, 2023
c78760d
make inheritence clearer
aronwk-aaron Jun 23, 2023
f27e040
scaffold activity based components
aronwk-aaron Jun 23, 2023
bcbc588
Merge branch 'main' into components-wheeeee
aronwk-aaron Jun 23, 2023
34d22d2
AchievementVendor scaffold
aronwk-aaron Jun 23, 2023
d153d66
Merge branch 'item-component' into components-wheeeee
aronwk-aaron Jun 23, 2023
d44b18e
rough logic around loading physics
aronwk-aaron Jun 23, 2023
c237c16
group physicstogether in heirarchy
aronwk-aaron Jun 23, 2023
485a88d
move vars to be local
aronwk-aaron Jun 24, 2023
3f328a1
Merge upstream ghosting candidate changes
EmosewaMC Jun 26, 2023
fee1025
Remove commented out logic, add ghosting exclusion
EmosewaMC Jun 26, 2023
9121bf4
Entity work
EmosewaMC Jun 26, 2023
ec92782
Use better naming
EmosewaMC Jun 26, 2023
34cfd45
CombatAI and Vendor
EmosewaMC Jun 26, 2023
a5611e9
Bouncer cleanup
EmosewaMC Jun 26, 2023
06acd23
Use of final
EmosewaMC Jun 26, 2023
d29287f
Buff Component fixes
EmosewaMC Jun 26, 2023
68f90b7
rename possessor to possession
aronwk-aaron Jun 26, 2023
fd182d2
Update activing and racing components
aronwk-aaron Jun 26, 2023
fdcfbde
BuildBorderCleanup
EmosewaMC Jun 27, 2023
d9a3bea
Merge branch 'components-wheeeee' of https://github.com/DarkflameUniv…
EmosewaMC Jun 27, 2023
2abcb14
Character fixes - get it compiling again
EmosewaMC Jun 27, 2023
c6063aa
Component serialization updates
EmosewaMC Jun 27, 2023
7c12659
move ctor to header for collectible
EmosewaMC Jun 27, 2023
478b6ff
Move empty definitions to header
EmosewaMC Jun 27, 2023
f55bec0
Donation Component serialization
EmosewaMC Jun 27, 2023
c2fe7f6
HavokVehicleComponent improvements
EmosewaMC Jun 27, 2023
0544eeb
Add default constructor for EquipmentItem
EmosewaMC Jun 27, 2023
81404d9
InventoryComponent pass
EmosewaMC Jun 28, 2023
6fb1786
Add component order array
aronwk-aaron Jun 29, 2023
c22040c
ItemComponent Pass
EmosewaMC Jul 5, 2023
8ede5b8
Fix compilation error; add final specifiers
EmosewaMC Jul 5, 2023
cfec980
LevelProgressionComponent cleanup
EmosewaMC Jul 5, 2023
68a2a04
LUPExhibitComponent cleanup
EmosewaMC Jul 5, 2023
197d1bc
Merge branch 'main' into components-wheeeee
aronwk-aaron Jul 5, 2023
950a1fe
MissionComponent pass
EmosewaMC Jul 6, 2023
001f6a7
MissionOfferComponent pass
EmosewaMC Jul 6, 2023
5301346
ModelBehaviorComponent pass
EmosewaMC Jul 6, 2023
cf53e35
SwitchComponent pass
EmosewaMC Jul 7, 2023
28fbe20
ModuleAssemblyComponent pass
EmosewaMC Jul 8, 2023
790bd6c
Merge branch 'components-wheeeee' of https://github.com/DarkflameUniv…
EmosewaMC Jul 8, 2023
1b7be5d
Merge branch 'components-wheeeee' of https://github.com/DarkflameUniv…
EmosewaMC Jul 10, 2023
2528e02
add final
EmosewaMC Jul 10, 2023
8a512e5
MovementAiComponent pass
EmosewaMC Jul 10, 2023
d2a7e14
I am throwing this one out later.
EmosewaMC Jul 10, 2023
7ca9e59
MultiZoneEntranceComponent pass
EmosewaMC Jul 10, 2023
83780af
MutableModelBehaviorComponent pass
EmosewaMC Jul 10, 2023
87675aa
PetComponent pass
EmosewaMC Jul 10, 2023
28637a2
PhantomPhysicsComponent pass
EmosewaMC Jul 10, 2023
598d88b
PlayerForcedMovementComponent pass
EmosewaMC Jul 10, 2023
fe6b279
PossessableComponent pass
EmosewaMC Jul 10, 2023
59831fc
PhantomPhysicsComponent pass
EmosewaMC Jul 10, 2023
4d88f63
PossessionComponent pass
EmosewaMC Jul 10, 2023
37bcc81
PropertyComponent pass
EmosewaMC Jul 10, 2023
8678ed0
push no pass
EmosewaMC Jul 11, 2023
a37ec32
idek if ill keep this but yeah
EmosewaMC Jul 11, 2023
c204ea4
PropertyVendorComponent pass
EmosewaMC Jul 11, 2023
49f3d75
ProximityMonitorComponent re-pass
EmosewaMC Jul 11, 2023
949a6db
RailActivatorComponent pass
EmosewaMC Jul 11, 2023
6240eef
local work
EmosewaMC Jul 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename some variables
- Add order for loading Components
- Enforce all components have Entity* in the first argument
EmosewaMC committed Jun 9, 2023
commit 6f057204be6f35e107d5772a0f1496fdc6129009
29 changes: 23 additions & 6 deletions dGame/Entity.cpp
Original file line number Diff line number Diff line change
@@ -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 {
74 changes: 37 additions & 37 deletions dGame/EntityInitializeOld.cc
Original file line number Diff line number Diff line change
@@ -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 (m_Character) {
controllablePhysics->LoadFromXml(m_Character->GetXMLDoc());

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;

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();
}

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));
}
// if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CONTROLLABLE_PHYSICS) > 0) {
// ControllablePhysicsComponent* controllablePhysics = new ControllablePhysicsComponent(this);

// if (m_Character) {
// controllablePhysics->LoadFromXml(m_Character->GetXMLDoc());

// 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;

// 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();
// }

// 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));
// }

// If an entity is marked a phantom, simple physics is made into phantom phyics.
bool markedAsPhantom = GetVar<bool>(u"markedAsPhantom");
62 changes: 31 additions & 31 deletions dGame/dComponents/BaseCombatAIComponent.cpp
Original file line number Diff line number Diff line change
@@ -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) {
22 changes: 11 additions & 11 deletions dGame/dComponents/BouncerComponent.cpp
Original file line number Diff line number Diff line change
@@ -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();
});
}
Loading