changeset 698:05e0425a8bc5

ecl_vm: enable SetDeathCallback.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 23 Aug 2019 02:37:21 +0200
parents 600eb0a69b25
children 2a60f12bd5bd
files src/th06/ecl_vm.rs src/th06/enemy.rs
diffstat 2 files changed, 6 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/th06/ecl_vm.rs
+++ b/src/th06/ecl_vm.rs
@@ -883,12 +883,10 @@ impl EclRunner {
                 enemy.death_flags = death_flags;
             }
             // 108
-            /*
             SubInstruction::SetDeathCallback(sub) => {
                 let mut enemy = self.enemy.borrow_mut();
-                enemy.death_callback.enable(self.switch_to_sub, (sub,));
+                enemy.death_callback = Some(sub);
             }
-            */
 
             // 109
             SubInstruction::MemoryWriteInt(value, index) => {
--- a/src/th06/enemy.rs
+++ b/src/th06/enemy.rs
@@ -57,8 +57,7 @@ impl std::ops::Sub<Position> for Positio
     }
 }
 
-#[derive(Debug, Clone)]
-struct Callback;
+type Callback = i32;
 
 #[derive(Debug, Clone)]
 /// XXX
@@ -251,10 +250,10 @@ pub struct Enemy {
     pub(crate) screen_box: Option<(f32, f32, f32, f32)>,
 
     // Callbacks.
-    death_callback: Option<Callback>,
-    boss_callback: Option<Callback>,
-    low_life_callback: Option<Callback>,
-    timeout_callback: Option<Callback>,
+    pub(crate) death_callback: Option<Callback>,
+    pub(crate) boss_callback: Option<Callback>,
+    pub(crate) low_life_callback: Option<Callback>,
+    pub(crate) timeout_callback: Option<Callback>,
 
     // Laser.
     pub(crate) laser_by_id: HashMap<u32, Laser>,