Skip to content

Tick Repeat/Delay updates #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Dec 4, 2016
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated Entity.delay for upcoming changes.
  • Loading branch information
L'In20Cible committed Oct 23, 2016
commit 8c66dc2c26075e362ff990584497cc3ca2a05d98
15 changes: 10 additions & 5 deletions addons/source-python/packages/source-python/entities/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,21 +484,26 @@ def _set_property(self, name, prop_type, value):
'Property "{0}" not found for entity type "{1}"'.format(
name, self.classname))

def delay(self, delay, callback, *args, **kwargs):
def delay(
self, delay, callback, args=(), kwargs=None,
cancel_on_level_end=False):
"""Execute a callback after the given delay.

:param int delay: The delay in seconds.
:param float delay: The delay in seconds.
:param callback: A callable object that should be called after the
delay expired.
:param args: Arguments that should be passed to the callback.
:param kwargs: Keyword arguments that should be passed to the
:param tuple args: Arguments that should be passed to the callback.
:param dict kwargs: Keyword arguments that should be passed to the
callback.
:param bool cancel_on_level_end: Whether or not to cancel the delay at
the end of the map.
:raises ValueError: If the given callback is not callable.

:return: The delay instance.
:rtype: Delay
"""
# Get the delay instance...
delay = Delay(delay, callback, *args, **kwargs)
delay = Delay(delay, callback, args, kwargs, cancel_on_level_end)

# Add the delay to the dictionary...
_entity_delays[self.index].add(delay)
Expand Down