Fixed leaky abstraction Map - calc_step - Object.
This commit is contained in:
@@ -138,7 +138,12 @@ class Map:
|
|||||||
for j in range(len(self.cells)):
|
for j in range(len(self.cells)):
|
||||||
for cell in self.cells[j]:
|
for cell in self.cells[j]:
|
||||||
if cell.creature_obj:
|
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):
|
def compute_walkable_rocks(self):
|
||||||
"""Вычисляет матрицы walkable и rocks_only БЕЗ учета стартовой позиции"""
|
"""Вычисляет матрицы walkable и rocks_only БЕЗ учета стартовой позиции"""
|
||||||
|
|||||||
@@ -163,29 +163,16 @@ class Creature(Object):
|
|||||||
# action/task_counter = 0
|
# action/task_counter = 0
|
||||||
#clear goal/wp
|
#clear goal/wp
|
||||||
|
|
||||||
def update(self, time_delta, cell_size, map_obj):
|
def update(self, time_delta):
|
||||||
self.walkable_matrix = map_obj.walkable_matrix
|
|
||||||
self.rocks_matrix = map_obj.rocks_matrix
|
|
||||||
|
|
||||||
#quick_actions? here?
|
#quick_actions? here?
|
||||||
#print(self.waypoints, self.final_goal, self.action_counter, self.task_counter)
|
#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":
|
if self.interrupt_task and self.interrupt_action_status == "completed":
|
||||||
#print(3)
|
|
||||||
self.action_time = 0.0
|
self.action_time = 0.0
|
||||||
self.action = self.interrupt_task.pop(0)
|
self.action = self.interrupt_task.pop(0)
|
||||||
self.interrupt_action_status = "active"
|
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:
|
if self.action:
|
||||||
#print(self.action_counter, self.task_counter)
|
|
||||||
self.action_time += time_delta
|
self.action_time += time_delta
|
||||||
self.action.progress = min(1.0, self.action_time / self.action.duration)
|
self.action.progress = min(1.0, self.action_time / self.action.duration)
|
||||||
|
|
||||||
@@ -197,9 +184,7 @@ class Creature(Object):
|
|||||||
self.action = None
|
self.action = None
|
||||||
self.action_time = 0.0
|
self.action_time = 0.0
|
||||||
|
|
||||||
|
|
||||||
elif self.tasks:
|
elif self.tasks:
|
||||||
#print(6)
|
|
||||||
if self.action_counter < len(self.tasks[self.task_counter]):
|
if self.action_counter < len(self.tasks[self.task_counter]):
|
||||||
self.action = self.tasks[self.task_counter][self.action_counter]
|
self.action = self.tasks[self.task_counter][self.action_counter]
|
||||||
self.action_counter += 1
|
self.action_counter += 1
|
||||||
@@ -213,7 +198,7 @@ class Creature(Object):
|
|||||||
self.action_counter += 1
|
self.action_counter += 1
|
||||||
self.action_time = 0.0
|
self.action_time = 0.0
|
||||||
|
|
||||||
|
# possibly shorther version of a code above, need to test
|
||||||
#elif self.tasks:
|
#elif self.tasks:
|
||||||
# if self.action_counter >= len(self.tasks[self.task_counter]):
|
# if self.action_counter >= len(self.tasks[self.task_counter]):
|
||||||
# self.task_counter += 1
|
# self.task_counter += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user