2024-02-02 22:03:47 +11:00
|
|
|
|
|
|
|
#include "valve.hpp"
|
|
|
|
|
|
|
|
using namespace sim::coolant;
|
|
|
|
|
2024-02-03 18:12:18 +11:00
|
|
|
valve::valve(fluid_holder* src, fluid_holder* dst, double max) : src(src), dst(dst), max(max)
|
2024-02-02 22:03:47 +11:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-02-03 18:12:18 +11:00
|
|
|
void valve::add_open_speed(double v)
|
2024-02-02 22:03:47 +11:00
|
|
|
{
|
2024-02-03 18:12:18 +11:00
|
|
|
open_speed += v;
|
2024-02-02 22:03:47 +11:00
|
|
|
}
|
|
|
|
|
2024-02-03 18:12:18 +11:00
|
|
|
void valve::clear_open_speed()
|
2024-02-02 22:03:47 +11:00
|
|
|
{
|
2024-02-03 18:12:18 +11:00
|
|
|
open_speed = 0;
|
2024-02-02 22:03:47 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
void valve::update(double dt)
|
|
|
|
{
|
2024-02-03 18:12:18 +11:00
|
|
|
state += open_speed * dt;
|
|
|
|
if(state > 1) state = 1;
|
|
|
|
if(state < 0) state = 0;
|
2024-02-02 22:03:47 +11:00
|
|
|
}
|
|
|
|
|