blob: f69feccbb1fbc7806b2f90de65d87dfd023dcc8a (
plain) (
blame)
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
|
use gdnative::api::*;
use gdnative::prelude::*;
use crate::buff_trait::Buff;
pub struct BuffPhase {
name: String,
description: String,
rigid_body: Box<Ref<RigidBody>>,
wall_layer_bit: i64,
}
impl BuffPhase {
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);
BuffPhase {
name: String::from("Phase"),
description: String::from("Phases through thin fences"),
rigid_body,
wall_layer_bit: mask_bit,
}
}
}
impl Buff for BuffPhase {
unsafe fn execute_buff(&mut self) {
// 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) {
self.rigid_body.assume_safe().set_collision_mask_bit(self.wall_layer_bit, false);
}
fn get_name(self) -> GodotString {
GodotString::from_str(self.name)
}
fn get_description(self) -> GodotString {
GodotString::from_str(self.description)
}
}
|