+
+ if(controls->fire.was_pressed())
+ defer([this]{ fire(); });
+
+ controls->reset_edges();
+}
+
+void PlayerController::deferred_tick()
+{
+ System::deferred_tick();
+ erase_if(bullets, [](Game::Handle<Bullet> b){ return !b->get_hitpoints()->is_alive(); });
+}
+
+void PlayerController::fire()
+{
+ Game::Handle<Game::Transform> player_tf = player_ship->get_transform();
+ Game::Handle<RigidBody> player_body = player_ship->get_body();
+
+ Game::TransformValues tv;
+ tv.position = (player_tf->get_world_matrix()*LinAl::Vector<float, 4>(2.0f, 0.0f, 0.0f, 1.0f)).slice<3>(0);
+ tv.rotation = player_tf->get_rotation()*Geometry::Quaternion<float>::rotation(Geometry::Angle<float>::from_degrees(10), LinAl::Vector<float, 3>(0.0f, 0.0f, 1.0f));
+ bullets.emplace_back(stage.get_root(), bullet_setup, tv);
+ Game::Handle<Bullet> bullet = bullets.back();
+ Game::Handle<RigidBody> bullet_body = bullet->get_body();
+ bullet_body->set_velocity(player_body->get_velocity()+(player_tf->get_world_matrix()*LinAl::Vector<float, 4>(20.0f, 0.0f, 0.0f, 0.0f)).slice<2>(0));