aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/buff_phase.rs
diff options
context:
space:
mode:
authorLibravatar David <david003@gmx.net>2022-07-16 20:38:58 +0200
committerLibravatar David <david003@gmx.net>2022-07-16 20:38:58 +0200
commitd1bac1c41a75fdf901e1f7c5f604783f0685190a (patch)
tree6230dbb9c0526a5efe00f81971acb2697f87c6fb /rust/src/buff_phase.rs
parent717a665a84dd9ca1b545d57976b87ba77bf11d80 (diff)
download2022-d1bac1c41a75fdf901e1f7c5f604783f0685190a.tar.gz
2022-d1bac1c41a75fdf901e1f7c5f604783f0685190a.tar.bz2
2022-d1bac1c41a75fdf901e1f7c5f604783f0685190a.zip
make buffs work
Diffstat (limited to 'rust/src/buff_phase.rs')
-rw-r--r--rust/src/buff_phase.rs27
1 files changed, 6 insertions, 21 deletions
diff --git a/rust/src/buff_phase.rs b/rust/src/buff_phase.rs
index e64508e..f69fecc 100644
--- a/rust/src/buff_phase.rs
+++ b/rust/src/buff_phase.rs
@@ -2,16 +2,16 @@ use gdnative::api::*;
use gdnative::prelude::*;
use crate::buff_trait::Buff;
-struct BuffPhase {
+pub struct BuffPhase {
name: String,
description: String,
- rigid_body: Option<Ref<RigidBody>>,
+ rigid_body: Box<Ref<RigidBody>>,
wall_layer_bit: i64,
}
impl BuffPhase {
- fn new(rigid_body: Option<Ref<RigidBody>>) -> Self {
+ pub fn new(rigid_body: Box<Ref<RigidBody>>) -> Self {
// calculate the bit for the mask to enable/ disable collision detection
let mask_layer = 2;
let mask_bit = 2_i64.pow(mask_layer - 1);
@@ -20,7 +20,6 @@ impl BuffPhase {
name: String::from("Phase"),
description: String::from("Phases through thin fences"),
rigid_body,
-
wall_layer_bit: mask_bit,
}
}
@@ -28,26 +27,12 @@ impl BuffPhase {
impl Buff for BuffPhase {
unsafe fn execute_buff(&mut self) {
- match &self.rigid_body {
- Some(body) => {
- // actually disable the collision to the fences
- let save_body = body.assume_safe();
- save_body.set_collision_mask_bit(self.wall_layer_bit, false);
- },
- None => godot_warn!("Rigid body not found")
- }
+ // actually disable the collision to the fences
+ self.rigid_body.assume_safe().set_collision_mask_bit(self.wall_layer_bit, false);
}
unsafe fn revert_buff(& mut self) {
- // make sure the rigid body exists
- match &self.rigid_body {
- Some(body) => {
- // actually enable the collision again
- let save_body = body.assume_safe();
- save_body.set_collision_mask_bit(self.wall_layer_bit, false);
- },
- None => godot_warn!("Rigid body not found")
- }
+ self.rigid_body.assume_safe().set_collision_mask_bit(self.wall_layer_bit, false);
}
fn get_name(self) -> GodotString {