annotate src/th06/enemy.rs @ 657:ff7b6355cdf1

Port the Enemy struct from Python, for now without its methods.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 09 Aug 2019 01:36:47 +0200
parents
children 3a9d82a02c88
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 //! Module providing an Enemy struct, to be changed by EclRunner.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 use crate::th06::anm0::Anm0;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 use crate::th06::anm0_vm::{Sprite, AnmRunner};
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 use crate::th06::interpolator::{Interpolator1, Interpolator2};
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 use crate::util::prng::Prng;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 use std::cell::RefCell;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 use std::collections::HashMap;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 use std::rc::{Rc, Weak};
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 #[derive(Debug, Clone, Copy)]
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 struct Position {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 x: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 y: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17 #[derive(Debug, Clone, Copy)]
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 struct Offset {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 dx: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 dy: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 impl Position {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 pub fn new(x: f32, y: f32) -> Position {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 Position { x, y }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29 impl Offset {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 pub fn new(dx: f32, dy: f32) -> Offset {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 Offset { dx, dy }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 impl std::ops::Add<Offset> for Position {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 type Output = Position;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 fn add(self, offset: Offset) -> Position {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 Position {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 x: self.x + offset.dx,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 y: self.y + offset.dy,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 #[derive(Debug, Clone)]
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 struct Callback;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48 #[derive(Debug, Clone)]
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 struct Laser;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 #[derive(Debug, Clone)]
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 struct Process;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54 struct Game {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 enemies: Vec<Enemy>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 prng: Rc<RefCell<Prng>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
59 /// Common to all elements in game.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60 struct Element {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61 pos: Position,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 removed: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 sprite: Weak<RefCell<Sprite>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64 anmrunner: AnmRunner,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
67 /// The enemy struct, containing everything pertaining to an enemy.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
68 pub struct Enemy {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
69 // Common to all elements in game.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
70 pos: Position,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
71 removed: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
72 sprite: Rc<RefCell<Sprite>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
73 anmrunner: Rc<RefCell<AnmRunner>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75 // Specific to enemy.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76 // Floats.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77 z: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
78 angle: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
79 speed: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
80 rotation_speed: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
81 acceleration: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
82
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
83 // Ints.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
84 type_: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
85 bonus_dropped: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
86 die_score: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
87 frame: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
88 life: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
89 death_flags: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
90 current_laser_id: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
91 low_life_trigger: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
92 timeout: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
93 remaining_lives: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
94 bullet_launch_interval: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
95 bullet_launch_timer: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
96 death_anim: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
97 direction: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98 update_mode: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
99
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
100 // Bools.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101 visible: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
102 was_visible: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103 touchable: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104 collidable: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
105 damageable: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
106 boss: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107 automatic_orientation: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
108 delay_attack: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
109
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
110 // Tuples.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
111 difficulty_coeffs: (f32, f32, u32, u32, u32, u32),
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112 extended_bullet_attributes: Option<(u32, u32, u32, u32, f32, f32, f32, f32)>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113 bullet_attributes: Option<(i16, i16, u32, u32, u32, f32, f32, f32, f32, u32)>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
114 bullet_launch_offset: Offset,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115 movement_dependant_sprites: Option<(f32, f32, f32, f32)>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 screen_box: Option<(f32, f32, f32, f32)>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 // Callbacks.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119 death_callback: Option<Callback>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120 boss_callback: Option<Callback>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121 low_life_callback: Option<Callback>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 timeout_callback: Option<Callback>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
123
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
124 // Laser.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
125 laser_by_id: HashMap<u32, Laser>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
126
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
127 // Options.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
128 options: Vec<Element>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
129
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
130 // Interpolators.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
131 interpolator: Option<Interpolator2<f32>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
132 speed_interpolator: Option<Interpolator1<f32>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
133
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
134 // Misc stuff, do we need them?
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
135 anm0: Weak<RefCell<Anm0>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
136 process: Rc<RefCell<Process>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
137 game: Weak<RefCell<Game>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
138 prng: Weak<RefCell<Prng>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
139 hitbox_half_size: (f32, f32),
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
140 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
141
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
142 impl Enemy {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
143 /// Sets the animation to the one indexed by index in the current anm0.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
144 pub fn set_anim(&mut self, index: u8) {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
145 self.sprite = Rc::new(RefCell::new(Sprite::new()));
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
146 let anm0 = self.anm0.upgrade().unwrap();
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
147 let anmrunner = AnmRunner::new(&*anm0.borrow(), index, self.sprite.clone(), self.prng.clone(), 0);
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
148 self.anmrunner = Rc::new(RefCell::new(anmrunner));
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
149 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
150 }