mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-06 10:44:08 +00:00
feat: Movement behaviors (#1815)
* Move in all directions is functional * feat: add movement behaviors the following behaviors will function MoveRight MoveLeft FlyUp FlyDown MoveForward MoveBackward The behavior of the behaviors is once a move in an axis is active, that behavior must finish its movement before another one on that axis can do another movement on it.
This commit is contained in:
@@ -1994,6 +1994,38 @@ void Entity::SetRotation(const NiQuaternion& rotation) {
|
||||
Game::entityManager->SerializeEntity(this);
|
||||
}
|
||||
|
||||
void Entity::SetVelocity(const NiPoint3& velocity) {
|
||||
auto* controllable = GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllable != nullptr) {
|
||||
controllable->SetVelocity(velocity);
|
||||
}
|
||||
|
||||
auto* simple = GetComponent<SimplePhysicsComponent>();
|
||||
|
||||
if (simple != nullptr) {
|
||||
simple->SetVelocity(velocity);
|
||||
}
|
||||
|
||||
Game::entityManager->SerializeEntity(this);
|
||||
}
|
||||
|
||||
const NiPoint3& Entity::GetVelocity() const {
|
||||
auto* controllable = GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllable != nullptr) {
|
||||
return controllable->GetVelocity();
|
||||
}
|
||||
|
||||
auto* simple = GetComponent<SimplePhysicsComponent>();
|
||||
|
||||
if (simple != nullptr) {
|
||||
return simple->GetVelocity();
|
||||
}
|
||||
|
||||
return NiPoint3Constant::ZERO;
|
||||
}
|
||||
|
||||
bool Entity::GetBoolean(const std::u16string& name) const {
|
||||
return GetVar<bool>(name);
|
||||
}
|
||||
|
Reference in New Issue
Block a user