From 53df7353e5c5dbb041f66eabc430610e3c0a18eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Fri, 9 May 2014 13:19:57 +0200 Subject: [PATCH] let timer listenings be called right after start --- application/core/Callbacks/TimerListening.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/application/core/Callbacks/TimerListening.php b/application/core/Callbacks/TimerListening.php index 3c211406..fbb12bcb 100644 --- a/application/core/Callbacks/TimerListening.php +++ b/application/core/Callbacks/TimerListening.php @@ -18,6 +18,7 @@ class TimerListening { public $deltaTime = null; public $oneTime = null; public $lastTrigger = null; + public $instantCall = null; /** * Construct a new Timer Listening @@ -25,13 +26,17 @@ class TimerListening { * @param TimerListener $listener * @param string $method * @param float $deltaTime + * @param bool $instantCall */ - public function __construct(TimerListener $listener, $method, $deltaTime, $oneTime = false) { + public function __construct(TimerListener $listener, $method, $deltaTime, $oneTime = false, $instantCall = true) { $this->listener = $listener; $this->method = $method; $this->deltaTime = $deltaTime / 1000.; - $this->lastTrigger = microtime(true); $this->oneTime = (bool)$oneTime; + $this->instantCall = (bool)$instantCall; + if (!$this->instantCall) { + $this->lastTrigger = microtime(true); + } } /** @@ -69,6 +74,9 @@ class TimerListening { * @return bool */ public function isTimeReached($time = null) { + if ($this->lastTrigger === null) { + return true; + } if (!$time) { $time = microtime(true); }