@@ -374,10 +374,11 @@ def get_model(self):
374
374
``None`` if the entity has no model.
375
375
:rtype: Model
376
376
"""
377
- if not self .model_name :
377
+ model_name = self .model_name
378
+ if not model_name :
378
379
return None
379
380
380
- return Model (self . model_name )
381
+ return Model (model_name )
381
382
382
383
def set_model (self , model ):
383
384
"""Set the entity's model to the given model.
@@ -449,18 +450,21 @@ def delay(
449
450
The delay instance.
450
451
:rtype: Delay
451
452
"""
453
+ # Get the index of the entity
454
+ index = self .index
455
+
452
456
# TODO: Ideally, we want to subclass Delay and cleanup on cancel() too
453
457
# in case the caller manually cancel the returned Delay.
454
458
def _callback (* args , ** kwargs ):
455
459
"""Called when the delay is executed."""
456
460
# Remove the delay from the global dictionary...
457
- _entity_delays [self . index ].remove (delay )
461
+ _entity_delays [index ].remove (delay )
458
462
459
463
# Was this the last pending delay for the entity?
460
- if not _entity_delays [self . index ]:
464
+ if not _entity_delays [index ]:
461
465
462
466
# Remove the entity from the dictionary...
463
- del _entity_delays [self . index ]
467
+ del _entity_delays [index ]
464
468
465
469
# Call the callback...
466
470
callback (* args , ** kwargs )
@@ -469,7 +473,7 @@ def _callback(*args, **kwargs):
469
473
delay = Delay (delay , _callback , args , kwargs , cancel_on_level_end )
470
474
471
475
# Add the delay to the dictionary...
472
- _entity_delays [self . index ].add (delay )
476
+ _entity_delays [index ].add (delay )
473
477
474
478
# Return the delay instance...
475
479
return delay
@@ -610,8 +614,11 @@ def is_in_solid(
610
614
:class:`BaseEntity` instances that are ignored by the ray.
611
615
:rtype: bool
612
616
"""
617
+ # Get the entity's origin
618
+ origin = self .origin
619
+
613
620
# Get a Ray object of the entity physic box
614
- ray = Ray (self . origin , self . origin , self .mins , self .maxs )
621
+ ray = Ray (origin , origin , self .mins , self .maxs )
615
622
616
623
# Get a new GameTrace instance
617
624
trace = GameTrace ()
0 commit comments