⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 n_arylink.java

📁 NetWar是一个实时策略游戏
💻 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.utils.*;

/** Linking point to connect N vertices of different GraphicThings to each other.
 * For each of the N points connected to it, you must pass a GraphicThing
 * which uses that point, and another N_aryLink that uses that GraphicThing.
 * @see netwar.utils.vectorgraphics.UnaryLink
 */
public class N_aryLink {
	private int N = 0;
	private boolean binding = false;
	N_aryLink adjacent[];
	Point3D points[];
	GraphicThing gts[];
	
	/** Creates a new instance of N_aryLink
	 * @param n The number of points linked together.
	 */
	public N_aryLink(int n) {
		adjacent = new N_aryLink[n];
		points = new Point3D[n];
		gts = new GraphicThing[n];
	}
	/** add one of the points to link together.
	 * @param nlink The link on the other side of gt.
	 * @param p3d The point to link together.
	 * @param gt The GraphicThing which uses this point.
	 */
	public void addLink(N_aryLink nlink, Point3D p3d, GraphicThing gt) {
		Assert.notFalse(gts.length > N, "Too many links added to N_aryLink");
		adjacent[N] = nlink;
		points[N] = p3d;
		gts[N] = gt;
		N++;
	}
	void rebind(N_aryLink bindto) {
		Assert.notFalse(N == gts.length, "rebind called before all the links were established");
		if(binding) return;
		binding = true;
		int n;
		for(n = 0; adjacent[n] != bindto; n++)
			Assert.notFalse(n < N, "rebind called, but caller was not bound to this link");
		int i;
		for(i = 0; i < N; i++) {
			if(i != n) {
				gts[i].translate(points[n].getDifference(points[i]));
			}
		}
		for(i = 0; i < N; i++) {
			if(i != n) {
				adjacent[i].rebind(this);
			}
		}
		binding = false;
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -