Skip to content
Snippets Groups Projects
Commit df5b36ff authored by Florian Schröder's avatar Florian Schröder
Browse files

Optimize conveyor effect progression handling.

Introduced the `CONVEYER_SMOOTH` flag to allow smoother progression for objects on conveyors with different orientations. Adjusted the maximum progress value dynamically based on conveyor configurations to improve accuracy and realism.
parent 38924240
No related branches found
No related tags found
1 merge request!116Resolve "New game content"
Pipeline #77054 passed
......@@ -24,12 +24,11 @@ from cooperative_cuisine.items import (
)
from cooperative_cuisine.utils import get_touching_counters, find_item_on_counters
if TYPE_CHECKING:
from cooperative_cuisine.counters import Counter, Conveyer
from cooperative_cuisine.counters import Counter, Conveyer
# the effect class is located in the items.py
CONVEYER_SMOOTH = True # if False, then objects are on "edge" countern accurate but do jumps
class EffectManager:
"""The EffectManager class is responsible for managing effects in an environment.
......@@ -275,11 +274,18 @@ class ConveyerManager(EffectManager):
self.new_effects = []
delete_effects = []
for i, (effect, target) in enumerate(self.active_effects):
effect.progres_percentage = min(1.0, effect.progres_percentage + passed_time.total_seconds() / effect.item_info.seconds)
max_value = 1.0
if CONVEYER_SMOOTH and target.uuid in self.next_counter:
next_counter = self.next_counter[target.uuid]
if isinstance(next_counter, Conveyer) and not np.isclose(np.linalg.norm(next_counter.orientation - target.orientation), 0):
max_value = 1.5
effect.progres_percentage = min(max_value, effect.progres_percentage + passed_time.total_seconds() / effect.item_info.seconds)
if effect.inverse_progress and effect.progres_percentage >= 0.5:
effect.inverse_progress = False
if effect.progres_percentage >= 1.0:
if effect.progres_percentage >= max_value:
if target.uuid in self.next_counter:
next_counter = self.next_counter[target.uuid]
on_new_counter = target.item_to_next_counter(effect.uuid[:-1], next_counter, self.effect_to_player.get(effect.uuid, "0") )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment