Mercurial > touhou
changeset 739:01915da33b99
ecl_vm: Let enemies spawn other enemies.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 06 Jan 2020 22:43:31 +0100 |
parents | 817c453b7223 |
children | 8d29dac12219 |
files | src/th06/ecl_vm.rs |
diffstat | 1 files changed, 13 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/th06/ecl_vm.rs +++ b/src/th06/ecl_vm.rs @@ -1,7 +1,7 @@ //! ECL runner. use crate::th06::ecl::{Ecl, SubInstruction}; -use crate::th06::enemy::{Enemy, Offset, BulletAttributes}; +use crate::th06::enemy::{Enemy, Offset, BulletAttributes, Position}; use crate::util::prng::Prng; use std::cell::RefCell; use std::rc::Rc; @@ -776,16 +776,18 @@ impl EclRunner { } // 95 - /* - SubInstruction::PopEnemy(sub, x, y, z, life, bonus_dropped, die_score) => { - self._pop_enemy(sub, 0, self.get_f32(x), - self.get_f32(y), - self.get_f32(z), - life, bonus_dropped, die_score) - + SubInstruction::SpawnEnemy(sub, x, y, z, life, bonus, score) => { + let x = self.get_f32(x); + let y = self.get_f32(y); + let _z = self.get_f32(z); + let enemy = self.enemy.borrow_mut(); + let anm0 = enemy.anm0.upgrade().unwrap(); + let game = enemy.game.upgrade().unwrap(); + let enemy = Enemy::new(Position::new(x, y), life, bonus, score as u32, false, Rc::downgrade(&anm0), Rc::downgrade(&game)); + let ecl = self.ecl.clone().unwrap(); + let mut runner = EclRunner::new(&ecl, enemy, sub as u16); + runner.run_frame(); } - */ - // 96 /* @@ -1287,7 +1289,7 @@ mod tests { use super::*; use crate::th06::anm0::Anm0; use crate::th06::ecl::{Sub, CallSub, Rank}; - use crate::th06::enemy::{Game, Position}; + use crate::th06::enemy::Game; use std::io::{self, Read}; use std::fs::File;