aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/buff_phase.rs
diff options
context:
space:
mode:
authorLibravatar IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com>2022-07-16 21:12:23 +0200
committerLibravatar IcECreAm777 <31211782+IcECreAm777@users.noreply.github.com>2022-07-16 21:12:23 +0200
commit9a750a6688ad923d990d11dc464f783210b50678 (patch)
tree90d7658c5e6173946bfb89c46d2cd43fd3f9bf90 /rust/src/buff_phase.rs
parent9c061b9997d0add3298b1230426dd7332b91420f (diff)
parentf561a1f69d5fda68e0a23ab04f448e9364b2968c (diff)
download2022-9a750a6688ad923d990d11dc464f783210b50678.tar.gz
2022-9a750a6688ad923d990d11dc464f783210b50678.tar.bz2
2022-9a750a6688ad923d990d11dc464f783210b50678.zip
Merge branch 'BuffSystem' into GoalPost
Diffstat (limited to '')
-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 {