formatting

This commit is contained in:
kacper 2019-07-28 16:00:14 +02:00
parent fd0df4177f
commit 999b6709a3

View File

@ -589,18 +589,18 @@ fn handle_light(server: &mut Server, entity: EcsEntity, args: String, action: &C
scan_fmt!(&args, action.arg_fmt, f32, f32, f32, f32, f32, f32, f32);
let mut light_emitter = comp::LightEmitter::default();
if let (Some(r), Some(g), Some(b)) = (opt_r, opt_g, opt_b) {
let r = clamp(r,0.0,1.0);
let g = clamp(g,0.0,1.0);
let b = clamp(b,0.0,1.0);
let r = clamp(r, 0.0, 1.0);
let g = clamp(g, 0.0, 1.0);
let b = clamp(b, 0.0, 1.0);
light_emitter.col = Rgb::new(r, g, b)
};
if let (Some(x), Some(y), Some(z)) = (opt_x, opt_y, opt_z) {
light_emitter.offset = Vec3::new(x, y, z)
};
if let Some(s) = opt_s {
light_emitter.strength = clamp(s,0.0,100.0)
light_emitter.strength = clamp(s, 0.0, 100.0)
};
let pos = server
.state
@ -643,7 +643,7 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action:
.write_storage::<comp::LightEmitter>()
.get_mut(entity)
{
light.strength = clamp(s,0.0,100.0);
light.strength = clamp(s, 0.0, 100.0);
server.clients.notify(
entity,
ServerMsg::chat(String::from("You played with flame strength.")),
@ -670,7 +670,11 @@ fn handle_lantern(server: &mut Server, entity: EcsEntity, args: String, action:
comp::LightEmitter {
offset: Vec3::new(1.0, 0.2, 0.8),
col: Rgb::new(0.824, 0.365, 0.196),
strength: if let Some(s) = opt_s { clamp(s,0.0,100.0) } else { 2.0 },
strength: if let Some(s) = opt_s {
clamp(s, 0.0, 100.0)
} else {
2.0
},
},
);
@ -747,15 +751,15 @@ fn handle_tell(server: &mut Server, entity: EcsEntity, args: String, action: &Ch
}
}
//#region Helper
fn clamp(value: f32,min:f32,max:f32) -> f32 {
if value >= min {
if value > max {
max
} else {
value
}
fn clamp(value: f32, min: f32, max: f32) -> f32 {
if value >= min {
if value > max {
max
} else {
min
value
}
} else {
min
}
//#endregion
}
//#endregion