# HG changeset patch # User Emmanuel Gil Peyrot # Date 1566043499 -7200 # Node ID eecb8626f472e859fc48477e3f8b18ddf212cbbc # Parent 482d81f50a1150fbe44ecd954ae8afbb5215628c ecl_vm: implement SetBulletLaunchOffset. diff --git a/src/th06/ecl_vm.rs b/src/th06/ecl_vm.rs --- 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, BulletAttributes}; +use crate::th06::enemy::{Enemy, BulletAttributes, Offset}; use crate::util::prng::Prng; use std::cell::RefCell; use std::rc::Rc; @@ -513,15 +513,17 @@ impl EclRunner { } // 47 SubInstruction::SetSpeed(speed) => { + let speed = self.get_f32(speed); let mut enemy = self.enemy.borrow_mut(); enemy.update_mode = 0; - enemy.speed = self.get_f32(speed); + enemy.speed = speed; } // 48 SubInstruction::SetAcceleration(acceleration) => { + let acceleration = self.get_f32(acceleration); let mut enemy = self.enemy.borrow_mut(); enemy.update_mode = 0; - enemy.acceleration = self.get_f32(acceleration); + enemy.acceleration = acceleration; } // 49 SubInstruction::SetRandomAngle(min_angle, max_angle) => { @@ -643,13 +645,14 @@ impl EclRunner { enemy.fire(bullet_attributes=bullet_attributes) } */ + // 81 - /* - SubInstruction::SetBulletLaunchOffset(x, y, z) => { + SubInstruction::SetBulletLaunchOffset(dx, dy, dz) => { + let (dx, dy, dz) = (self.get_f32(dx), self.get_f32(dy), self.get_f32(dz)); let mut enemy = self.enemy.borrow_mut(); - enemy.bullet_launch_offset = (self._getval(x), self._getval(y), self._getval(z)); + enemy.bullet_offset = Offset { dx, dy }; } - */ + // 82 // TODO: correct but how to implement that in a rusty way? /* diff --git a/src/th06/enemy.rs b/src/th06/enemy.rs --- a/src/th06/enemy.rs +++ b/src/th06/enemy.rs @@ -19,8 +19,8 @@ pub struct Position { /// An offset which can be added to a Position. #[derive(Debug, Clone, Copy, Default, PartialEq)] pub struct Offset { - dx: f32, - dy: f32, + pub(crate) dx: f32, + pub(crate) dy: f32, } impl Position {