5151# Filters
5252from filters .weapons import WeaponClassIter
5353# Listeners
54- from listeners import OnEntityDeleted
55- from listeners import on_entity_deleted_listener_manager
5654from listeners .tick import Delay
5755from listeners .tick import Repeat
5856from listeners .tick import RepeatStatus
@@ -168,17 +166,6 @@ def cache(cls):
168166 """
169167 return cls ._cache
170168
171- @staticmethod
172- def _invalidate_cache (base_entity ):
173- """Invalidates the cache for the given entity."""
174- try :
175- index = base_entity .index
176- except ValueError :
177- return
178-
179- for cls in _entity_classes :
180- cls .cache .pop (index , None )
181-
182169
183170class Entity (BaseEntity , metaclass = _EntityCaching ):
184171 """Class used to interact directly with entities.
@@ -1245,7 +1232,8 @@ def set_parent(self, parent, attachment=INVALID_ATTACHMENT_INDEX):
12451232# =============================================================================
12461233# >> LISTENERS
12471234# =============================================================================
1248- @OnEntityDeleted
1235+ # NOTE: This callback is called by sp_main.cpp after all registered entity
1236+ # deletion listeners have been called.
12491237def _on_entity_deleted (base_entity ):
12501238 """Called when an entity is removed.
12511239
@@ -1258,22 +1246,20 @@ def _on_entity_deleted(base_entity):
12581246 except ValueError :
12591247 return
12601248
1261- # Get the registered delays for this entity
1262- delays = _entity_delays .pop (index , ())
1263-
12641249 # Loop through all delays...
1265- for delay in delays :
1250+ for delay in _entity_delays . pop ( index , ()) :
12661251
12671252 # Cancel the delay...
12681253 with suppress (ValueError ):
12691254 delay .cancel ()
12701255
1271- # Get the registered repeats for this entity
1272- repeats = _entity_repeats .pop (index , ())
1273-
12741256 # Loop through all repeats...
1275- for repeat in repeats :
1257+ for repeat in _entity_repeats . pop ( index , ()) :
12761258
12771259 # Stop the repeat if running
12781260 if repeat .status is RepeatStatus .RUNNING :
12791261 repeat .stop ()
1262+
1263+ # Invalidate the internal entity caches for this entity
1264+ for cls in _entity_classes :
1265+ cls .cache .pop (index , None )
0 commit comments