mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-06 10:44:08 +00:00
woirking
This commit is contained in:
@@ -71,7 +71,10 @@ ControllablePhysicsComponent::~ControllablePhysicsComponent() {
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::Update(float deltaTime) {
|
||||
|
||||
if (m_Velocity == NiPoint3::ZERO) return;
|
||||
m_Position += m_Velocity * deltaTime;
|
||||
m_DirtyPosition = true;
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
|
||||
void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||
@@ -153,6 +156,7 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bo
|
||||
}
|
||||
|
||||
outBitStream->Write0();
|
||||
if (!bIsInitialUpdate) m_DirtyPosition = false;
|
||||
}
|
||||
|
||||
if (!bIsInitialUpdate) {
|
||||
|
@@ -63,7 +63,14 @@ void MovementAIComponent::SetupPath(const std::string& pathname) {
|
||||
}
|
||||
const Path* pathData = Game::zoneManager->GetZone()->GetPath(path);
|
||||
if (pathData) {
|
||||
Game::logger->Log("MovementAIComponent", "found path %s", path.c_str());
|
||||
Game::logger->Log("MovementAIComponent", "found path %i %s", m_Parent->GetLOT(), path.c_str());
|
||||
m_Path = pathData;
|
||||
std::vector<NiPoint3> waypoints;
|
||||
for (auto& waypoint : m_Path->pathWaypoints) {
|
||||
waypoints.push_back(waypoint.position);
|
||||
}
|
||||
SetPath(waypoints);
|
||||
SetMaxSpeed(3.0f);
|
||||
} else {
|
||||
Game::logger->Log("MovementAIComponent", "No path found for %i:%llu", m_Parent->GetLOT(), m_Parent->GetObjectID());
|
||||
}
|
||||
@@ -144,7 +151,16 @@ void MovementAIComponent::Update(const float deltaTime) {
|
||||
// Check if there are more waypoints in the queue, if so set our next destination to the next waypoint
|
||||
HandleWaypointArrived();
|
||||
if (!AdvancePathWaypointIndex()) {
|
||||
Stop();
|
||||
if (m_Path && m_Path->pathBehavior == PathBehavior::Bounce) {
|
||||
ReversePath(); // untested.
|
||||
} else if (m_Path && m_Path->pathBehavior == PathBehavior::Loop) {
|
||||
m_CurrentPathWaypointIndex = 0;
|
||||
m_NextPathWaypointIndex = 0;
|
||||
AdvancePathWaypointIndex();
|
||||
SetDestination(GetCurrentPathWaypoint());
|
||||
} else {
|
||||
Stop();
|
||||
}
|
||||
return;
|
||||
}
|
||||
SetDestination(GetCurrentPathWaypoint());
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
class ControllablePhysicsComponent;
|
||||
class BaseCombatAIComponent;
|
||||
class Path;
|
||||
|
||||
/**
|
||||
* Information that describes the different variables used to make an entity move around
|
||||
@@ -265,7 +266,7 @@ private:
|
||||
/**
|
||||
* The path this entity is currently traversing
|
||||
*/
|
||||
uint32_t m_PathIndex;
|
||||
int32_t m_PathIndex;
|
||||
|
||||
/**
|
||||
* If the entity has reached it last waypoint
|
||||
@@ -346,6 +347,11 @@ private:
|
||||
* Whether or not the current movement via pathing is paused.
|
||||
*/
|
||||
bool m_IsPaused;
|
||||
|
||||
/**
|
||||
* The optional path this component will follow.
|
||||
*/
|
||||
const Path* m_Path = nullptr;
|
||||
};
|
||||
|
||||
#endif // MOVEMENTAICOMPONENT_H
|
||||
|
Reference in New Issue
Block a user