fa7ea9f4f3
* ServerUIPropertiesMenu for Configurator to edit builtin UIProperties of MP * fixed unregister-functions of CallbackManager * Reducing menuItemHeight in Configurator to avoid overlapping of the menu items * Fully rebuild the admins menu after a player rights changed * Added function to FileUtil to improve realpath, so symbolic links can be resolved * Fixed indentation * Update FileUtil.php Fixed error in case of an absolute path on Unix-like systems. * New CallQueue which runs once inbetween the MC-loops * Added important queued call to be executed earlier * ErrorMethod made optional, as in some cases, there might be nothing to fail * Clean up repository from unnecessary files * Added easy installation script for DB on Unix-like systems * Replaced deprecated is_real by is_float * Add milliseconds with dot instead of double colon * Resolved deprecated curly braces error * gitignore all hidden files (except git and gitignore) * Update MC-update-check-interval, so that a restart is not required * Update gitignore to not ignore changes in MCTeam-Plugins * Update gitignore again * And another try * fixed MasterAdmin //delrec, added personal /delrec-command with permission-setting * Increase version number of local records plugin * Add Permission to delete any record * Reworked notifications of locals, removed private only, added private at rank * Fix formatting * Allow AuthenticationManager to store Plugin Permissions * Method to check, if a named function call is already queued * Added command disable feature * Reset timer if DeltaTime updated, so it does not try to catch up missed timings * Added private notification setting * To reduce load of multiple records (especially in rounds), queue call chat notifications * Added internal function to plugin manager to return plugin menu * restore .idea codestyle files * Update MC-Version number to 0.250
86 lines
2.0 KiB
PHP
86 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace ManiaControl\Callbacks;
|
|
|
|
use ManiaControl\General\UsageInformationAble;
|
|
use ManiaControl\General\UsageInformationTrait;
|
|
|
|
/**
|
|
* Model Class for a Timer Listening
|
|
*
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
|
* @copyright 2014-2020 ManiaControl Team
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
|
*/
|
|
class TimerListening extends Listening implements UsageInformationAble {
|
|
use UsageInformationTrait;
|
|
|
|
/*
|
|
* Public Properties
|
|
*/
|
|
public $deltaTime = null;
|
|
public $oneTime = null;
|
|
public $lastTrigger = null;
|
|
public $instantCall = null;
|
|
|
|
/**
|
|
* Construct a new Timer Listening
|
|
*
|
|
* @param TimerListener $listener
|
|
* @param mixed $method
|
|
* @param float $milliSeconds
|
|
* @param bool $oneTime
|
|
* @param bool $instantCall
|
|
*/
|
|
public function __construct(TimerListener $listener, $method, $milliSeconds, $oneTime = false, $instantCall = true) {
|
|
parent::__construct($listener, $method);
|
|
|
|
$this->deltaTime = $milliSeconds / 1000.;
|
|
$this->oneTime = (bool) $oneTime;
|
|
if ($this->oneTime) {
|
|
$this->lastTrigger = microtime(true); //TODO verify before here was time()
|
|
}
|
|
$this->instantCall = (bool) $instantCall;
|
|
if (!$this->instantCall) {
|
|
$this->lastTrigger = microtime(true);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Increase last Trigger Time
|
|
*/
|
|
public function tick() {
|
|
if ($this->lastTrigger === null) {
|
|
$this->lastTrigger = microtime(true);
|
|
} else {
|
|
$this->lastTrigger += $this->deltaTime;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Set the deltaTime
|
|
*
|
|
* @param float $milliSeconds
|
|
*/
|
|
public function setDeltaTime($milliSeconds) {
|
|
$this->deltaTime = $milliSeconds / 1000.;
|
|
$this->lastTrigger = null;
|
|
}
|
|
|
|
/**
|
|
* Check if the desired Time is reached
|
|
*
|
|
* @param float $time
|
|
* @return bool
|
|
*/
|
|
public function isTimeReached($time = null) {
|
|
if ($this->lastTrigger === null) {
|
|
return true;
|
|
}
|
|
if (!$time) {
|
|
$time = microtime(true);
|
|
}
|
|
return ($this->lastTrigger + $this->deltaTime <= $time);
|
|
}
|
|
}
|