mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'Nero/lantern_strenght_fix' into 'master'
after review See merge request veloren/veloren!370
This commit is contained in:
commit
cdc8f3629e
@ -591,16 +591,16 @@ fn handle_light(server: &mut Server, entity: EcsEntity, args: String, action: &C
|
||||
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 = r.max(0.0).min(1.0);
|
||||
let g = g.max(0.0).min(1.0);
|
||||
let b = b.max(0.0).min(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 = s.max(0.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 = s.max(0.1);
|
||||
server.clients.notify(
|
||||
entity,
|
||||
ServerMsg::chat(String::from("You played with flame strength.")),
|
||||
@ -670,11 +670,7 @@ 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 { s.max(0.0) } else { 2.0 },
|
||||
},
|
||||
);
|
||||
|
||||
@ -750,16 +746,3 @@ fn handle_tell(server: &mut Server, entity: EcsEntity, args: String, action: &Ch
|
||||
.notify(entity, ServerMsg::private(String::from(action.help_string))),
|
||||
}
|
||||
}
|
||||
//#region Helper
|
||||
fn clamp(value: f32, min: f32, max: f32) -> f32 {
|
||||
if value >= min {
|
||||
if value > max {
|
||||
max
|
||||
} else {
|
||||
value
|
||||
}
|
||||
} else {
|
||||
min
|
||||
}
|
||||
}
|
||||
//#endregion
|
||||
|
Loading…
Reference in New Issue
Block a user