aboutsummaryrefslogtreecommitdiff
path: root/server/src/entity/environment_effect.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-07-27 13:04:32 +0200
committermetamuffin <metamuffin@disroot.org>2024-07-27 13:04:41 +0200
commit13fb44b129c8bdb263136997300121abbbff4aaf (patch)
tree85c962be6499a0007d0168ece0495d73a1b545c5 /server/src/entity/environment_effect.rs
parent6c76dd801276dd94f2655e0858c42d7e26caf5b8 (diff)
downloadhurrycurry-13fb44b129c8bdb263136997300121abbbff4aaf.tar
hurrycurry-13fb44b129c8bdb263136997300121abbbff4aaf.tar.bz2
hurrycurry-13fb44b129c8bdb263136997300121abbbff4aaf.tar.zst
permanent effects
Diffstat (limited to 'server/src/entity/environment_effect.rs')
-rw-r--r--server/src/entity/environment_effect.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/server/src/entity/environment_effect.rs b/server/src/entity/environment_effect.rs
index dcfc08c1..8888f253 100644
--- a/server/src/entity/environment_effect.rs
+++ b/server/src/entity/environment_effect.rs
@@ -32,7 +32,6 @@ pub struct EnvironmentEffect {
on: f32,
#[serde(default = "default_onoff")]
off: f32,
- exclusive: bool,
}
fn default_onoff() -> f32 {
40.
@@ -70,10 +69,8 @@ impl EntityT for EnvironmentEffectController {
} else {
self.next_transition +=
Duration::from_secs_f32(self.config.off * (0.5 + random::<f32>()));
- if game.environment_effects.is_empty() || !self.config.exclusive {
- self.active = true;
- game.environment_effects.insert(self.config.name.clone());
- }
+ self.active = true;
+ game.environment_effects.insert(self.config.name.clone());
}
packet_out.push_back(PacketC::Environment {
effects: game.environment_effects.clone(),
@@ -82,3 +79,19 @@ impl EntityT for EnvironmentEffectController {
Ok(())
}
}
+
+#[derive(Debug, Clone)]
+pub struct EnvironmentController(pub Vec<String>);
+impl EntityT for EnvironmentController {
+ fn tick(
+ &mut self,
+ game: &mut Game,
+ _packet_out: &mut VecDeque<PacketC>,
+ _dt: f32,
+ ) -> anyhow::Result<()> {
+ if game.environment_effects.is_empty() {
+ game.environment_effects.extend(self.0.clone());
+ }
+ Ok(())
+ }
+}