Rename some variables

- Add order for loading Components
- Enforce all components have Entity* in the first argument
This commit is contained in:
David Markowitz
2023-06-09 02:46:01 -07:00
parent f555ba8c25
commit 6f057204be
49 changed files with 634 additions and 584 deletions

View File

@@ -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 {