equal
deleted
inserted
replaced
9 LandGenerator, |
9 LandGenerator, |
10 }; |
10 }; |
11 use lfprng::LaggedFibonacciPRNG; |
11 use lfprng::LaggedFibonacciPRNG; |
12 use mapgen::{theme::Theme, MapGenerator}; |
12 use mapgen::{theme::Theme, MapGenerator}; |
13 use std::fs; |
13 use std::fs; |
|
14 use std::ptr::slice_from_raw_parts; |
14 use std::{ffi::CStr, path::Path}; |
15 use std::{ffi::CStr, path::Path}; |
15 use std::ptr::slice_from_raw_parts; |
|
16 |
16 |
17 #[repr(C)] |
17 #[repr(C)] |
18 pub struct GameField { |
18 pub struct GameField { |
19 collision: land2d::Land2D<u16>, |
19 collision: land2d::Land2D<u16>, |
20 pixels: land2d::Land2D<u32>, |
20 pixels: land2d::Land2D<u32>, |
255 pub extern "C" fn ai_clear_team(ai: &mut AI) { |
255 pub extern "C" fn ai_clear_team(ai: &mut AI) { |
256 *ai.get_team_mut() = vec![]; |
256 *ai.get_team_mut() = vec![]; |
257 } |
257 } |
258 |
258 |
259 #[no_mangle] |
259 #[no_mangle] |
260 pub unsafe extern "C" fn ai_add_team_hedgehog(ai: &mut AI, x: f32, y: f32, ammo_counts: *const u32) { |
260 pub unsafe extern "C" fn ai_add_team_hedgehog( |
261 let ammo_counts = &*slice_from_raw_parts(ammo_counts, crate::ai::ammo::AmmoType::Count as usize); |
261 ai: &mut AI, |
|
262 x: f32, |
|
263 y: f32, |
|
264 ammo_counts: *const u32, |
|
265 ) { |
|
266 let ammo_counts = |
|
267 &*slice_from_raw_parts(ammo_counts, crate::ai::ammo::AmmoType::Count as usize); |
262 let ammo_counts = std::array::from_fn(|i| ammo_counts[i].clone()); |
268 let ammo_counts = std::array::from_fn(|i| ammo_counts[i].clone()); |
263 |
269 |
264 ai.get_team_mut().push(Hedgehog { x, y, ammo: ammo_counts }); |
270 ai.get_team_mut().push(Hedgehog { |
|
271 x, |
|
272 y, |
|
273 ammo: ammo_counts, |
|
274 }); |
265 } |
275 } |
266 |
276 |
267 #[no_mangle] |
277 #[no_mangle] |
268 pub extern "C" fn ai_think(ai: &AI) {} |
278 pub extern "C" fn ai_think(ai: &AI) {} |
269 |
279 |