@@ -46,6 +46,8 @@ Player::Player(Services const& services, std::unique_ptr<IController> controller
46
46
47
47
if (auto const death = resources.get <ParticleEmitter>(" assets/particles/explode.json" )) { m_death_source = *death; }
48
48
m_death_source.config .respawn = false ;
49
+
50
+ m_heat_color = rgbas.get_or (" ship_heat" , bave::red_v);
49
51
}
50
52
51
53
void Player::on_focus (bave::FocusChange const & /* focus_changed*/ ) { m_controller->untap (); }
@@ -65,7 +67,20 @@ void Player::tick(State const& state, Seconds const dt) {
65
67
.muzzle_position = get_muzzle_position (),
66
68
.in_play = !m_health.is_dead (),
67
69
};
68
- m_arsenal.tick (round_state, m_controller->is_firing (), dt);
70
+
71
+ auto const has_fired = m_arsenal.tick (round_state, m_controller->is_firing () && !m_is_cooling_down, dt);
72
+
73
+ if (has_fired) {
74
+ m_heat += m_heat_increment;
75
+ } else {
76
+ m_heat -= (m_is_cooling_down ? m_heat_dissipated * 0 .5f : m_heat_dissipated) * dt.count ();
77
+ }
78
+ if (m_heat >= 1 .0f ) { m_is_cooling_down = true ; }
79
+ if (m_heat <= m_cooldown_threshold) { m_is_cooling_down = false ; }
80
+ m_heat = std::clamp (m_heat, 0 .f , 1 .0f );
81
+
82
+ m_heat_being_rendered = glm::mix (m_heat_being_rendered, m_heat, 0 .5f );
83
+ ship.tint = bave::Rgba::from (glm::mix (bave::white_v.to_vec4 (), m_heat_color.to_vec4 (), m_heat_being_rendered));
69
84
70
85
m_shield.set_position (ship.transform .position );
71
86
m_shield.tick (dt);
@@ -188,6 +203,10 @@ void Player::do_inspect() {
188
203
}
189
204
190
205
if (ImGui::Button (" 1up" )) { one_up (); }
206
+
207
+ ImGui::DragFloat (" heat dissipated per sec" , &m_heat_dissipated, 0 .05f , 0 .f , 1 .f );
208
+ ImGui::DragFloat (" heat per round fired" , &m_heat_increment, 0 .1f , 0 .f , 1 .f );
209
+ ImGui::DragFloat (" cooldown threshold" , &m_cooldown_threshold, 0 .1f , 0 .f , 0 .9f );
191
210
}
192
211
}
193
212
} // namespace spaced
0 commit comments