veloren/common/src/comp/location.rs
Marcel Märtens c212de00c2 updated dependencies and fixed stuff
- replace serde_derive by feature of serde
   incl. source code modifications to compile
 - reduce futures-timer to "2.0" to be same as async_std
 - update notify
 - removed mio, bincode and lz4 compress in common as networking is now in own crate
   btw there is a better lz4 compress crate, which is newer than 2017
 - update prometheus to 0.9
 - can't update uvth yet due to usues
 - hashbrown to 7.2 to only need a single version
 - libsqlite3 update
 - image didn't change as there is a problem with `image 0.23`
 - switch old directories with newer directories-next
 - no num upgrade as we still depend on num 0.2 anyways
 - rodio and cpal upgrade
 - const-tewaker update
 - dispatch (untested) update
 - git2 update
 - iterations update
2020-07-07 09:43:49 +02:00

40 lines
947 B
Rust

use crate::state::Time;
use serde::{Deserialize, Serialize};
use specs::{Component, FlaggedStorage};
use specs_idvs::IdvStorage;
use vek::*;
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
pub struct Waypoint {
pos: Vec3<f32>,
last_save: Time,
}
impl Waypoint {
pub fn new(pos: Vec3<f32>, last_save: Time) -> Self { Self { pos, last_save } }
pub fn get_pos(&self) -> Vec3<f32> { self.pos }
/// Time in seconds since this waypoint was saved
pub fn elapsed(&self, time: Time) -> f64 { time.0 - self.last_save.0 }
}
impl Component for Waypoint {
type Storage = FlaggedStorage<Self, IdvStorage<Self>>;
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct WaypointArea(f32);
impl WaypointArea {
pub fn radius(&self) -> f32 { self.0 }
}
impl Component for WaypointArea {
type Storage = FlaggedStorage<Self, IdvStorage<Self>>;
}
impl Default for WaypointArea {
fn default() -> Self { Self(5.0) }
}