1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use crate::body::Body;
use crate::utils::{GameTimeC, ClothesGroupC};
impl Body {
/// Is player sleeping now
pub fn is_sleeping(&self) -> bool { self.is_sleeping.get() }
/// Cached warmth level value
pub fn warmth_level(&self) -> f32 { self.warmth_level.get() }
/// Cached wetness level value
pub fn wetness_level(&self) -> f32 { self.wetness_level.get() }
/// Last time slept (if any)
pub fn last_sleep_time(&self) -> Option<GameTimeC> {
match self.last_sleep_time.borrow().as_ref()
{
Some(t) => Some(t.clone()),
_ => None
}
}
/// Duration of the last sleep (game hours)
pub fn last_sleep_duration(&self) -> f32 { self.last_sleep_duration.get() }
/// Returns copy of matched clothes group description.
pub fn clothes_group(&self) -> Option<ClothesGroupC> {
match self.clothes_group.borrow().as_ref() {
Some(g) => Some(g.clone()),
_ => None
}
}
/// Returns total 0..100 bonus cold resistance value calculated as a sum of all active clothes
/// cold resistance values plus cold resistance bonus from a matched clothes group, if any.
///
/// ## Note
/// This value is not cached.
pub fn total_cold_resistance(&self) -> usize {
let mut result = 0;
for (_, data) in self.clothes_data.borrow().iter() {
result += data.cold_resistance;
}
match self.clothes_group.borrow().as_ref() {
Some(g) => result += g.bonus_cold_resistance,
_ => { }
}
return result;
}
/// Returns total 0..100 bonus water resistance value calculated as a sum of all active clothes
/// water resistance values plus water resistance bonus from a matched clothes group, if any
///
/// ## Note
/// This value is not cached.
pub fn total_water_resistance(&self) -> usize {
let mut result = 0;
for (_, data) in self.clothes_data.borrow().iter() {
result += data.water_resistance;
}
match self.clothes_group.borrow().as_ref() {
Some(g) => result += g.bonus_water_resistance,
_ => { }
}
return result;
}
}