]> git.mxchange.org Git - city.git/blob - application/city/classes/states/city/init/class_CityInitState.php
Continued:
[city.git] / application / city / classes / states / city / init / class_CityInitState.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\City\State\Init;
4
5 // Import application-specific stuff
6 use Org\Mxchange\City\Factory\State\CityStateFactory;
7 use Org\Mxchange\City\State\BaseCityState;
8
9 // Import framework stuff
10 use Org\Mxchange\CoreFramework\Executor\Executor;
11 use Org\Mxchange\CoreFramework\State\Stateable;
12
13 /**
14  * A init city state class
15  *
16  * @author              Roland Haeder <webmaster@shipsimu.org>
17  * @version             0.0.0
18  * @copyright   Copyright (c) 2015 - 2023 City Developer Team
19  * @license             GNU GPL 3.0 or any newer version
20  * @link                http://www.shipsimu.org
21  *
22  * This program is free software: you can redistribute it and/or modify
23  * it under the terms of the GNU General Public License as published by
24  * the Free Software Foundation, either version 3 of the License, or
25  * (at your option) any later version.
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30  * GNU General Public License for more details.
31  *
32  * You should have received a copy of the GNU General Public License
33  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
34  */
35 class CityInitState extends BaseCityState implements Stateable {
36         /**
37          * Protected constructor
38          *
39          * @return      void
40          */
41         protected function __construct () {
42                 // Call parent constructo
43                 parent::__construct(__CLASS__);
44
45                 // Set state name
46                 $this->setStateName('init');
47         }
48
49         /**
50          * Creates an instance of this class
51          *
52          * @return      $stateInstance  An instance of a Stateable class
53          */
54         public static final function createCityInitState () {
55                 // Get new instance
56                 $stateInstance = new CityInitState();
57
58                 // Return the prepared instance
59                 return $stateInstance;
60         }
61
62         /**
63          * Executes the state with given Executor instance
64          *
65          * @param       $executorInstance       An instance of a Executor class
66          * @return      void
67          */
68         public function executeState (Executor $executorInstance) {
69                 // Initialize the daemon
70                 $executorInstance->initializeDaemon($this);
71         }
72
73         /**
74          * Change the state to 'active' when the city daemon has initialized all
75          * tasks, queues, etc.
76          *
77          * @return      void
78          */
79         public function citySimulationIsActivated () {
80                 // Create the new state instance
81                 CityStateFactory::createCityStateInstanceByName('active');
82         }
83 }