-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspace.php
107 lines (96 loc) · 1.79 KB
/
space.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
*
*/
class Space {
/**
* undocumented class variable
*/
private $entities;
private $data;
function __construct() {
if (!is_array($this->entities)) {
$this->entities = array();
}
if (!is_array($this->data)) {
$this->data = array();
}
}
/**
* undocumented function
* @param string $name
* @param string $value
* @return void
**/
public function __set($name, $value) {
if ($value instanceof Entity) {
$this->entities[$name] = $value;
} else {
$this->data[$name] = $value;
}
}
/**
* undocumented function
* @param string $name
* @return void
**/
public function __get($name) {
if (!isset($this->$name)) {
return null;
}
if (array_key_exists($name, $this->entities)) {
return $this->entities[$name];
}
return $this->data[$name];
}
/**
* has an entity already set
*
* @param string $name
* @return void
**/
public function __isset($name) {
if (array_key_exists($name, $this->entities)) {
return true;
}
if (array_key_exists($name, $this->data)) {
return true;
}
return false;
}
/**
* undocumented function
* @param string $name
* @return void
**/
public function get($name) {
return $this->$name;
}
/**
* undocumented function
* @param
* @return void
**/
public function set($name, $value) {
$this->$name = $value;
}
/**
* undocumented function
* @param
* @return void
**/
public function createGuid(Entity $entity) {
if (!isset($this->nextGuid)) {
$this->nextGuid = 0;
}
$entity->setGuid($this->nextGuid);
$this->set($this->nextGuid, $entity);
$this->nextGuid++;
}
public function run(){
foreach ($this->entities as $entity) {
$entity->work();
}
}
}
?>