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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
pub mod messages;
pub mod faction;
pub mod interactable;
pub mod equipment;
pub mod inventory;
pub mod serialise;
pub mod flags;
pub mod ear;
pub use messages::{
AttackMessage,
AttackInbox,
AttackType
};
pub use faction::Faction;
pub use interactable::Interactable;
pub use equipment::Equipment;
pub use inventory::Inventory;
pub use serialise::Serialise;
pub use flags::{
Flag,
Flags
};
pub use ear::{
Notification,
Ear
};
use specs::{
DenseVecStorage,
VecStorage,
HashMapStorage,
NullStorage,
Component,
Entity
};
use crate::{
Pos,
PlayerId,
RoomId,
Sprite,
controls::Control,
Template,
playerstate::RoomPos,
Timestamp,
ItemId,
};
#[derive(Component, Debug, Clone)]
#[storage(VecStorage)]
pub struct Position{
pub pos: Pos
}
impl Position {
pub fn new(pos: Pos) -> Position {
Position{pos}
}
}
#[derive(Component, Debug, Clone)]
#[storage(VecStorage)]
pub struct Visible {
pub sprite: Sprite,
pub height: f64,
pub name: String
}
#[derive(Component, Debug)]
pub struct Controller {
pub control: Control
}
#[derive(Default, Component, Debug, Clone)]
pub struct Movable {
pub cooldown: i64
}
#[derive(Default, Component, Debug, Clone)]
#[storage(NullStorage)]
pub struct New;
#[derive(Default, Component, Debug, Clone)]
#[storage(NullStorage)]
pub struct Removed;
#[derive(Default, Component, Debug, Clone)]
pub struct Moved {
pub from: Pos
}
#[derive(Default, Component, Debug, Clone)]
#[storage(HashMapStorage)]
pub struct Player {
pub id: PlayerId
}
impl Player {
pub fn new(id: PlayerId) -> Self {
Self{id}
}
}
#[derive(Component, Debug, Clone)]
pub struct Health {
pub health: i64,
pub maxhealth: i64
}
impl Health {
pub fn heal(&mut self, amount: i64) {
self.health += amount;
if self.health > self.maxhealth {
self.health = self.maxhealth;
}
}
}
#[derive(Component, Debug, Clone)]
pub struct RoomExit {
pub destination: RoomId,
pub dest_pos: RoomPos
}
#[derive(Default, Component, Debug, Clone)]
#[storage(NullStorage)]
pub struct Entered;
#[derive(Default, Component, Debug, Clone)]
#[storage(NullStorage)]
pub struct Dead;
#[derive(Component, Debug, Clone)]
#[storage(HashMapStorage)]
pub struct Trap {
pub attack: AttackType
}
#[derive(Component, Debug, Clone)]
#[storage(HashMapStorage)]
pub struct Fighter {
pub attack: AttackType,
pub cooldown: i64,
pub range: i64
}
#[derive(Component, Debug, Clone)]
#[storage(HashMapStorage)]
pub struct Healing {
pub delay: i64,
pub health: i64,
pub next_heal: Option<Timestamp>
}
#[derive(Component, Debug, Clone)]
#[storage(HashMapStorage)]
pub struct Volatile {
pub delay: i64,
pub end_time: Option<Timestamp>
}
#[derive(Component, Debug, Clone)]
#[storage(HashMapStorage)]
pub struct ControlCooldown {
pub amount: i64
}
#[derive(Component, Debug, Clone, Default)]
#[storage(HashMapStorage)]
pub struct Autofight {
pub target: Option<Entity>
}
#[derive(Component, Debug, Clone, Default)]
#[storage(HashMapStorage)]
pub struct MonsterAI {
pub move_chance: f64,
pub homesickness: f64,
pub view_distance: i64
}
#[derive(Component, Debug, Clone, Default)]
#[storage(HashMapStorage)]
pub struct Home {
pub home: Pos
}
#[derive(Component, Debug, Clone, Default)]
pub struct Mortal;
#[derive(Component, Debug, Clone)]
#[storage(HashMapStorage)]
pub struct Spawner {
pub amount: usize,
pub delay: i64,
pub clan: Clan,
pub template: Template,
pub last_spawn: Option<Timestamp>
}
#[derive(Component, Debug, Clone, PartialEq, Eq, Hash)]
#[storage(HashMapStorage)]
pub struct Clan {
pub name: String,
}
#[derive(Component, Debug, Clone)]
#[storage(HashMapStorage)]
pub struct Loot {
pub loot: Vec<(Template, f64)>
}
#[derive(Component, Debug, Clone)]
#[storage(HashMapStorage)]
pub struct Grow {
pub delay: i64,
pub target_time: Option<Timestamp>,
pub into: Template
}
#[derive(Component, Debug, Clone)]
#[storage(HashMapStorage)]
pub struct CreationTime {
pub time: Timestamp
}
#[derive(Component, Debug, Clone)]
pub struct Item(pub ItemId);
|