changeset 157:ca6f8b3f739d

Remove half of the new_enemy/pop_enemy mess.
author Thibaut Girka <thib@sitedethib.com>
date Mon, 10 Oct 2011 18:42:02 +0200
parents ebfd328e700c
children 7769ce7be03c
files pytouhou/game/game.py pytouhou/vm/eclrunner.py
diffstat 2 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/game.py
+++ b/pytouhou/game/game.py
@@ -48,7 +48,7 @@ class Game(object):
         self.enm_anm_wrapper = resource_loader.get_anm_wrapper2(('stg%denm.anm' % stage,
                                                                  'stg%denm2.anm' % stage))
         ecl = resource_loader.get_ecl('ecldata%d.ecl' % stage)
-        self.ecl_runner = ECLMainRunner(ecl, self.new_enemy, self)
+        self.ecl_runner = ECLMainRunner(ecl, self)
 
 
     def drop_bonus(self, x, y, _type):
--- a/pytouhou/vm/eclrunner.py
+++ b/pytouhou/vm/eclrunner.py
@@ -25,12 +25,11 @@ logger = get_logger(__name__)
 
 class ECLMainRunner(object):
     __metaclass__ = MetaRegistry
-    __slots__ = ('_ecl', '_new_enemy_func', '_game', 'processes',
+    __slots__ = ('_ecl', '_game', 'processes',
                  'instruction_pointer')
 
-    def __init__(self, ecl, new_enemy_func, game):
+    def __init__(self, ecl, game):
         self._ecl = ecl
-        self._new_enemy_func = new_enemy_func
         self._game = game
 
         self.processes = []
@@ -70,7 +69,7 @@ class ECLMainRunner(object):
                 y = self._game.prng.rand_double() * 416
             if z < -990: #102h.exe@0x411881
                 y = self._game.prng.rand_double() * 800
-        enemy = self._new_enemy_func((x, y), life, instr_type, bonus_dropped, self._pop_enemy)
+        enemy = self._game.new_enemy((x, y), life, instr_type, bonus_dropped, self._pop_enemy)
         process = ECLRunner(self._ecl, sub, enemy, self._game)
         self.processes.append(process)
         process.run_iteration()