diff --git a/src/systems/docking.cpp b/src/systems/docking.cpp index ca13beb8d..8785b3ebc 100644 --- a/src/systems/docking.cpp +++ b/src/systems/docking.cpp @@ -55,8 +55,9 @@ void DockingSystem::update(float delta) }else{ if (transform) { transform->setPosition(target_transform->getPosition() + rotateVec2(docking_port.docked_offset, target_transform->getRotation())); + transform->setRotation(vec2ToAngle(transform->getPosition() - target_transform->getPosition())); auto thrusters = entity.getComponent(); - if (thrusters) thrusters->target = vec2ToAngle(transform->getPosition() - target_transform->getPosition()); + if (thrusters) thrusters->stop(); } auto bay = docking_port.target.getComponent(); @@ -133,10 +134,16 @@ void DockingSystem::update(float delta) auto engine = entity.getComponent(); if (engine) + { engine->request = 0.f; + engine->actual = 0.f; + } auto warp = entity.getComponent(); if (warp) + { warp->request = 0; + warp->current = 0; + } break; } } @@ -210,6 +217,17 @@ void DockingSystem::requestUndock(sp::ecs::Entity entity) auto impulse = entity.getComponent(); if (impulse && impulse->getSystemEffectiveness() < 0.1f) return; + if (!entity.hasComponent()) + { + auto& t = entity.addComponent(); + auto target_transform = docking_port->target.getComponent(); + t.setPosition(target_transform->getPosition() + rotateVec2(docking_port->docked_offset, target_transform->getRotation())); + t.setRotation(target_transform->getRotation() + vec2ToAngle(docking_port->docked_offset)); + } + + auto thrusters = entity.getComponent(); + if (thrusters) thrusters->stop(); + docking_port->state = DockingPort::State::NotDocking; if (impulse) impulse->request = 0.5; }