From f7d6f689fb54a60c83417def4e12f7f8ee9f9b41 Mon Sep 17 00:00:00 2001 From: NewSoupVi <57900059+NewSoupVi@users.noreply.github.com> Date: Sat, 21 Sep 2024 19:00:57 +0200 Subject: [PATCH] Update world api.md --- docs/world api.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/world api.md b/docs/world api.md index 1d094c58b3..3d488ac211 100644 --- a/docs/world api.md +++ b/docs/world api.md @@ -736,17 +736,17 @@ def remove(self, state: CollectionState, item: Item) -> bool: return change ``` -Using LogicMixin can slow down your code by a lot if you don't use it intelligently. +Using LogicMixin can slow down your code by a lot if you don't use it intelligently. For example, you can make use of the fact that `collect` should only unlock things, and `remove` should only lock things. -In our example, we have two different functions: `get_newly_unlocked_enemies` and `get_newly_locked_enemies`. +In our example, we have two different functions: `get_newly_unlocked_enemies` and `get_newly_locked_enemies`. `get_newly_unlocked_enemies` should only consider enemies that are *not already in the set* -and check whether they were **unlocked**. +and check whether they were **unlocked**. `get_newly_locked_enemies` should only consider enemies that are *already in the set* and check whether they **became locked**. There are a multitude of other ways you can optimise LogicMixin. Some games use a `mygame_state_is_stale` -variable that they simply initialize as True, and set to True in collect/remove. +variable that they simply initialize as True, and set to True in collect/remove. The calls to the actual recalculating functions are then moved to the start of the relevant access rules like this: ```python