Fixed leaky abstraction Map - calc_step - Object.

This commit is contained in:
shiva404
2026-03-07 01:25:48 +03:00
parent 5ba8c8b3ab
commit e347eb6fa6
2 changed files with 8 additions and 18 deletions

View File

@@ -138,7 +138,12 @@ class Map:
for j in range(len(self.cells)):
for cell in self.cells[j]:
if cell.creature_obj:
cell.creature_obj.update(time_delta, self.cell_size, self)
cell.creature_obj.walkable_matrix = self.walkable_matrix
cell.creature_obj.rocks_matrix = self.rocks_matrix
if cell.creature_obj.final_goal is not None:
cell.creature_obj.calc_step(time_delta, self.cell_size, self)
continue
cell.creature_obj.update(time_delta)
def compute_walkable_rocks(self):
"""Вычисляет матрицы walkable и rocks_only БЕЗ учета стартовой позиции"""

View File

@@ -163,29 +163,16 @@ class Creature(Object):
# action/task_counter = 0
#clear goal/wp
def update(self, time_delta, cell_size, map_obj):
self.walkable_matrix = map_obj.walkable_matrix
self.rocks_matrix = map_obj.rocks_matrix
def update(self, time_delta):
#quick_actions? here?
#print(self.waypoints, self.final_goal, self.action_counter, self.task_counter)
if self.final_goal is not None:
#print(2)
self.calc_step(time_delta, cell_size, map_obj)
return
if self.interrupt_task and self.interrupt_action_status == "completed":
#print(3)
self.action_time = 0.0
self.action = self.interrupt_task.pop(0)
self.interrupt_action_status = "active"
#print(f" DEBUG: tasks={len(self.tasks)}, "
# f"task_len={len(self.tasks[self.task_counter]) if self.tasks else 0}, "
# f"action={self.action is not None}")
if self.action:
#print(self.action_counter, self.task_counter)
self.action_time += time_delta
self.action.progress = min(1.0, self.action_time / self.action.duration)
@@ -197,9 +184,7 @@ class Creature(Object):
self.action = None
self.action_time = 0.0
elif self.tasks:
#print(6)
if self.action_counter < len(self.tasks[self.task_counter]):
self.action = self.tasks[self.task_counter][self.action_counter]
self.action_counter += 1
@@ -213,7 +198,7 @@ class Creature(Object):
self.action_counter += 1
self.action_time = 0.0
# possibly shorther version of a code above, need to test
#elif self.tasks:
# if self.action_counter >= len(self.tasks[self.task_counter]):
# self.task_counter += 1