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

📄 targets.cpp

📁 空战游戏flacon源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	}
}

void AddObjectiveToTargetTree(Objective obj)
{
	short					f,fid;
	VehicleID				classID;
	Falcon4EntityClassType* classPtr;
	float					x,y,z;
	FeatureClassDataType*	fc;
	ObjClassDataType*		oc;
	BSPLIST					*drawptr;
	Tpoint					objPos;
	TREELIST				*item,*parent;
	C_Entity				*recon_ent;
	C_Feature				*feat;
	BSPLIST					*Parent;
	short					ShowAllFeatures=0;

	if(TargetTree)
	{
		recon_ent=BuildObjective(obj);
		if(recon_ent)
			recon_ent->SetCallback(PickFirstChildCB);

		parent=TargetTree->CreateItem(obj->GetCampID(),C_TYPE_MENU,recon_ent);
		if(parent)
		{
			TargetTree->AddItem(TargetTree->GetRoot(),parent);
			recon_ent->SetOwner(parent);
		}

		Parent=NULL;
		if(obj->GetType() == TYPE_CITY || obj->GetType() == TYPE_TOWN || obj->GetType() == TYPE_VILLAGE)
			ShowAllFeatures=1;
		oc = obj->GetObjectiveClassData();
		fid = oc->FirstFeature;
		for (f=0; f<oc->Features; f++,fid++)
		{
			classID = static_cast<short>(obj->GetFeatureID(f));
			if (classID)
			{
				fc = GetFeatureClassData (classID);
				if (!fc || fc->Flags & FEAT_VIRTUAL)
					continue;
				obj->GetFeatureOffset(f, &y, &x, &z);
				objPos.x=x+obj->XPos();
				objPos.y=y+obj->YPos();
				objPos.z=z;
				classPtr = &Falcon4ClassTable[fc->Index];
				if(classPtr != NULL)
				{
					drawptr=gUIViewer->LoadDrawableFeature(obj->GetCampID() << 16 | f,obj,f,fid,classPtr,fc,&objPos,Parent);
					if(drawptr != NULL)
					{
						Parent=drawptr->owner;
						if(obj->GetFeatureValue(f) || ShowAllFeatures)
						{
							((DrawableObject*)drawptr)->GetPosition(&objPos);

							feat=BuildFeature(obj,f,&objPos);
							if(feat)
							{
								item=TargetTree->CreateItem(obj->GetCampID() << 16 | f,C_TYPE_ITEM,feat);
								if(item)
								{
									TargetTree->AddChildItem(parent,item);
									feat->SetOwner(item);
								}
							}
						}
					}
				}
			}
		}
	}
}

void GetGroundUnitsNear(float x,float y,float range)
{
	VuListIterator myit(AllRealList);
	Unit un;
	float deltax,deltay;

 	un=GetFirstUnit(&myit);

	while(un != NULL)
	{
		deltax=x-un->XPos();
		deltay=y-un->YPos();
		if(deltax < 0) deltax=-deltax;
		if(deltay < 0) deltay=-deltay;

		// KCK: I made the following change here. Not sure what was intended
//		if((deltax < range & deltay < range) && !un->IsSquadron())
		if(deltax < range && deltay < range && !un->IsSquadron())
			AddUnitToTargetTree(un);
		un=GetNextUnit(&myit);
	}
}

void GetObjectivesNear(float x,float y,float range)
{
	VuListIterator myit(AllObjList);
	Objective Obj;
	float deltax,deltay;

 	Obj=GetFirstObjective(&myit);

	while(Obj != NULL)
	{
		deltax=x-Obj->XPos();
		deltay=y-Obj->YPos();
		if(deltax < 0) deltax=-deltax;
		if(deltay < 0) deltay=-deltay;

		// KCK: I made the following change here. Not sure what was intended
//		if(deltax < range & deltay < range)
		if(deltax < range && deltay < range)
			AddObjectiveToTargetTree(Obj);
		Obj=GetNextObjective(&myit);
	}
}

void ReconArea(float x,float y,float range)
{
	C_Window *win;
	TREELIST *parent,*item;

	SetCursor(gCursors[CRSR_WAIT]);
	win=gMainHandler->FindWindow(RECON_WIN);
	if(win)
	{
		CloseAllRenderers(RECON_WIN);
		if(TargetTree)
			TargetTree->DeleteBranch(TargetTree->GetRoot());

		if(gUIViewer)
		{
			gUIViewer->Cleanup();
			delete gUIViewer;
		}

		gUIViewer=new C_3dViewer;
		gUIViewer->Setup();
		gUIViewer->Viewport(win,0); // use client 0 for this window

		Recon.Heading=0.0f;
		Recon.Pitch=70.0f;
		Recon.Distance=1000.0f;
		Recon.Direction=0.0f;

		Recon.MinDistance=250.0f;
		Recon.MaxDistance=30000.0f;
		Recon.MinPitch=5;
		Recon.MaxPitch=90;
		Recon.CheckPitch=TRUE;

		Recon.PosX=x;
		Recon.PosY=y;
		Recon.PosZ=-4000;

		GetObjectivesNear(x,y,range);
		GetGroundUnitsNear(x,y,range);

		SetBullsEye(win);
		SetSlantRange(win);
		SetHeading(win);

		gUIViewer->SetPosition(Recon.PosX,Recon.PosY,Recon.PosZ);
		gUIViewer->InitOTW(30.0f,TRUE);
		gUIViewer->AddAllToView();

		win->ScanClientAreas();
		win->RefreshWindow();

		TheLoader.WaitForLoader();
		PositionCamera(&Recon,win,0);

		gMainHandler->ShowWindow(win);
		gMainHandler->WindowToFront(win);
	}
	win=gMainHandler->FindWindow(RECON_LIST_WIN);
	if(win)
	{
		if(TargetTree)
			TargetTree->RecalcSize();
		gMainHandler->ShowWindow(win);
		gMainHandler->WindowToFront(win);
	}
	if(TargetTree)
	{
		parent=TargetTree->GetRoot();
		if(parent)
		{
			if(parent->Type_ == C_TYPE_MENU)
			{
				item=parent->Child;
				if(item)
					CenterOnFeatureCB(RECON_TREE,C_TYPE_LMOUSEUP,item->Item_);
			}
			else if(parent->Type_ == C_TYPE_ITEM)
				CenterOnFeatureCB(RECON_TREE,C_TYPE_LMOUSEUP,parent->Item_);
		}
	}
	SetCursor(gCursors[CRSR_F16]);
}

void BuildTargetList(float x,float y,float range)
{
	TREELIST *parent,*item;
	C_Window *win;

	win=gMainHandler->FindWindow(RECON_WIN);
	if(win)
	{
		CloseAllRenderers(RECON_WIN);
		if(TargetTree)
			TargetTree->DeleteBranch(TargetTree->GetRoot());

		if(gUIViewer)
		{
			gUIViewer->Cleanup();
			delete gUIViewer;
		}

		gUIViewer=new C_3dViewer;
		gUIViewer->Setup();
		gUIViewer->Viewport(win,0); // use client 0 for this window

		Recon.Heading=0.0f;
		Recon.Pitch=70.0f;
		Recon.Distance=1000.0f;
		Recon.Direction=0.0f;

		Recon.MinDistance=250.0f;
		Recon.MaxDistance=30000.0f;
		Recon.MinPitch=5;
		Recon.MaxPitch=90;
		Recon.CheckPitch=TRUE;

		Recon.PosX=x;
		Recon.PosY=y;
		Recon.PosZ=-4000;

		GetObjectivesNear(x,y,range);
		GetGroundUnitsNear(x,y,range);

		SetBullsEye(win);
		SetSlantRange(win);
		SetHeading(win);

		gUIViewer->SetPosition(Recon.PosX,Recon.PosY,Recon.PosZ);
		gUIViewer->InitOTW(30.0f,FALSE);
		gUIViewer->AddAllToView();

		win->ScanClientAreas();
		win->RefreshWindow();

		PositionCamera(&Recon,win,0);
	}
	win=gMainHandler->FindWindow(RECON_LIST_WIN);
	if(win)
	{
		if(TargetTree)
			TargetTree->RecalcSize();
		gMainHandler->ShowWindow(win);
		gMainHandler->WindowToFront(win);
	}
	if(TargetTree)
	{
		parent=TargetTree->GetRoot();
		if(parent)
		{
			if(parent->Type_ == C_TYPE_MENU)
			{
				item=parent->Child;
				if(item)
					CenterOnFeatureCB(RECON_TREE,C_TYPE_LMOUSEUP,item->Item_);
			}
			else if(parent->Type_ == C_TYPE_ITEM)
				CenterOnFeatureCB(RECON_TREE,C_TYPE_LMOUSEUP,parent->Item_);
		}
	}
}

void BuildSpecificTargetList(VU_ID targetID)
{
	C_Window *win;
	CampEntity ent;
	TREELIST *parent,*item;

	ent=(CampEntity)vuDatabase->Find(targetID);
	if(!ent)
		return;

	win=gMainHandler->FindWindow(RECON_WIN);
	if(win)
	{
		CloseAllRenderers(RECON_WIN);
		if(TargetTree)
			TargetTree->DeleteBranch(TargetTree->GetRoot());

		if(gUIViewer)
		{
			gUIViewer->Cleanup();
			delete gUIViewer;
		}

		gUIViewer=new C_3dViewer;
		gUIViewer->Setup();
		gUIViewer->Viewport(win,0); // use client 0 for this window

		Recon.Heading=0.0f;
		Recon.Pitch=70.0f;
		Recon.Distance=1000.0f;
		Recon.Direction=0.0f;

		Recon.MinDistance=150.0f;
		Recon.MaxDistance=30000.0f;
		Recon.MinPitch=5;
		Recon.MaxPitch=90;
		Recon.CheckPitch=TRUE;

		if(ent->IsObjective())
			AddObjectiveToTargetTree((Objective)ent);
		if(ent->IsUnit())
			AddUnitToTargetTree((Unit)ent);

		Recon.PosX=ent->XPos();
		Recon.PosY=ent->YPos();
		Recon.PosZ=-4000;

		SetBullsEye(win);
		SetSlantRange(win);
		SetHeading(win);

		gUIViewer->SetPosition(Recon.PosX,Recon.PosY,Recon.PosZ);
		gUIViewer->InitOTW(30.0f,FALSE);
		gUIViewer->AddAllToView();

		win->ScanClientAreas();
		win->RefreshWindow();

		PositionCamera(&Recon,win,0);
	}
	win=gMainHandler->FindWindow(RECON_LIST_WIN);
	if(win)
	{
		if(TargetTree)
			TargetTree->RecalcSize();
		gMainHandler->ShowWindow(win);
		gMainHandler->WindowToFront(win);
	}
	if(TargetTree)
	{
		parent=TargetTree->GetRoot();
		if(parent)
		{
			if(parent->Type_ == C_TYPE_MENU)
			{
				item=parent->Child;
				if(item)
					CenterOnFeatureCB(RECON_TREE,C_TYPE_LMOUSEUP,item->Item_);
			}
			else if(parent->Type_ == C_TYPE_ITEM)
				CenterOnFeatureCB(RECON_TREE,C_TYPE_LMOUSEUP,parent->Item_);
		}
	}
}

⌨️ 快捷键说明

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