当前位置: 首页>>代码示例>>C++>>正文


C++ Objective::GetObjectiveClassData方法代码示例

本文整理汇总了C++中Objective::GetObjectiveClassData方法的典型用法代码示例。如果您正苦于以下问题:C++ Objective::GetObjectiveClassData方法的具体用法?C++ Objective::GetObjectiveClassData怎么用?C++ Objective::GetObjectiveClassData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Objective的用法示例。


在下文中一共展示了Objective::GetObjectiveClassData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddRunwayCraters

void AddRunwayCraters (Objective o, int f, int craters)
{
	// Add a few linked craters
	// NOTE: These need to be deterministically generated
	int		i,tp,rp;
	float	x1,y1,x,y,xd,yd,r;
	int		rwindex,runway = 0;
	ObjClassDataType	*oc;
	
	// Find the runway header this feature belongs to
	oc = o->GetObjectiveClassData();
	rwindex = oc->PtDataIndex;
	while (rwindex && !runway)
	{
		if (PtHeaderDataTable[rwindex].type == RunwayPt)
		{
			for (i=0; i<MAX_FEAT_DEPEND && !runway; i++)
			{
				if (PtHeaderDataTable[rwindex].features[i] == f)
					runway = rwindex;
			}
		}
		rwindex = PtHeaderDataTable[rwindex].nextHeader;
	}
	// Check for valid runway (could be a runway number or something)
	if (!runway)
		return;

	rp = GetFirstPt(runway);
	tp = rp + 1;
	TranslatePointData(o,rp,&xd,&yd);
	TranslatePointData(o,tp,&x1,&y1);
	xd -= x1;
	yd -= y1;
	// Seed the random number generator
	srand(o->Id().num_);

	for (i=0; i<craters; i++)
	{
		// Randomly place craters along the runway.
		r = ((float)(rand()%1000)) / 1000.0F;
		x = x1 + r*xd + (((float)(rand()%50)) / 50.0F);
		y = y1 + r*yd + (((float)(rand()%50)) / 50.0F);
		NewLinkedPersistantObject(MapVisId(VIS_CRATER2), o->Id(), f, x, y);
#ifdef DEBUG
		Persistant_Runway_Craters++;
#endif
	}
}
开发者ID:FreeFalcon,项目名称:freefalcon-central,代码行数:49,代码来源:persist.cpp

示例2: GetDeaggregationPoint

int TaskForceClass::GetDeaggregationPoint (int slot, CampEntity *installation)
{
    int			pt=0,type;
    static int	last_pt, index = 0;

    if (!*installation)
    {
        // We're looking for a new list, so clear statics
        last_pt = index = 0;

        // Check if we care about placement
        if (!Moving())
        {
            // Find the appropriate installation
            GridIndex	x,y;
            Objective	o;
            GetLocation(&x,&y);
            o = FindNearestObjective (x,y,NULL,0);
            *installation = o;

            // Find the appropriate list
            if (o)
            {
                ObjClassDataType	*oc = o->GetObjectiveClassData();
                index = oc->PtDataIndex;
                while (index)
                {
                    if (PtHeaderDataTable[index].type == DockListType)
                    {
                        // The first time we look, we just want to know if we have a list.
                        // Return now.
                        return index;
                    }
                    index = PtHeaderDataTable[index].nextHeader;
                }
#ifdef DEBUG
                FILE	*fp = fopen("PtDatErr.log","a");
                if (fp)
                {
                    char		name[80];
                    o->GetName(name,79,FALSE);
                    fprintf(fp, "Obj %s @ %d,%d: No header list of type %d.\n",name,x,y,DockListType);
                    fclose(fp);
                }
#endif
            }
        }
    }

    if (index)
    {
        // We have a list, and want to find the correct point
        UnitClassDataType		*uc = GetUnitClassData();
        VehicleClassDataType	*vc = GetVehicleClassData(uc->VehicleType[slot]);

        // Check which type of point we're looking for
        // TODO: Check ship type here...
        //		type = SmallDockPt;
        type = LargeDockPt;

        // Return the next point, if it's the base type
        // NOTE: Log error if we don't have enough points of this type
        if (last_pt)
        {
            last_pt = pt = GetNextPt(last_pt);
#ifdef DEBUG
            if (!pt || PtDataTable[pt].type != type)
            {
                FILE	*fp = fopen("PtDatErr.log","a");
                if (fp)
                {
                    char		name[80];
                    GridIndex	x,y;
                    (*installation)->GetName(name,79,FALSE);
                    (*installation)->GetLocation(&x,&y);
                    fprintf(fp, "HeaderList %d (Obj %s @ %d,%d): Insufficient points of type %d.\n",index,name,x,y,type);
                    fclose(fp);
                }
            }
#endif
            return pt;
        }

        // Find one of the appropriate type
        pt = GetFirstPt(index);
        while (pt)
        {
            if (PtDataTable[pt].type == type)
            {
                last_pt = pt;
                return pt;
            }
            pt = GetNextPt(pt);
        }
#ifdef DEBUG
        FILE	*fp = fopen("PtDatErr.log","a");
        if (fp)
        {
            char		name[80];
            GridIndex	x,y;
//.........这里部分代码省略.........
开发者ID:aoighost,项目名称:freefalcon-central,代码行数:101,代码来源:navunit.cpp


注:本文中的Objective::GetObjectiveClassData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。