class_name Plan const TURN_TIME : float = 5.0 var elements = [] # All elements of the plan thus far var current_elements = [] # All elements of the next 5 seconds func current_time() -> float: var total_time : float = 0.0 for current_element in current_elements: var _element : PlanElement = (current_element as PlanElement) total_time += _element.time return total_time func add_element(element : PlanElement) -> bool: var total_time : float = self.current_time() if total_time + element.time > TURN_TIME: return false current_elements.append(element) return true func remove_last_element() -> void: current_elements.pop_back() func remove_all_elements() -> void: current_elements.clear() func new_turn() -> void: for i in range(len(current_elements)): elements.push_back(current_elements.pop_front()) func sanity_check() -> bool: # Returns true if sane and false if insane var total_time : float = 0.0 for current_element in current_elements: var element : PlanElement = (current_element as PlanElement) total_time += element.time if !element.sanity_check(): return false if total_time > TURN_TIME: return false return true