1+ Phaser . LinkedList = function ( ) {
2+ } ;
3+
4+ Phaser . LinkedList . prototype = {
5+
6+ _iNext : null ,
7+ _iPrev : null ,
8+ first : null ,
9+ last : null ,
10+ sprite : { name : 'HD' } ,
11+
12+ add : function ( child ) {
13+
14+ // If the list is empty
15+ if ( this . first == null && this . last == null )
16+ {
17+ this . first = child ;
18+ this . last = child ;
19+ this . _iNext = child ;
20+ child . _iPrev = this ;
21+ return ;
22+ }
23+
24+ // Get gets appended to the end of the list, regardless of anything, and it won't have any children of its own (non-nested list)
25+ this . last . _iNext = child ;
26+
27+ child . _iPrev = this . last ;
28+
29+ this . last = child ;
30+
31+ } ,
32+
33+ remove : function ( child ) {
34+
35+ // If the list is empty
36+ if ( this . first == null && this . last == null )
37+ {
38+ return ;
39+ }
40+
41+ // The only node?
42+ if ( this . first == child && this . last == child )
43+ {
44+ this . first = null ;
45+ this . last = null ;
46+ this . _iNext = null ;
47+ child . _iNext = null ;
48+ child . _iPrev = null ;
49+ return ;
50+ }
51+
52+ var childPrev = child . _iPrev ;
53+
54+ // Tail node?
55+ if ( child . _iNext )
56+ {
57+ // Has another node after it?
58+ child . _iNext . _iPrev = child . _iPrev ;
59+ }
60+
61+ childPrev . _iNext = child . _iNext ;
62+
63+ } ,
64+
65+ dump : function ( ) {
66+
67+ console . log ( "\nNode\t\t|\t\tNext\t\t|\t\tPrev\t\t|\t\tFirst\t\t|\t\tLast" ) ;
68+ console . log ( "\t\t\t|\t\t\t\t\t|\t\t\t\t\t|\t\t\t\t\t|" ) ;
69+
70+ var nameNext = '-' ;
71+ var namePrev = '-' ;
72+ var nameFirst = '-' ;
73+ var nameLast = '-' ;
74+
75+ if ( this . _iNext )
76+ {
77+ nameNext = this . _iNext . sprite . name ;
78+ }
79+
80+ if ( this . _iPrev )
81+ {
82+ namePrev = this . _iPrev . sprite . name ;
83+ }
84+
85+ if ( this . first )
86+ {
87+ nameFirst = this . first . sprite . name ;
88+ }
89+
90+ if ( this . last )
91+ {
92+ nameLast = this . last . sprite . name ;
93+ }
94+
95+ if ( typeof nameNext === 'undefined' )
96+ {
97+ nameNext = '-' ;
98+ }
99+
100+ if ( typeof namePrev === 'undefined' )
101+ {
102+ namePrev = '-' ;
103+ }
104+
105+ if ( typeof nameFirst === 'undefined' )
106+ {
107+ nameFirst = '-' ;
108+ }
109+
110+ if ( typeof nameLast === 'undefined' )
111+ {
112+ nameLast = '-' ;
113+ }
114+
115+ console . log ( 'HD' + '\t\t\t|\t\t' + nameNext + '\t\t\t|\t\t' + namePrev + '\t\t\t|\t\t' + nameFirst + '\t\t\t|\t\t' + nameLast ) ;
116+
117+ var entity = this ;
118+
119+ var testObject = entity . last . _iNext ;
120+ entity = entity . first ;
121+
122+ do
123+ {
124+ var name = entity . sprite . name || '*' ;
125+ var nameNext = '-' ;
126+ var namePrev = '-' ;
127+ var nameFirst = '-' ;
128+ var nameLast = '-' ;
129+
130+ if ( entity . _iNext )
131+ {
132+ nameNext = entity . _iNext . sprite . name ;
133+ }
134+
135+ if ( entity . _iPrev )
136+ {
137+ namePrev = entity . _iPrev . sprite . name ;
138+ }
139+
140+ if ( entity . first )
141+ {
142+ nameFirst = entity . first . sprite . name ;
143+ }
144+
145+ if ( entity . last )
146+ {
147+ nameLast = entity . last . sprite . name ;
148+ }
149+
150+ if ( typeof nameNext === 'undefined' )
151+ {
152+ nameNext = '-' ;
153+ }
154+
155+ if ( typeof namePrev === 'undefined' )
156+ {
157+ namePrev = '-' ;
158+ }
159+
160+ if ( typeof nameFirst === 'undefined' )
161+ {
162+ nameFirst = '-' ;
163+ }
164+
165+ if ( typeof nameLast === 'undefined' )
166+ {
167+ nameLast = '-' ;
168+ }
169+
170+ console . log ( name + '\t\t\t|\t\t' + nameNext + '\t\t\t|\t\t' + namePrev + '\t\t\t|\t\t' + nameFirst + '\t\t\t|\t\t' + nameLast ) ;
171+
172+ entity = entity . _iNext ;
173+
174+ }
175+ while ( entity != testObject )
176+
177+ }
178+
179+ } ;
0 commit comments