?? zlistnode.java
字號:
/*
Netwar
Copyright (C) 2002 Daniel Grund, Kyle Kakligian, Jason Komutrattananon, & Brian Hibler.
This file is part of Netwar.
Netwar is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Netwar is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Netwar; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package netwar.utils.vectorgraphics;
import netwar.game.GameViewer;
import netwar.utils.*;
public class ZListNode {
private float Z;
private GraphicThing thing;
private ZOrderedList owner;
private ZListNode next = null;
private ZListNode prev = null;
public ZListNode(GraphicThing gt, ZOrderedList zol) {
thing = gt;
owner = zol;
Z = thing.getZ(owner.getT());
owner.count++;
gt.addNode(this);
next = zol.zNode;
while((next != null) && (next.Z < Z)) {
prev = next;
next = next.next;
}
if(next != null)
next.prev = this;
if(prev != null)
prev.next = this;
else
zol.zNode = this;
}
void update(float newZ){
Z = newZ;
if((prev != null) && (prev.Z > Z)) {
prev.next = next;
if(next != null)
next.prev = prev;
while((prev != null) && (prev.Z > Z)) {
next = prev;
prev = prev.prev;
}
if(next != null)
next.prev = this;
if(prev != null)
prev.next = this;
else
owner.zNode = this;
}else if((next != null) && (next.Z < Z)) {
if(prev != null)
prev.next = next;
else
owner.zNode = next;
next.prev = prev;
while((next != null) && (next.Z < Z)) {
prev = next;
next = next.next;
}
if(next != null)
next.prev = this;
if(prev != null)
prev.next = this;
else
owner.zNode = this;
}
}
void remove() {
if(prev == null)
owner.zNode = next;
else
prev.next = next;
if(next != null)
next.prev = prev;
thing.remNode(this);
owner.count--;
next = null;
prev = null;
thing = null;
owner = null;
}
Transform getT() {
return owner.getT();
}
//Static only in order to avoid unneeded recursion.
static void draw(GameViewer v, ZListNode node) {
ZListNode zln = node;
while(zln != null) {
zln.thing.draw(v);
zln = zln.next;
}
}
float getZ(Transform t) {
return thing.getZ(t);
}
public GraphicThing getThing() {
return thing;
}
public ZListNode getNext() {
return next;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -