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
|
/*
Hurry Curry! - a game about cooking
Copyright (C) 2025 Hurry Curry! Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License only.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use hurrycurry_protocol::glam::{IVec2, Vec2};
use serde::{Deserialize, Serialize};
use crate::ItemTileRegistry;
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum EntityDecl {
Conveyor {
from: IVec2,
to: IVec2,
speed: Option<f32>,
},
ItemPortal {
from: IVec2,
to: IVec2,
},
PlayerPortal {
from: Vec2,
to: Vec2,
},
Customers {
scaling_factor: Option<f32>,
},
Map {
name: String,
pos: Vec2,
},
EnvironmentEffect(EnvironmentEffect),
Environment(Vec<String>),
Gate {
condition: GateCondition,
pos: IVec2,
},
Tram {
length: usize,
color: Option<i32>,
points: Vec<Vec2>,
spacing: f32,
smoothing: f32,
},
Book {
pos: IVec2,
},
Pedestrians {
spawn_delay: f32,
spawn_delay_stdev: Option<f32>,
speed: Option<f32>,
points: Vec<Vec2>,
},
}
impl EntityDecl {
pub(crate) fn run_register(&self, reg: &ItemTileRegistry) {
match self {
Self::Gate { .. } => drop(reg.register_tile("fence".into())),
Self::Customers { .. } => drop(reg.register_item("unknown-order".into())),
_ => (),
}
}
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "kebab-case")]
pub enum GateCondition {
All(Vec<GateCondition>),
Any(Vec<GateCondition>),
Stars(String, u8),
}
#[derive(Clone, Debug, Deserialize, Serialize, Default)]
pub struct EnvironmentEffect {
pub name: String,
#[serde(default = "default_onoff")]
pub on: f32,
#[serde(default = "default_onoff")]
pub off: f32,
}
fn default_onoff() -> f32 {
40.
}
|