veloren_common/comp/
location.rs1use crate::{resources::Time, uid::Uid};
2use serde::{Deserialize, Serialize};
3use specs::Component;
4use vek::*;
5
6#[derive(Copy, Clone, Debug)]
7pub struct Waypoint {
8 pos: Vec3<f32>,
9 last_save: Time,
10}
11
12impl Waypoint {
13 pub fn temp_new(pos: Vec3<f32>, last_save: Time) -> Self {
15 Self {
16 pos: pos + Vec3::from(0.25f32).map(|e| e * rand::random::<f32>() - 0.25 / 2.0),
17 last_save,
18 }
19 }
20
21 pub fn new(pos: Vec3<f32>, last_save: Time) -> Self { Self { pos, last_save } }
22
23 pub fn get_pos(&self) -> Vec3<f32> { self.pos }
24
25 pub fn elapsed(&self, time: Time) -> f64 { time.0 - self.last_save.0 }
27}
28
29impl Component for Waypoint {
30 type Storage = specs::VecStorage<Self>;
31}
32
33#[derive(Copy, Clone, Debug, PartialEq)]
34pub struct WaypointArea(f32);
35
36impl WaypointArea {
37 pub fn radius(&self) -> f32 { self.0 }
38}
39
40impl Component for WaypointArea {
41 type Storage = specs::VecStorage<Self>;
42}
43
44impl Default for WaypointArea {
45 fn default() -> Self { Self(5.0) }
46}
47
48#[derive(Copy, Clone, Debug)]
51pub struct MapMarker(pub Vec2<i32>);
52
53impl Component for MapMarker {
54 type Storage = specs::VecStorage<Self>;
55}
56
57#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
58pub enum MapMarkerChange {
59 Update(Vec2<i32>),
60 Remove,
61}
62
63#[derive(Clone, Debug, Serialize, Deserialize)]
64pub enum MapMarkerUpdate {
65 Owned(MapMarkerChange),
66 GroupMember(Uid, MapMarkerChange),
67 ClearGroup,
68}