# HG changeset patch # User Thibaut Girka # Date 1315150485 -7200 # Node ID d167280a82fc6a359567d1f42cbd4a0f1fecc5c7 # Parent 85f3b8ba3f246b56f14f7cc73fc7e731a3696968 Handle timeout callbacks, and clean up unneeded things diff --git a/pytouhou/game/enemymanager.py b/pytouhou/game/enemymanager.py --- a/pytouhou/game/enemymanager.py +++ b/pytouhou/game/enemymanager.py @@ -271,7 +271,6 @@ class EnemyManager(object): self.anm_wrapper = anm_wrapper self.main = [] self.ecl = ecl - self.objects_by_texture = {} self.enemies = [] self.processes = [] self.bullets = [] @@ -297,7 +296,7 @@ class EnemyManager(object): def update(self, frame): if self.main and self.main[0][0] == frame: for sub, instr_type, args in self.main.pop(0)[1]: - if instr_type in (0, 2, 4, 6): # Normal/mirrored enemy + if instr_type in (0, 2, 4, 6) and not self._game_state.boss: x, y, z, life, unknown1, unknown2, unknown3 = args if instr_type & 4: if x < -990: #102h.exe@0x411820 @@ -350,13 +349,3 @@ class EnemyManager(object): if self._game_state.boss and self._game_state.boss._removed: self._game_state.boss = None - #TODO - self.objects_by_texture = {} - self.get_objects_by_texture(self.objects_by_texture) - for key, (nb_vertices, vertices, uvs, colors) in self.objects_by_texture.items(): - nb_vertices = len(vertices) - vertices = pack('f' * (3 * nb_vertices), *chain(*vertices)) - uvs = pack('f' * (2 * nb_vertices), *chain(*uvs)) - colors = pack('B' * (4 * nb_vertices), *chain(*colors)) - self.objects_by_texture[key] = (nb_vertices, vertices, uvs, colors) - diff --git a/pytouhou/vm/eclrunner.py b/pytouhou/vm/eclrunner.py --- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -46,13 +46,27 @@ class ECLRunner(object): self.stack = [] + def handle_callbacks(self): + #TODO + enm = self._enemy + if enm.timeout and enm.frame == enm.timeout: + enm.frame = 0 + if enm.timeout_callback: + self.frame = 0 + self.sub = enm.timeout_callback + self.instruction_pointer = 0 + else: + pass #TODO + #TODO: other callbacks (low life, etc.) + + def run_iteration(self): # First, if enemy is dead, return if self._enemy._removed: return False # Then, check for callbacks - #TODO + self.handle_callbacks() # Now, process script while True: