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
100
101
102
103
104
105
106
107
108
109
use sys;
use get_api;
use Variant;
use GodotType;
use VariantArray;
use Vector2;
use std::mem::transmute;
pub struct Vector2Array(pub(crate) sys::godot_pool_vector2_array);
impl Vector2Array {
pub fn new() -> Self { Vector2Array::default() }
pub fn from_variant_array(array: &VariantArray) -> Self {
unsafe {
let mut result = sys::godot_pool_vector2_array::default();
(get_api().godot_pool_vector2_array_new_with_array)(&mut result, &array.0);
Vector2Array(result)
}
}
pub fn push(&mut self, vector: &Vector2) {
unsafe {
(get_api().godot_pool_vector2_array_append)(&mut self.0, transmute(vector));
}
}
pub fn push_array(&mut self, vectors: &Vector2Array) {
unsafe {
(get_api().godot_pool_vector2_array_append_array)(&mut self.0, transmute(vectors));
}
}
pub fn insert(&mut self, offset: i32, vector: &Vector2) -> bool {
unsafe {
let status = (get_api().godot_pool_vector2_array_insert)(&mut self.0, offset, transmute(vector));
status != sys::godot_error::GODOT_OK
}
}
pub fn invert(&mut self) {
unsafe {
(get_api().godot_pool_vector2_array_invert)(&mut self.0)
}
}
pub fn remove(&mut self, idx: i32) {
unsafe {
(get_api().godot_pool_vector2_array_remove)(&mut self.0, idx);
}
}
pub fn resize(&mut self, size: i32) {
unsafe {
(get_api().godot_pool_vector2_array_resize)(&mut self.0, size);
}
}
pub fn get(&self, idx: i32) -> Vector2 {
unsafe {
transmute((get_api().godot_pool_vector2_array_get)(&self.0, idx))
}
}
pub fn set(&mut self, idx: i32, vector: &Vector2) {
unsafe {
(get_api().godot_pool_vector2_array_set)(&mut self.0, idx, transmute(vector));
}
}
pub fn len(&self) -> i32 {
unsafe {
(get_api().godot_pool_vector2_array_size)(&self.0)
}
}
impl_common_methods! {
pub fn new_ref(&self) -> Vector2Array : godot_pool_vector2_array_new_copy;
}
}
impl_basic_traits!(
for Vector2Array as godot_pool_vector2_array {
Drop => godot_pool_vector2_array_destroy;
Default => godot_pool_vector2_array_new;
}
);
impl GodotType for Vector2Array {
fn to_variant(&self) -> Variant { Variant::from_vector2_array(self) }
fn from_variant(variant: &Variant) -> Option<Self> { variant.try_to_vector2_array() }
}