|
|
@@ -32,6 +32,8 @@ const YEAR: i32 = MONTH*12;
|
|
|
const KG: f32 = 1.0;
|
|
|
const TON: f32 = KG*1000.0;
|
|
|
|
|
|
+
|
|
|
+// Diet types a lifeform could have
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
enum Diets {
|
|
|
Carnivore,
|
|
|
@@ -40,6 +42,7 @@ enum Diets {
|
|
|
Photovore
|
|
|
}
|
|
|
|
|
|
+// The types of lifeforms that may exist
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
enum LifeformKind {
|
|
|
Fauna,
|
|
|
@@ -56,6 +59,12 @@ struct Biome {
|
|
|
}
|
|
|
|
|
|
|
|
|
+/*
|
|
|
+Biome - a container for lifeforms.
|
|
|
+Ideally, I wanted to have next to no logic here, but I realized my lifeforms needed access to the biome,
|
|
|
+for example to re-deposit their weight back on death, to query for food, etc. I'd like to pass this to a
|
|
|
+lifeform so it can access it and modify it.
|
|
|
+*/
|
|
|
impl Biome {
|
|
|
fn tick(&mut self){
|
|
|
|
|
|
@@ -76,36 +85,32 @@ impl Biome {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- // fn lf_move(&mut self, mut lf: &Lifeform) {
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // fn lf_eat(&mut self) {
|
|
|
- // for lf in self.lifeforms {
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
struct Lifeform {
|
|
|
- name: String,
|
|
|
- mass: f32,
|
|
|
- age: i32,
|
|
|
- maxage: i32,
|
|
|
- water_intake: f32,
|
|
|
- nutrient_intake: f32,
|
|
|
- diet: Diets,
|
|
|
- kind: LifeformKind,
|
|
|
- alive: bool,
|
|
|
- position: Vec<f32>,
|
|
|
- speed: f32,
|
|
|
+ name: String, //just for fun
|
|
|
+ mass: f32, //how much it weights
|
|
|
+ age: i32, //age in ticks
|
|
|
+ maxage: i32, //maximum age
|
|
|
+ water_intake: f32, //how much water it consumes per tick
|
|
|
+ nutrient_intake: f32, //how much food it consumes per tick
|
|
|
+ diet: Diets, //the type of stuff it eats
|
|
|
+ kind: LifeformKind, //the kind of lifeform it is
|
|
|
+ alive: bool, //whether it lives or not
|
|
|
+ position: Vec<f32>, //where it hangs out
|
|
|
+ speed: f32, //how fast it can move (or not)
|
|
|
}
|
|
|
|
|
|
|
|
|
// TODO: add position
|
|
|
impl Lifeform {
|
|
|
+
|
|
|
+ /*
|
|
|
+ Here is what the lifeform 'does' per tick. It consumes food, gains weight...
|
|
|
+ i would like to be able to pass the biome to the lifeform as a reference to that
|
|
|
+ it could interact with it.
|
|
|
+ */
|
|
|
fn tick(&mut self){
|
|
|
if self.alive {
|
|
|
self.mass += self.nutrient_intake;
|