Beispiel #1
0
int main()
{
	/* Initialize Building */
	Building dc;
	
	int num_zones = dc.get_num_zones();
	int num_rooms = dc.get_num_rooms();

	int update = 0;

	printf("DEFAULT: \n Number of Zones = %d \n Number of Rooms = %d \n", num_zones, num_rooms);
	
	printf("Do you want to change? (1-Yes, 0-No): ");
	scanf_s("%d", &update);

	if (update == 1) {
		printf("WARNING: Number should lie between 0-255. Otherwise, Unexpected Results\n");

		printf("Enter Number of Zones : ");
		scanf_s("%d", &num_zones);
		dc.set_num_zones(num_zones);

		printf("Enter Number of Rooms : ");
		scanf_s("%d", &num_rooms);
		dc.set_num_rooms(num_rooms);
	}
	
	num_zones = dc.get_num_zones();
	num_rooms = dc.get_num_rooms();

	printf("UPDATED: \n Number of Zones = %d \n Number of Rooms = %d \n", num_zones, num_rooms);
	
	/* Initialize Simulation Details */
	int MIN2SEC = 60;
	long int duration = 120000;
	int time_step = 600;

	printf("DEFAULT: \n Duration = %ld \n Time Step = %d \n", duration, time_step);

	printf("Do you want to change? (1-Yes, 0-No): ");
	scanf_s("%d", &update);

	if (update == 1) {
		printf("Enter Simulation Duration (in seconds) : ");
		scanf_s("%ld", &duration);

		printf("Enter Time Step (in seconds) : ");
		scanf_s("%d", &time_step);
	}

	if ((time_step/MIN2SEC)/duration > 1) {
		printf("ERROR: Time step can't be greater than total duration of simulation");
		return 0;
	}

	printf("UPDATED: \n Duration = %ld \n Time Step = %d \n", duration, time_step);

	int control_type = 1;

	printf("DEFAULT: SPOT Always On \n");

	printf("Do you want to change? (1-Yes, 0-No): ");
	scanf_s("%d", &update);

	if (update == 1) {
		printf("Enter Control Type (1 - AlwaysOn, 2 - Reactive, 3 - MPC) : ");
		scanf_s("%d", &control_type);
	}

	if (control_type == 1) {
		printf("Updated: SPOT Always On \n");
	}
	else if (control_type == 1) {
		printf("Updated: Reactive Control \n");
	}
	else {
		printf("Updated: MPC Control \n");
	}
		
	dc.Simulate(duration, time_step, control_type);
	printf("Simulation Complete");
	system("pause");
	return 0;
}
void AIObjectiveMarker::AdvanceStandard()
{
    AIObjective *objective = (AIObjective *)g_app->m_location->GetBuilding( m_objectiveId );
    if( objective && objective->m_active )
    {
        if( m_objectiveBuildingId != -1 )
        {
            Building *b = g_app->m_location->GetBuilding( m_objectiveBuildingId );
            if( b && !b->m_destroyed )
            {
                if( b->m_type == Building::TypeSolarPanel &&
                    b->GetNumPorts() == 0 )
                {
                    m_objectiveBuildingId = -1;
                }
                else
                {
                    SetTeamId( b->m_id.GetTeamId() );
                }
            }
            else
            {
                AppDebugOut("Registered Objective Building missing\n");
                m_objectiveBuildingId = -1;
            }
        }

        if( m_objectiveBuildingId == -1 )
        {
            if( m_scanRange == 0.0 )
            {
                SetTeamId(m_defaultTeam);
            }
            else
            {
                bool include[NUM_TEAMS];
                memset( include, true, sizeof(bool) * NUM_TEAMS );
                include[g_app->m_location->GetMonsterTeamId()] = false;
                include[g_app->m_location->GetFuturewinianTeamId()] = false;
                int total = g_app->m_location->m_entityGrid->GetNumNeighbours( m_pos.x, m_pos.z, m_scanRange, include );
                if( total > 0 )
                {
                    int teamCounts[NUM_TEAMS];
                    memset( teamCounts, 0, sizeof(int) * NUM_TEAMS );
                    for( int i = 0; i < NUM_TEAMS; ++i )
                    {
                        if( i == g_app->m_location->GetMonsterTeamId() ) continue;
                        if( i == g_app->m_location->GetFuturewinianTeamId() ) continue;
                        teamCounts[i] = g_app->m_location->m_entityGrid->GetNumFriends( m_pos.x, m_pos.z, m_scanRange, i );
                    }

                    int currentWinner = 0;
                    for( int i = 0; i < NUM_TEAMS; ++i )
                    {
                        if( teamCounts[i] > (teamCounts[currentWinner] * 4 ) &&
                            teamCounts[currentWinner] < 10) currentWinner = i;
                    }

                    SetTeamId( currentWinner );
                }
                else
                {
                    SetTeamId(255);
                }
            }
        }
    }

    int id = AI::FindNearestTarget( m_pos );
    AITarget *target = (AITarget *)g_app->m_location->GetBuilding( id );
    if( target )
    {
        for( int i = 0; i < NUM_TEAMS; ++i )
        {
            if( g_app->m_location->IsAttacking(i) )
            {
                AI *ai = AI::s_ai[i];
                if( ai )
                {
                    if( ai->m_currentObjective == m_objectiveId )
                    {
                        if( m_armourObjective == 0 )
                        {
                            if(!g_app->m_location->IsFriend(m_id.GetTeamId(), i )) 
                            {
                                target->m_priority[i] = 1.0;
                                target->m_aiObjectiveTarget[i] = true;
                            }
                            else
                            {
                                target->m_aiObjectiveTarget[i] = false;
                            }
                        }
                        else
                        {
                            target->m_aiObjectiveTarget[i] = false;
                        }
                    }
                    else if( m_pickupAvailable )
                    {
                        target->m_priority[i] = 1.0;
                        target->m_aiObjectiveTarget[i] = true;
                    }
                    else
                    {
                        target->m_aiObjectiveTarget[i] = false;
                    }
                }
            }
        }
    }
}
TEST_F(ModelFixture, Building_SpaceAttributes)
{
  Model model;

  Building building = model.getUniqueModelObject<Building>();

  EXPECT_EQ(0, building.floorArea());
  EXPECT_FALSE(building.conditionedFloorArea());
  EXPECT_EQ(0, building.lightingPower());
  EXPECT_EQ(0, building.lightingPowerPerFloorArea());
  EXPECT_EQ(0, building.peoplePerFloorArea());

  Space space(model);

  // floor 
  Point3dVector points;
  points.push_back(Point3d(0, 10, 0));
  points.push_back(Point3d(10, 10, 0));
  points.push_back(Point3d(10, 0, 0));
  points.push_back(Point3d(0, 0, 0));
  Surface floor(points, model);
  floor.setParent(space);
  EXPECT_EQ("Floor", floor.surfaceType());
  EXPECT_NEAR(100, space.floorArea(), 0.0001);

  EXPECT_NEAR(100, building.floorArea(), 0.0001);
  EXPECT_FALSE(building.conditionedFloorArea());
  EXPECT_EQ(0, building.lightingPower());
  EXPECT_EQ(0, building.lightingPowerPerFloorArea());
  EXPECT_EQ(0, building.peoplePerFloorArea());

  LightsDefinition lightsDefinition(model);
  Lights light(lightsDefinition);
  EXPECT_TRUE(light.setSpace(space));
  EXPECT_TRUE(lightsDefinition.setLightingLevel(100));

  PeopleDefinition peopleDefinition(model);
  People person(peopleDefinition);
  EXPECT_TRUE(person.setSpace(space));
  EXPECT_TRUE(peopleDefinition.setNumberofPeople(1));

  EXPECT_NEAR(100, building.floorArea(), 0.0001);
  EXPECT_FALSE(building.conditionedFloorArea());
  EXPECT_NEAR(100, building.lightingPower(), 0.0001);
  EXPECT_NEAR(1, building.lightingPowerPerFloorArea(), 0.0001);
  EXPECT_NEAR(1.0/100.0, building.peoplePerFloorArea(), 0.0001);

  EXPECT_TRUE(light.setMultiplier(2));
  EXPECT_TRUE(person.setMultiplier(2));

  EXPECT_NEAR(100, building.floorArea(), 0.0001);
  EXPECT_FALSE(building.conditionedFloorArea());
  EXPECT_NEAR(200, building.lightingPower(), 0.0001);
  EXPECT_NEAR(2, building.lightingPowerPerFloorArea(), 0.0001);
  EXPECT_NEAR(2.0/100.0, building.peoplePerFloorArea(), 0.0001);

  ThermalZone thermalZone(model);
  EXPECT_TRUE(thermalZone.setMultiplier(2));
  EXPECT_TRUE(space.setThermalZone(thermalZone));
  EXPECT_EQ(2, space.multiplier());

  EXPECT_NEAR(200, building.floorArea(), 0.0001);
  EXPECT_FALSE(building.conditionedFloorArea());
  EXPECT_NEAR(400, building.lightingPower(), 0.0001);
  EXPECT_NEAR(2, building.lightingPowerPerFloorArea(), 0.0001);
  EXPECT_NEAR(2.0/100.0, building.peoplePerFloorArea(), 0.0001);

}
void LocationEditor::AdvanceModeBuilding()
{
	BuildingEditWindow *ew = (BuildingEditWindow *)EclGetWindow("editor_buildingid");
	if (ew && EclMouseInWindow(ew))	return;
	
	Camera *cam = g_app->m_camera;

	// Find the ID of the building the user is clicking on
	int newSelectionId = -1;
	if ( g_inputManager->controlEvent( ControlTileSelect ) )
	{
		Vector3 rayStart, rayDir;
		cam->GetClickRay( g_target->X(), g_target->Y(), &rayStart, &rayDir );
		newSelectionId = DoesRayHitBuilding(rayStart, rayDir);
	}

	if (m_selectionId == -1)
	{
		// If there isn't currently any selection, then check for a new one
		if (newSelectionId != -1)
		{
			m_selectionId = newSelectionId;
			BuildingsCreateWindow *cw = (BuildingsCreateWindow*)EclGetWindow("editor_buildings");
			AppDebugAssert(!ew);
			AppDebugAssert(cw);
			BuildingEditWindow *bew = new BuildingEditWindow("editor_buildingid");
			bew->m_w = cw->m_w;
			bew->m_h = 140;
			bew->m_x = cw->m_x;
			EclRegisterWindow(bew);
			bew->m_y = cw->m_y - bew->m_h - 10;
			m_waitingForRelease = true;

            Location *location = g_app->m_location;
		    Building *building = location->GetBuilding(m_selectionId);            
            if( building->m_type == Building::TypeTree )
            {
                TreeWindow *tw = new TreeWindow( "editor_treeditor" );
                tw->m_w = cw->m_w;
                tw->m_h = 230;
                tw->m_y = bew->m_y - tw->m_h - 10;
                tw->m_x = bew->m_x;
                EclRegisterWindow( tw );
            }
		}
	}
	else 
	{
		Location *location = g_app->m_location;
		Building *building = location->GetBuilding(m_selectionId);
	
		
		if ( g_inputManager->controlEvent( ControlTileSelect ) )                  // If left mouse is clicked then consider creating a new link
		{
			if (newSelectionId == -1)
			{
				EclRemoveWindow("editor_buildingid");
				m_selectionId = -1;
			}
			else if (m_tool == ToolLink)
			{
				building->SetBuildingLink(newSelectionId);
				m_tool = ToolNone;
			}
		}		
		else if ( g_inputManager->controlEvent( ControlTileDrag ) && newSelectionId == -1 )  // Otherwise consider rotation and movement
		{
			switch (m_tool)
			{
				case ToolMove:
				{
					Vector3 mousePos = g_app->m_userInput->GetMousePos3d();
					building->m_pos = mousePos;
					break;
				}
				case ToolRotate:
				{
					Vector3 front = building->m_front;
					front.RotateAroundY((float)g_target->dX() * 0.01);
					building->m_front = front;
					break;
				}
			}
		}
	}
}
Beispiel #5
0
/*
*	handleClickInput - if shift is held, then user is wanting to select units, 
*		and no spell will cast. Otherwise the selected spell, if a single-click 
*		type spell, will cast. 
*/
void InGameState::handleClickInput(int x, int y,int screenX,int screenY){
	if(!game->getGSM()->isGameInProgress()){
		int overlayState= game->getGSM()->getOverlayGameState();
		map<int,GUIScreenOverlay*>::iterator find=overlayWorkers.find(overlayState);
		if(find!=overlayWorkers.end())(*find).second->handleClick(screenX,screenY);
		return;
	}
	Viewport *vp = game->getGUI()->getViewport();
	Cursor *c = game->getGUI()->getCursor(GS_GAME_IN_PROGRESS);
	toolbar.handleClick(game,screenX,screenY);
	displayUnits.handleClick(this,game,x,y);
	//spDBToolbar.handleClick(this, game, screenX, screenY);
	if(!isCursorBusy()){
		vector<Tower*>::iterator beginTower=towers.begin(), endTower=towers.end();
		b2Vec2 scaleMouse(x,y);
		scaleMouse*=BOX2D_Scale_Factor;
		for(;beginTower!=endTower;)
		{
			Tower* t = *beginTower;
			if(!t->isDead()){
				if(t->p==mainPlayer){
					b2AABB rct=t->getAABB();
					if(rct.lowerBound.x<scaleMouse.x && rct.lowerBound.y<scaleMouse.y &&
						rct.upperBound.x>scaleMouse.x && rct.upperBound.y>scaleMouse.y){
							t->mouseClick(game,screenX,screenY);
					}
				}
				beginTower++;
			}else{
				beginTower=towers.erase(beginTower);
				endTower=towers.end();
			}
		}
		vector<Building*>::iterator beginOther=buildings.begin(), endOther=buildings.end();
		for(;beginOther!=endOther;)
		{
			Building* t = *beginOther;
			if(!t->isDead()){
				if(t->p==mainPlayer){
					b2AABB rct=t->getAABB();
					if(rct.lowerBound.x<scaleMouse.x && rct.lowerBound.y<scaleMouse.y &&
						rct.upperBound.x>scaleMouse.x && rct.upperBound.y>scaleMouse.y){
							t->mouseClick(game,screenX,screenY);
					}
				}
				beginOther++;
			}
			else{
				beginOther=buildings.erase(beginOther);
				endOther=buildings.end();
			}
		}
	}
	if( screenY < vp->getViewportHeight()+vp->getViewportOffsetY() ){ 
		if (canCastSpell() && !isCursorBusy()){
			Spell* p = toolbar.getCurrentSpell();
			if(p!=NULL && p->getType()==click){
				//x+=vp->getViewportX()-vp->getViewportOffsetX();
				//y+=vp->getViewportY()-vp->getViewportOffsetY();
				
					if(p->getManaCost(game,x,y,0,0)<=this->mainPlayer->mana){
						mainPlayer->mana-=p->getManaCost(game,x,y,0,0);
						p=p->clone();
						p->start(game,x,y);
						p->owner=mainPlayer;
						spells.push_back(p);
					}
				
			}
			//c->setActiveCursorID(2);

			
		}
		else{
			if(currentBuilding!=NULL&& mappable){
				if(!mainPlayer->getWizard()->buildingsTutorials){
					tutSys->currentTutorial="BuildBarracks";
					game->getGSM()->setOverlayGameState(TUTSYSSCREENOVERLAYNUM);
					mainPlayer->getWizard()->buildingsTutorials=true;
				}
				this->addBuilding(currentBuilding,bx,by,this->players[0]);
				currentBuilding=NULL;
			}
		}
	}
}
Beispiel #6
0
void Handler::spawnObject(int objectID, ofVec2f inPos) {
	if (objectID >= 0 && objectID <= 6) {
		for (auto &obj : *gameObjects) {
			Building* building = dynamic_cast<Building*>(obj);
			if (building) {
				if (building->getPos().x == inPos.x&&building->getPos().y == inPos.y) {
					if (objectID == 0) {
						building->setHealth(0);
					}
					return;
				}
			}
		}
	}
	switch (objectID) {
	case(objectSheet::warehouse) : {
		gameObjects->push_back(new Warehouse(map));
		(*gameObjects)[gameObjects->size() - 1]->setMyImage(images[objectID]);
		(*gameObjects)[gameObjects->size() - 1]->setPos(inPos);
		break;
	}
	case(objectSheet::forest) : {
		gameObjects->push_back(new Forest(map));
		(*gameObjects)[gameObjects->size() - 1]->setMyImage(images[objectID]);
		(*gameObjects)[gameObjects->size() - 1]->setPos(inPos);
		break;
	}
	case(objectSheet::mine) : {
		gameObjects->push_back(new Mine(map));
		(*gameObjects)[gameObjects->size() - 1]->setMyImage(images[objectID]);
		(*gameObjects)[gameObjects->size() - 1]->setPos(inPos);
		break;
	}
	case(objectSheet::farm) : {
		gameObjects->push_back(new Farm(map));
		(*gameObjects)[gameObjects->size() - 1]->setMyImage(images[objectID]);
		(*gameObjects)[gameObjects->size() - 1]->setPos(inPos);
		break;
	}
	case(objectSheet::house) : {
		gameObjects->push_back(new House(map));
		(*gameObjects)[gameObjects->size() - 1]->setMyImage(images[objectID]);
		(*gameObjects)[gameObjects->size() - 1]->setPos(inPos);
		break;
	}
	case(objectSheet::stockPile) : {
		gameObjects->push_back(new Stockpile(map));
		(*gameObjects)[gameObjects->size() - 1]->setMyImage(images[objectID]);
		(*gameObjects)[gameObjects->size() - 1]->setPos(inPos);
		break;
	}
	case(objectSheet::person) : {
		gameObjects->push_back(new Person(gameObjects));
		int random = rand();
		random = random % 4;
			(*gameObjects)[gameObjects->size() - 1]->setMyImage(images[objectID+random]);
			(*gameObjects)[gameObjects->size() - 1]->setPos(inPos);
		break;
	}
	case(objectSheet::cow) : {
		gameObjects->push_back(new Cow());
		(*gameObjects)[gameObjects->size() - 1]->setMyImage(images[objectID]);
		(*gameObjects)[gameObjects->size() - 1]->setPos(inPos);
		break;
	}
	case(objectSheet::onyxHorse) : {
		gameObjects->push_back(new OnyxHorse());
		(*gameObjects)[gameObjects->size() - 1]->setMyImage(images[objectID]);
		(*gameObjects)[gameObjects->size() - 1]->setPos(inPos);
		break;
	}
	}
}
void BuildingConstructor::construct() {
	GLdouble currentMaxH = maxH;
	GLdouble currentMinH = minH;
	GLdouble xTranslation = ((double) rand() * 0.5) / (double) RAND_MAX;
	GLdouble zTranslation = ((double) rand() * 0.5) / (double) RAND_MAX;
	GLdouble xScaling = 2.0;
	GLdouble zScaling = 2.0;
	GLdouble rotationAngle = 90.0;
	GLdouble lotBias = 0.02;
	Matrix4d translation;
	Matrix4d scaling;
	Matrix4d rotation;
	Matrix4d rotation90;
	Building* building = NULL;
	
	GLdouble scaleMax = 0.90;
	GLdouble scaleMin = 0.5;
	double colorH = 1.0;
	double colorL = 0.90;
	double r = (double) rand() * (colorH + 1.0 - colorL) / (double) RAND_MAX + colorL;
	double g = (double) rand() * (colorH + 1.0 - colorL) / (double) RAND_MAX + colorL;
	double b = (double) rand() * (colorH + 1.0 - colorL) / (double) RAND_MAX + colorL;

	GLuint buildingChoice = rand() * (3 + 1) / RAND_MAX;
	GLuint roofChoice = rand() * (5 - 4 + 1) / RAND_MAX + 4;

	std::cerr << "buildingChoice: " << buildingChoice << "  roofChoice: " << roofChoice << std::endl;

	rotation.identity();
	rotation90.makeRotateY(rotationAngle);

	switch (choice) {
		// medium buildings
		case 0:
			while (buildingChoice == 1) {
				buildingChoice = rand() * (3 + 1) / RAND_MAX;
			}
			std::cerr << "hhhh" << std::endl;
			xScaling = (double) rand() * (3.0 + 1.0 - 2.0) / (double) RAND_MAX + 2.0;
			zScaling = (double) rand() * (3.0 + 1.0 - 2.0) / (double) RAND_MAX + 2.0;
			translation.makeTranslate(xTranslation, 0.0, zTranslation);
			scaling.makeScale(xScaling, currentMaxH, zScaling);
			building = new Building(buildingChoice, roofChoice, r, g, b, texture, xScaling, currentMaxH, zScaling, translation * scaling);
			root->addChild(building->getRoot());
			break;
		// mid towards out buildings
		case 1:
			buildingChoice = rand() * (3 + 1 - 1) / RAND_MAX + 1;
			xScaling = zScaling = (double) rand() * (1.0 + 1.0 - 0.5) / (double) RAND_MAX + 0.5;

			for (int count = 0; count < layerCount - 1; ++count) {
				currentMaxH -= ((double) rand() * (scaleMax - scaleMin)) / (double) RAND_MAX + scaleMin;;

				xScaling += 0.3;
				zScaling += 0.3;

				if (xScaling > 3.0 || zScaling > 3.0) {
					break;
				}
				// std::cerr << "zScaling: " << zScaling << std::endl;
				scaling.makeScale(xScaling, currentMaxH, zScaling);

				building = new Building(buildingChoice, roofChoice, r, g, b, texture, xScaling, currentMaxH, zScaling, scaling);
				root->addChild(building->getRoot());
			}
			break;
		// tall buildings with rotation
		case 2:
			scaling.makeScale(3.0, 1.0, 3.0);
			buildingChoice = rand() * (3 + 1 - 1) / RAND_MAX + 1;
			building = new Building(buildingChoice, roofChoice, r, g, b, texture, 3.0, 1.0, 3.0, scaling);
			root->addChild(building->getRoot());


			translation.makeTranslate(xTranslation, 0.0, zTranslation);
			scaling.makeScale(xScaling, currentMaxH, zScaling);
			building = new Building(buildingChoice, roofChoice, r, g, b, texture, xScaling, currentMaxH, zScaling, translation * scaling);
			root->addChild(building->getRoot());

			//t s m
			xTranslation = 0.5 - lotBias;
			zTranslation = 0.0;
			zScaling = ((double) rand() * (currentMaxH - currentMinH)) / (double) RAND_MAX + currentMinH;

			for (int count = 0; count < layerCount - 1; ++count) {
				currentMaxH -= ((double) rand() * (scaleMax - scaleMin)) / (double) RAND_MAX + scaleMin;;
				rotation = rotation90 * rotation;

				zScaling = ((double) rand() * (scaleMax - scaleMin)) / (double) RAND_MAX + scaleMin;
				// std::cerr << "zScaling: " << zScaling << std::endl;
				scaling.makeScale(xScaling, currentMaxH, zScaling);

				translation.makeTranslate(xTranslation, 0.0, 0.0);

				building = new Building(buildingChoice, roofChoice, r, g, b, texture, xScaling, currentMaxH, zScaling, rotation * translation * scaling);
				root->addChild(building->getRoot());
			}
			break;
		default:
			break;
	}
}
int OpeningPredictor::instantiate_and_compile(int time,
        const Building& building, const string& tmpOpening)
{
#ifdef BENCH
    clock_t start = clock();
#endif
    evidence[observed[building.getEnumValue()]] = 1;
    evidence[Time] = time;

#if DEBUG_OUTPUT > 1
    cout << "====== evidence ======" << endl;
    cout << evidence << endl;
#endif

    plDistribution PP_X;
    Cnd_P_X_knowing_obs.instantiate(PP_X, evidence);

#if DEBUG_OUTPUT > 1
    cout << "====== P(Opening | rest).instantiate ======" << endl;
    cout << Cnd_P_Opening_knowing_rest << endl;
    cout << PP_Opening.get_left_variables() << endl;
    cout << PP_Opening.get_right_variables() << endl;
#endif
    PP_X.compile(T_P_X);
#if DEBUG_OUTPUT >= 1
    cout << "====== P(Opening | evidence), building: "
        << building << " ======" << endl;
    cout << T_P_Opening << endl;
#endif
#ifdef BENCH
    vector<pair<plValues, plProbValue> > outvals;
    if (T_P_X.is_null())
        return -1;
    T_P_X.sorted_tabulate(outvals);
#if PLOT > 0
    vector<plValues> dummy;
    tmpProbV.clear();
    T_P_Opening.tabulate(dummy, tmpProbV);
    T_P_Opening_v.push_back(tmpProbV);
#endif
    for (vector<pair<plValues, plProbValue> >::const_iterator 
            jt = outvals.begin(); jt != outvals.end(); ++jt)
    {
        cumulative_prob[jt->first] += jt->second;
    }
#endif
#ifdef DIRAC_ON_LAST_OPENING
    P_LastOpening.mutate(static_cast<plDistribution>(
                PP_Opening.compile().rename(LastOpening)));
#endif
#ifdef BENCH
    plValues toTest(Opening);
    toTest[Opening] = tmpOpening;
    if (T_P_Opening.best()[Opening] == toTest[Opening])
        //&& T_P_Opening[toTest[Opening]] > 0.5)
        ++times_label_predicted ;
    if (time > 180 && T_P_Opening.best()[Opening] == toTest[Opening])
        ++times_label_predicted_after;
#endif
#ifdef BENCH
    clock_t end = clock();
    double duration = (double)(end - start) / CLOCKS_PER_SEC;
    time_taken_prediction.push_back(duration);
#if DEBUG_OUTPUT > 2
    cout << "TIME: instantiate+compile took: "
       << duration << " sec" << endl;
#endif
#endif
    return 0;
}
Beispiel #9
0
void Unit::attackBuilding(Building &building)
{
    building.takeDamage(attackDamage_);
}
Beispiel #10
0
int main()
{
    std::list<Passenger> passengers;
    Building* building = Building::getInstance();
    // Open the file
    std::ifstream myfile("HW6-Elevators.csv");
    std::string line;
    if(myfile.is_open())
    {
        while(!myfile.eof())
        {
            std::getline(myfile, line);
            // Simple validation
            // Line must have characters
            // and first ones need to be numbers
            // Short-circuits to avoid dereferencing line[0] when invalid
            if(line.length() <= 1 ||
                    !std::isdigit(line[0])
              )
            {
                continue;
            }
            // Trim the line
            boost::trim(line);
            // Use Boost.Tokenizer to parse the line
            boost::tokenizer< boost::escaped_list_separator< char > > tok(line);
            boost::tokenizer< boost::escaped_list_separator< char > >::iterator
            iter = tok.begin();
            // Set the start time
            uint16_t time = boost::lexical_cast<uint16_t>(*iter++);
            // Next is the starting floor
            uint16_t start_floor = boost::lexical_cast<uint16_t>(*iter++);
            // Finally, set the ending floor
            uint16_t end_floor = boost::lexical_cast<uint16_t>(*iter++);
            // Add it to the list
            Passenger p(time, start_floor, end_floor);
            cout << p << endl;
            passengers.push_back(p);
        }
    }

    // If every elevator is idle, and passengers is empty, we're done
    while(1) // Run forever until internal break triggers
    {
        if(!passengers.empty() && passengers.front().getTime() == building->getTicker())
        {
            // Process until all passengers for this timestamp are through
            while(passengers.front().getTime() == building->getTicker())
            {
                Floor& floor = building->getFloor(passengers.front().getStartFloor());
                floor.addPassenger(passengers.front());
                building->incrementPassengerNumber();
                // When we add a passenger, trigger an alert to the elevators
                building->alertElevators(floor.getNumber());
                passengers.pop_front();
            }
        }
        // Step the elevators
        building->stepElevators();
        if(passengers.empty() && building->elevatorsIdle())
        {
            break;
        }
        ++building->getTicker();
    }

    // Show the average wait time
    cout << "The average wait time was: " << building->averageWaitTime() << endl;
    // Show the average travel time
    cout << "The average travel time was: " << building->averageTravelTime() << endl;
}
Beispiel #11
0
bool sortByEmpl(Building i, Building j) { return j.employees() > i.employees(); }
void  User_Interface::run()
{
	switch (this->status){

	case OUTPUT_DATA:
		{
			int max = this->calcMtrl->size();
			for (unsigned int i = 0; i < max; i++)
			{
				this->calcMtrl->pop_back();
			}
			this->redraw_window();
			this->type_build_box->set_top_index(0);
			this->num_floors_edit->set_text("");
			this->length_edit->set_text("");
			this->width_edit->set_text("");
			this->mat_fund_box->set_top_index(0);
			this->mat_wall_box->set_top_index(0);
			this->mat_roof_box->set_top_index(0);
			//this->mat_panel_box->set_top_index(0);

			this->enable_all(true);
			this->OK_button->set_text("Расчет");

			this->OK_button->show(SW_SHOW);
			this->show(SW_SHOW);
			this->status = INPUT_DATA;
			break;
		}

		case INPUT_DATA:
		{
			if (!this->materials->empty()){
				int type_build = this->type_build_box->get_top_index();

				int num_floors = _ttoi(this->num_floors_edit->get_text());
				double length = _ttof(this->length_edit->get_text());
				double width = _ttof(this->width_edit->get_text());

				int mat_fund = this->mat_fund_box->get_id_top_material();
				
				int mat_wall = this->mat_wall_box->get_id_top_material();
				
				int mat_roof = this->mat_roof_box->get_id_top_material();
				
				//int mat_panel = this->mat_panel_box->get_id_top_material();

				bool podval = this->checkbox->isChecked();

				Building* building = nullptr;
				switch (type_build)
				{
				case 0:
					building = new Home((double)width, (double)length, num_floors);
					break;
				case 1:
					building = new Office((double)width, (double)length, num_floors);
					break;
				case 2:
					building = new Storage((double)width, (double)length, num_floors);
					break;
				case 3:
					building = new Garage((double)width, (double)length, num_floors);
					break;
				default:
					break;
				}


				if (building){

					building->createFoundation(mat_fund, podval);
					building->createWall(type_build, mat_wall);
					building->createRoof(mat_roof, type_build);
					building->calculate();
					building->addMaterials(this->materials, this->calcMtrl);

					this->enable_all(false);
					this->OK_button->set_text("Новый");
					this->OK_button->show(SW_SHOW);
					this->status = OUTPUT_DATA;

					int X = 10, Y = 320;
					this->textout("Материал", 10, Y);
					this->textout("Количество", 230, Y);
					this->textout("Цена/шт", 330, Y);
					this->textout("Сумма грн", 400, Y);
					this->line(5,Y-5, 475, Y-5);
					this->line(5, Y + 20, 475, Y + 20);
					this->line(5, Y - 5, 5, Y + 20);
					this->line(225, Y - 5, 225, Y + 20);
					this->line(325, Y - 5, 325, Y + 20);
					this->line(395, Y - 5, 395, Y + 20);
					this->line(475, Y - 5, 475, Y + 20);
					Y += 25;
					double itogo = 0;
					char * buf = 0;
					int decimal;
					int sign;
					int err;
					if (!this->calcMtrl->empty()){
						for (unsigned int i = 0; i < this->calcMtrl->size(); i++)
						{
							if (this->calcMtrl->at(i)->count != 0)
							{
								char name[25];
								strncpy_s(name,25, this->calcMtrl->at(i)->type.c_str(), 24);
								this->textout((TCHAR*)name, 10, Y);


								buf = (char*)malloc(_CVTBUFSIZE);
								err = _fcvt_s(buf, _CVTBUFSIZE, this->calcMtrl->at(i)->count, 0, &decimal, &sign);
								this->textout((TCHAR*)buf, 230, Y);
								_itoa_s(this->calcMtrl->at(i)->price, buf, _CVTBUFSIZE, 10);
								this->textout((TCHAR*)buf, 330, Y);
								double summa = this->calcMtrl->at(i)->count * this->calcMtrl->at(i)->price;
								err = _fcvt_s(buf, _CVTBUFSIZE, summa, 0, &decimal, &sign);
								this->textout((TCHAR*)buf, 400, Y);
								itogo += summa;
								this->line(5, Y + 20, 475, Y + 20);
								this->line(5, Y - 5, 5, Y + 20);
								this->line(225, Y - 5, 225, Y + 20);
								this->line(325, Y - 5, 325, Y + 20);
								this->line(395, Y - 5, 395, Y + 20);
								this->line(475, Y - 5, 475, Y + 20);
								Y += 25;
							}
						}

						this->textout("Итого:", 350, Y);
						err = _fcvt_s(buf, _CVTBUFSIZE, itogo, 0, &decimal, &sign);
						this->textout((TCHAR*)buf, 400, Y);
						this->line(345, Y + 20, 475, Y + 20);
						this->line(345, Y - 5, 345, Y + 20);
						this->line(395, Y - 5, 395, Y + 20);
						this->line(475, Y - 5, 475, Y + 20);
					}
				}
			}
			else{
				this->textout("Нет данных о строительных материалах", 10, 320);
				this->status = OUTPUT_DATA;
			}
			break;
		}

		

	}
}
Vector3 Entity::PushFromObstructions( Vector3 const &pos, bool killem )
{
    Vector3 result = pos;    
    if( m_onGround )
    {
        result.y = g_app->m_location->m_landscape.m_heightMap->GetValue( result.x, result.z );
    }

    Matrix34 transform( m_front, g_upVector, result );

    //
    // Push from Water

    if( result.y <= 1.0 )
    {        
        double pushAngle = syncsfrand(1.0);
        double distance = 0.0;
        while( distance < 50.0 )
        {
            double angle = distance * pushAngle * M_PI;
            Vector3 offset( iv_cos(angle) * distance, 0.0, iv_sin(angle) * distance );
            Vector3 newPos = result + offset;
            double height = g_app->m_location->m_landscape.m_heightMap->GetValue( newPos.x, newPos.z );
            if( height > 1.0 )
            {
                result = newPos;
                result.y = height;
                break;
            }
            distance += 1.0;
        }
    }
    

    //
    // Push from buildings

    LList<int> *buildings = g_app->m_location->m_obstructionGrid->GetBuildings( result.x, result.z );

    for( int b = 0; b < buildings->Size(); ++b )
    {
        int buildingId = buildings->GetData(b);
        Building *building = g_app->m_location->GetBuilding( buildingId );
        if( building )
        {        
            bool hit = false;
            if( m_shape && building->DoesShapeHit( m_shape, transform ) ) hit = true;
            if( (!m_shape || m_type == TypeOfficer ) && building->DoesSphereHit( result, 1.0 ) ) hit = true;
            // cheap hack, but no point overriding the entire function for this one line
            if( !hit )
            {
                Vector3 oldPos = m_pos - m_vel * SERVER_ADVANCE_PERIOD;
                if( building->DoesRayHit( oldPos, m_front, (m_pos - oldPos).Mag() ) ) hit = true;
            }

            if( hit )
            {            
                if( building->m_type == Building::TypeLaserFence && killem &&
                    ((LaserFence *) building)->IsEnabled())
                {
                    if( !g_app->m_location->IsFriend(building->m_id.GetTeamId(), m_id.GetTeamId() ) )
                    {
                        ChangeHealth( -9999 );
                        ((LaserFence *) building)->Electrocute( m_pos );
                    }
                }
                else
                {               
                    Vector3 pushForce = (building->m_pos - result);
                    pushForce.y = 0.0f;
                    pushForce.SetLength(4.0f);
                    while( building->DoesSphereHit( result, 2.0f ) )
                    {
                        result -= pushForce;   
                        //result.y = g_app->m_location->m_landscape.m_heightMap->GetValue( result.x, result.z );
                    }
                }
            }
        }
    }

    return result;
}
void AIObjectiveMarker::AdvanceDefensive()
{
    AIObjective *objective = (AIObjective *)g_app->m_location->GetBuilding( m_objectiveId );
    if( objective && objective->m_active )
    {
        Building *b = g_app->m_location->GetBuilding( m_objectiveBuildingId );
        if( b )
        {
            if( b->m_type == Building::TypeSolarPanel &&
                b->GetNumPorts() == 0 )
            {
                m_objectiveBuildingId = -1;
            }
        }
        else
        {
            m_objectiveBuildingId = -1;
        }

        int teamCounts[NUM_TEAMS];
        memset( teamCounts, 0, sizeof(int) * NUM_TEAMS );
        for( int i = 0; i < NUM_TEAMS; ++i )
        {
            if( i == g_app->m_location->GetMonsterTeamId() ) continue;
            if( i == g_app->m_location->GetFuturewinianTeamId() ) continue;
            teamCounts[i] = g_app->m_location->m_entityGrid->GetNumFriends( m_pos.x, m_pos.z, m_scanRange, i );
        }

        int currentWinner = 0;
        int totalDefenders = 0;
        for( int i = 0; i < NUM_TEAMS; ++i )
        {
            if( g_app->m_location->IsDefending(i) ) 
            {
                totalDefenders += teamCounts[i];
                if( totalDefenders >= 15 ||
                    (b && g_app->m_location->IsDefending( b->m_id.GetTeamId() ) ) )
                {
                    currentWinner = i;
                    break;
                }
            }

            if( teamCounts[i] > (teamCounts[currentWinner] * 2 )  )
                currentWinner = i;
        }

        SetTeamId( currentWinner );
    }


    int id = AI::FindNearestTarget( m_pos );
    AITarget *target = (AITarget *)g_app->m_location->GetBuilding( id );
    if( target )
    {
        for( int i = 0; i < NUM_TEAMS; ++i )
        {
            if( g_app->m_location->IsDefending(i) )
            {
                AI *ai = AI::s_ai[i];
                if( ai )
                {
                    if( ai->m_currentObjective == m_objectiveId )
                    {
                        if(g_app->m_location->IsFriend(m_id.GetTeamId(), i )) 
                        {
                            target->m_priority[i] = 1.0;
                            target->m_aiObjectiveTarget[i] = true;
                        }
                        else
                        {
                            target->m_aiObjectiveTarget[i] = false;
                        }
                    }
                    else
                    {
                        target->m_aiObjectiveTarget[i] = false;
                    }
                }
            }
        }
    }
}
Beispiel #15
0
void WorldModel::setBuildingsInSightPoints()
{
    int extendedSightRange = maxSightRange * 2;
    LOG(Main, 2) << "num of roads: " << world->roads.size() << endl;
    for (int i = 0; i < (int) world->roads.size(); i++)
    {
        for (int j = 0; j < (int) world->roads[i]->getInnerPoints().size(); j++)
        {
            Point p = world->roads[i]->getInnerPoints()[j];
            vector<Building*> nearBuildings;
            //			vector<Point> nearPoints;
            //			vector<Point> upNearPoints;
            //			vector<Point> downNearPoints;
            LOG(Main, 2) << "road: " << i << " with id " << world->roads[i]->getId() << endl;
            for (int k = 0; k < (int) world->buildings.size(); k++)
            {
                if (distanceBetweenPoints(p, world->buildings[k]->getPos()) < extendedSightRange)
                {
                    nearBuildings.push_back(world->buildings[k]);
                    //					LOG(Main, 1) << "circle" << world->buildings[k]->getPos() << " 2000; ";
                }
            }
            //algorithm for sort near points
            //			for(int k = 0; k < (int)nearBuildings.size(); k++)
            //			{
            //				for(int l = 0; l < nearBuildings[k]->getShape().size(); l++)
            //				{
            //					Point tmp = nearBuildings[k]->getShape().getVertex(l);
            //					if(isLessEqual(p.getY(), tmp.getY()))
            //					{
            //						upNearPoints.push_back(tmp);
            //					}
            //					else
            //					{
            //						downNearPoints.push_back(tmp);
            //					}
            //				}
            //			}
            //			setComparePoint(p);
            //			sort(upNearPoints.begin(), upNearPoints.end(), Geometry::angleCompare);
            //			sort(downNearPoints.begin(), downNearPoints.end(), Geometry::angleCompare);
            //			for(int k = 0; k < (int)upNearPoints.size(); k++)
            //			{
            //				nearPoints.push_back(upNearPoints[k]);
            //			}
            //			for(int k = 0; k < (int)downNearPoints.size(); k++)
            //			{
            //				nearPoints.push_back(downNearPoints[k]);
            //			}
            //			LOG(Main, 2) << "after sort" << endl;
            //			if(nearPoints.size() == 0)
            //			{
            //				continue;
            //			}
            set<Building*> inSightBuildings;
            setColor(4);
            LOG(Main, 2) << Circle(p, maxSightRange) << ' ';
            LOG(Main, 2) << Circle(p, 500) << ' ';
            setColor(1);
            //			LOG(Main, 1) << "circle" << p << " " << extendedSightRange << "; ";
            //			for(int k = 1; k < (int)nearPoints.size(); k++)
            //			{
            //				LOG(Main, 1) << "line" << nearPoints[k - 1] << nearPoints[k] << "; ";
            //			}
            //			LOG(Main, 1) << "line" << nearPoints[0] << nearPoints.back() << "; ";
            //			for(int k = 0; k < (int)nearPoints.size(); k++)
            double dAngle = M_PI * 2 / rayCount;
            for (int k = 0; k < rayCount; k++)
            {
                //				int next = (k + 1) % nearPoints.size();
                //				Point mid = Segment(nearPoints[k], nearPoints[next]).getMiddlePoint();
                //				Segment s(p, mid);
                //				Vector ext = p.asVector() + s.asVector() * (extendedSightRange / s.getLength());
                //				s = Segment(p, ext.asPoint());
                double angle = k * dAngle;
                Segment s(p, (p.asVector() + Vector(sin(angle) * maxSightRange, cos(angle) * maxSightRange)).asPoint());
                LOG(Main, 2) << s << ' ';
                //				LOG(Main, 1) << "circle" << nearPoints[k] << " 200; ";
                double minDist = 1e10;
                Building* inSightBuilding = NULL;
                Segment minLine;
                for (int l = 0; l < (int) nearBuildings.size(); l++)
                {
                    for (int m = 0; m < nearBuildings[l]->getIDs().size(); m++)
                    {
                        if (nearBuildings[l]->getIDs()[m] == -1)
                        {
                            Segment edge = nearBuildings[l]->getShape().getSegment(m);
                            //							LOG(Main, 1) << "line" << edge.getFirstPoint() << edge.getSecondPoint() << "; ";
                            if (isIntersect(s, edge))
                            {
                                //								LOG(Main, 1) << "circle" << p << " " << maxSightRange << "; ";
                                //								LOG(Main, 1) << "circle" << p << " " << extendedSightRange << "; ";
                                //								LOG(Main, 1) << "line" << s.getFirstPoint() << s.getSecondPoint() << "; ";
                                //								LOG(Main, 1) << "line" << edge.getFirstPoint() << edge.getSecondPoint() << "; ";
                                Point intersect = getIntersectPoint(s.asLine(), edge.asLine());
                                //								LOG(Main, 1) << "circle" << intersect << " 200;" << endl;
                                if (isLess(distanceBetweenPoints(p, intersect), minDist))
                                {
                                    minDist = distanceBetweenPoints(p, intersect);
                                    inSightBuilding = nearBuildings[l];
                                    minLine = edge;
                                }
                            }
                        }
                    }
                }
                if (inSightBuilding != NULL && isLess(minDist, (double) maxSightRange))
                {
                    inSightBuildings.insert(inSightBuilding);
                    LOG(Main, 2) << Circle(inSightBuilding->getPos(), 1000) << ' ';
                    LOG(Main, 2) << minLine << ' ';
                    //					LOG(Main, 1) << "line" << s.getFirstPoint() << s.getSecondPoint() << "; ";
                }
            }
            //			LOG(Main, 2) << endl << endl;
            for (set<Building*>::iterator k = inSightBuildings.begin(); k != inSightBuildings.end(); k++)
            {
                (*k)->addInSightPoint(i, j);
            }
        }
        LOG(Main, 2) << endl;
    }
    // Reverse Log (buildings)
    //	for(int i = 0; i < (int)world->buildings.size(); i++)
    //	{
    //		LOG(Main, 2) << "building " << i << " with id " << world->buildings[i]->getId() << endl;
    //		setColor(0);
    //		LOG(Main, 2) << Circle(world->buildings[i]->getPos(), 1000) << ' ';
    //		setColor(2);
    //		for(int j = 0; j < (int)world->buildings[i]->getInSightPoints().size(); j++)
    //		{
    //			LOG(Main, 2) << Circle(world->roads[world->buildings[i]->getInSightPoints()[j].roadIndex]->getInnerPoints()[world->buildings[i]->getInSightPoints()[j].index], 500) << ' ';
    //		}
    //		LOG(Main, 2) << endl << endl;
    //	}
}
TEST_F(ModelFixture, Construction_NetArea_InteriorWall) {
  Model model;

  Construction construction1(model);
  Construction construction2(model);
  EXPECT_DOUBLE_EQ(0.0, construction1.getNetArea());
  EXPECT_DOUBLE_EQ(0.0, construction2.getNetArea());

  // add costs
  boost::optional<LifeCycleCost> cost1 = LifeCycleCost::createLifeCycleCost("Brick", construction1, 3.0, "CostPerArea", "Construction");
  ASSERT_TRUE(cost1);
  boost::optional<LifeCycleCost> cost2 = LifeCycleCost::createLifeCycleCost("Glass", construction2, 5.0, "CostPerArea", "Construction");
  ASSERT_TRUE(cost2);
  EXPECT_DOUBLE_EQ(0, cost1->totalCost());
  EXPECT_DOUBLE_EQ(0, cost2->totalCost());

  Building building = model.getUniqueModelObject<Building>();
  DefaultSurfaceConstructions defaultExteriorSurfaceConstructions(model);
  DefaultSurfaceConstructions defaultInteriorSurfaceConstructions(model);
  DefaultSubSurfaceConstructions defaultExteriorSubSurfaceConstructions(model);
  DefaultSubSurfaceConstructions defaultInteriorSubSurfaceConstructions(model);
  DefaultConstructionSet defaultConstructionSet(model);
  defaultConstructionSet.setDefaultExteriorSurfaceConstructions(defaultExteriorSurfaceConstructions);
  defaultConstructionSet.setDefaultInteriorSurfaceConstructions(defaultInteriorSurfaceConstructions);
  defaultConstructionSet.setDefaultExteriorSubSurfaceConstructions(defaultExteriorSubSurfaceConstructions);
  defaultConstructionSet.setDefaultInteriorSubSurfaceConstructions(defaultInteriorSubSurfaceConstructions);
  building.setDefaultConstructionSet(defaultConstructionSet);

  Space space(model);

  Point3dVector points;
  points.push_back(Point3d(0, 0, 1));
  points.push_back(Point3d(0, 0, 0));
  points.push_back(Point3d(0, 1, 0));
  points.push_back(Point3d(0, 1, 1));

  Surface surface1(points, model);
  surface1.setSpace(space);
  EXPECT_EQ("Wall", surface1.surfaceType());
  EXPECT_EQ("Outdoors", surface1.outsideBoundaryCondition());
  EXPECT_DOUBLE_EQ(1.0, surface1.netArea());

  points.clear();
  points.push_back(Point3d(0, 1, 1));
  points.push_back(Point3d(0, 1, 0));
  points.push_back(Point3d(0, 0, 0));
  points.push_back(Point3d(0, 0, 1));

  Surface surface2(points, model);
  surface2.setSpace(space);
  EXPECT_EQ("Wall", surface2.surfaceType());
  EXPECT_EQ("Outdoors", surface2.outsideBoundaryCondition());
  EXPECT_DOUBLE_EQ(1.0, surface2.netArea());

  EXPECT_DOUBLE_EQ(0.0, construction1.getNetArea());
  EXPECT_DOUBLE_EQ(0.0, construction2.getNetArea());
  EXPECT_DOUBLE_EQ(0, cost1->totalCost());
  EXPECT_DOUBLE_EQ(0, cost2->totalCost());

  defaultExteriorSurfaceConstructions.setWallConstruction(construction1);
  ASSERT_TRUE(surface1.construction());
  ASSERT_TRUE(surface2.construction());
  EXPECT_EQ(surface1.construction()->handle(), construction1.handle());
  EXPECT_EQ(surface2.construction()->handle(), construction1.handle());
  EXPECT_DOUBLE_EQ(2.0, construction1.getNetArea());
  EXPECT_DOUBLE_EQ(0.0, construction2.getNetArea());
  EXPECT_DOUBLE_EQ(6.0, cost1->totalCost());
  EXPECT_DOUBLE_EQ(0, cost2->totalCost());

  surface1.setConstruction(construction1);
  surface2.setConstruction(construction2);
  ASSERT_TRUE(surface1.construction());
  ASSERT_TRUE(surface2.construction());
  EXPECT_EQ(surface1.construction()->handle(), construction1.handle());
  EXPECT_EQ(surface2.construction()->handle(), construction2.handle());
  EXPECT_DOUBLE_EQ(1.0, construction1.getNetArea());
  EXPECT_DOUBLE_EQ(1.0, construction2.getNetArea());
  EXPECT_DOUBLE_EQ(3.0, cost1->totalCost());
  EXPECT_DOUBLE_EQ(5.0, cost2->totalCost());

  surface1.setAdjacentSurface(surface2);
  ASSERT_TRUE(surface1.construction());
  ASSERT_TRUE(surface2.construction());
  EXPECT_EQ(surface1.construction()->handle(), construction1.handle());
  EXPECT_EQ(surface2.construction()->handle(), construction2.handle());
  EXPECT_DOUBLE_EQ(1.0, construction1.getNetArea());
  EXPECT_DOUBLE_EQ(1.0, construction2.getNetArea());
  EXPECT_DOUBLE_EQ(3.0, cost1->totalCost());
  EXPECT_DOUBLE_EQ(5.0, cost2->totalCost());

  surface2.setConstruction(construction1);
  ASSERT_TRUE(surface1.construction());
  ASSERT_TRUE(surface2.construction());
  EXPECT_EQ(surface1.construction()->handle(), construction1.handle());
  EXPECT_EQ(surface2.construction()->handle(), construction1.handle());
  EXPECT_DOUBLE_EQ(1.0, construction1.getNetArea());
  EXPECT_DOUBLE_EQ(0.0, construction2.getNetArea());
  EXPECT_DOUBLE_EQ(3.0, cost1->totalCost());
  EXPECT_DOUBLE_EQ(0.0, cost2->totalCost());
}
Beispiel #17
0
// -----------------------------------------------------------------
// Name : deserialize
// -----------------------------------------------------------------
bool LuaContext::deserialize(NetworkData * pData, PlayerManagerAbstract * pMngr, Map * pMap)
{
    pLua = NULL;
    pPlayer = NULL;
    pUnit = NULL;
    pTown = NULL;
    u32 uType = (u32) pData->readLong();
    switch (uType)
    {
    case LUAOBJECT_SPELL:
    {
        // Find player
        u8 uPlayerId = (u8) pData->readLong();
        pPlayer = pMngr->findPlayer(uPlayerId);
        assert(pPlayer != NULL);
        // Find spell
        u32 uLuaId = (u32) pData->readLong();
        pLua = pPlayer->findSpell(0, uLuaId, pPlayer->m_pActiveSpells);
        assert(pLua != NULL);
        ((Spell*)pLua)->setCaster(pPlayer);
        break;
    }
    case LUAOBJECT_SKILL:
    {
        // Find player
        u8 uPlayerId = (u8) pData->readLong();
        pPlayer = pMngr->findPlayer(uPlayerId);
        assert(pPlayer != NULL);
        // Find unit
        u32 uUnitId = (u32) pData->readLong();
        pUnit = pPlayer->findUnit(uUnitId);
        assert(pUnit != NULL);
        // Find skill
        u32 uLuaId = (u32) pData->readLong();
        pLua = pUnit->findSkill(uLuaId);
        assert(pLua != NULL);
        ((Skill*)pLua)->setCaster(pUnit);
        break;
    }
    case LUAOBJECT_BUILDING:
    {
        // Find town
        u32 uTown = (u32) pData->readLong();
        pTown = pMap->findTown(uTown);
        assert(pTown != NULL);
        // Find building
        u32 uLuaId = (u32) pData->readLong();
        Building * pBuild = pTown->getFirstBuilding(0);
        while (pBuild != NULL)
        {
            if (pBuild->getInstanceId() == uLuaId)
            {
                pLua = pBuild;
                break;
            }
            pBuild = pTown->getNextBuilding(0);
        }
        assert(pLua != NULL);
        ((Building*)pLua)->setCaster(pTown);
        break;
    }
    case LUAOBJECT_SPECIALTILE:
    {
        // Find special tile
        u32 uLuaId = (u32) pData->readLong();
        pLua = pMap->findSpecialTile(uLuaId);
        assert(pLua != NULL);
        break;
    }
    }
    pLua->setCurrentEffect((int) pData->readLong());
    return true;
}
Beispiel #18
0
 bool IsValid() const { return m_building.IsValid() && m_street.IsValid(); }
Beispiel #19
0
//Saves the map.  Good for editing maps, not good for saving a game in mid-play because unit statuses are not saved. 
void InformationStorage::saveMap(string filename, Map *level)
{
	TiXmlDocument doc;
	string s;
	TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "");
	doc.LinkEndChild(decl);

	//Set up the root of the XML document
	TiXmlElement *root = new TiXmlElement("TileInfo");
	doc.LinkEndChild(root);

	//Set up the Units, Buildings, and Tiles blocks
	TiXmlElement *units = new TiXmlElement("Units");
	TiXmlElement *buildings = new TiXmlElement("Buildings");
	TiXmlElement *tiles = new TiXmlElement("Tiles");

	//Set up pointers to be used throughout saving the map
	TiXmlElement *elem;
	GameObject *gObj = 0;
	Unit *unit = 0;
	Building *building = 0;
	Terrain *tile = 0;

	//Set the width, height, and player count in the XML based on the level
	tiles->SetAttribute("width", level->width);
	tiles->SetAttribute("height", level->height);
	tiles->SetAttribute("playercount", level->playerCount());

	//Add the units, buildings, and tiles blocks to the root
	root->LinkEndChild(units);
	root->LinkEndChild(buildings);
	root->LinkEndChild(tiles);

	Cell* cell;
	
	//Go through every cell of the map, and check what the terrain, unit(if any), and building(if any)
	//there is, and store it in the xml
	for(int i=0; i<level->width; i++)
	{
		for(int j=0; j<level->height; j++)
		{
			cell = level->getCell(i, j);
			gObj = cell->objectAtLayer(CellLayers::Unit);
			if(gObj)
			{
				//Add the unit to the units tag
				unit = (Unit*)gObj;
				elem = new TiXmlElement("Unit");
				elem->SetAttribute("id", unit->id);
				elem->SetAttribute("pId", unit->getOwner()->id);
				elem->SetAttribute("x", i);
				elem->SetAttribute("y", j);
				units->LinkEndChild(elem);
			}

			gObj = cell->objectAtLayer(CellLayers::Building);
			if(gObj)
			{
				//Add the building to the buildings tag
				building = (Building*)gObj;
				elem = new TiXmlElement("Building");
				elem->SetAttribute("id", building->id);
				elem->SetAttribute("pId", building->getOwner()->id);
				elem->SetAttribute("x", i);
				elem->SetAttribute("y", j);
				buildings->LinkEndChild(elem);
			}
			//Don't bother checking for terrain, there should always be one there.

			gObj = cell->objectAtLayer(CellLayers::Terrain);
			tile = (Terrain*)gObj;
			elem = new TiXmlElement("Tile");
			elem->SetAttribute("shorthand", tile->id);
			elem->SetAttribute("x", i);
			elem->SetAttribute("y", j);
			tiles->LinkEndChild(elem);
		}
	}
	doc.SaveFile(filename.c_str());
	
}
/* Fall 3: prüft, ob sich alles korrekt verhält, wenn das Gebäude gedreht ist.
 *
 *    Süd                  Ost                Nord                 West
 *   =====                =====              ======               ======
 *
 *    x=88                 x=88                x=88                 x=88
 *    |                    |                   |                    |
 * □□□□□□□□□              □□□□              ▨▨▨□□□□□□              □▨▨▨
 * □▨▨▣▣▣▨▨▨ — y=42       □▨▨□              ▨▨▨▣▣▣▨▨□ — y=42       □▨▨▨
 * □▨▨▣▣▣▨▨▨              □▨▨□              ▨▨▨▣▣▣▨▨□              □▨▨▨
 * □□□□□□▨▨▨              □▣▣□ — y=42       □□□□□□□□□              □▣▣□ — y=42
 *                        □▣▣□                                     □▣▣□
 *                        □▣▣□                                     □▣▣□
 *                        ▨▨▨□                                     □▨▨□
 *                        ▨▨▨□                                     □▨▨□
 *                        ▨▨▨□                                     □□□□
 *
 * Wir prüfen immer dieselben MapCoords im Test.
 * Je nach Gebäude-View sind wir dann innerhalb ..oder außerhalb des Einzugsbereichs.
 */
TEST(CatchmentAreaTest, isInsideCatchmentArea_Views) {
    Building building;
    building.setMapCoords(MapCoords(88, 42));
    building.setView(Direction::SOUTH);

    RectangleData<char>* catchmentArea = new RectangleData<char>(9, 4);
    memcpy(catchmentArea->data, "000000000011111111011111111000000111", 36);

    MapObjectType mapObjectType;
    mapObjectType.catchmentArea.reset(catchmentArea);
    building.setMapObjectType(&mapObjectType);

    building.setMapWidth(3);
    building.setMapHeight(2);
    building.setView(Direction::SOUTH);
    ASSERT_TRUE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(88, 42))); // Mitte

    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(85, 41))); // Ecken des Quer-Rechtecks
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(93, 41)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(85, 44)));
    ASSERT_TRUE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(93, 44)));

    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(87, 39)));  // Ecken des Hochkant-Rechtecks
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(90, 39)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(87, 47)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(90, 47)));

    building.setMapWidth(2);
    building.setMapHeight(3);
    building.setView(Direction::EAST);
    ASSERT_TRUE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(88, 42))); // Mitte

    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(85, 41))); // Ecken des Quer-Rechtecks
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(93, 41)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(85, 44)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(93, 44)));

    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(87, 39)));  // Ecken des Hochkant-Rechtecks
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(90, 39)));
    ASSERT_TRUE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(87, 47)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(90, 47)));

    building.setMapWidth(3);
    building.setMapHeight(2);
    building.setView(Direction::NORTH);
    ASSERT_TRUE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(88, 42))); // Mitte

    ASSERT_TRUE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(85, 41))); // Ecken des Quer-Rechtecks
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(93, 41)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(85, 44)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(93, 44)));

    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(87, 39)));  // Ecken des Hochkant-Rechtecks
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(90, 39)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(87, 47)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(90, 47)));

    building.setMapWidth(2);
    building.setMapHeight(3);
    building.setView(Direction::WEST);
    ASSERT_TRUE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(88, 42))); // Mitte

    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(85, 41))); // Ecken des Quer-Rechtecks
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(93, 41)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(85, 44)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(93, 44)));

    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(87, 39)));  // Ecken des Hochkant-Rechtecks
    ASSERT_TRUE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(90, 39)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(87, 47)));
    ASSERT_FALSE(CatchmentArea::isInsideCatchmentArea(building, MapCoords(90, 47)));
}
void LocationEditor::Render()
{
    //
    // Render our buildings
	
	g_app->m_renderer->SetObjectLighting();
    LevelFile *levelFile = g_app->m_location->m_levelFile;
    for( int i = 0; i < levelFile->m_buildings.Size(); ++i )
    {
        if( levelFile->m_buildings.ValidIndex(i) )
        {
            Building *b = levelFile->m_buildings.GetData(i);
            b->Render(0.0);
        }
    } 
    g_app->m_renderer->UnsetObjectLighting();
	if (m_mode == ModeBuilding)
	{
		for( int i = 0; i < levelFile->m_buildings.Size(); ++i )
		{
			if( levelFile->m_buildings.ValidIndex(i) )
			{
				Building *b = levelFile->m_buildings.GetData(i);
				b->RenderAlphas(0.0);
				b->RenderLink();
			}
		}
	}


	// 
	// Render camera mounts

	{
		g_app->m_renderer->SetObjectLighting();
		Shape *camShape = g_app->m_resource->GetShape("camera.shp");
		Matrix34 mat;
		
		for (int i = 0; i < g_app->m_location->m_levelFile->m_cameraMounts.Size(); ++i)
		{
			CameraMount *mount = g_app->m_location->m_levelFile->m_cameraMounts[i];
			Vector3 camToMount = g_app->m_camera->GetPos() - mount->m_pos;
			if (camToMount.Mag() < 20.0) continue;
			mat.OrientFU(mount->m_front, mount->m_up);
			mat.pos = mount->m_pos;
			camShape->Render(0.0, mat);
		}
	    g_app->m_renderer->UnsetObjectLighting();
	}


    g_app->m_renderer->UnsetObjectLighting();


	// 
	// Render our instant units
	
	for (int i = 0; i < levelFile->m_instantUnits.Size(); ++i)
	{
		InstantUnit *iu = levelFile->m_instantUnits.GetData(i);
		RenderUnit(iu);
	}

	switch (m_mode)
	{
		case ModeLandTile:			RenderModeLandTile();				break;
		case ModeLandFlat:			RenderModeLandFlat();				break;
		case ModeBuilding:			RenderModeBuilding();				break;
		case ModeLight:													break;
		case ModeInstantUnit:		RenderModeInstantUnit();			break;
		case ModeCameraMount:		RenderModeCameraMount();			break;
	}

	
	//
	// Render axes

	float sizeX = g_app->m_location->m_landscape.GetWorldSizeX() / 2;
	float sizeZ = g_app->m_location->m_landscape.GetWorldSizeZ() / 2;
	RenderArrow(Vector3(10, 200, 0), Vector3(sizeX, 200, 0), 4.0);
	glBegin(GL_LINES);
		glVertex3f(sizeX,      250, 0);
		glVertex3f(sizeX + 90, 150, 0);
		glVertex3f(sizeX,      150, 0);
		glVertex3f(sizeX + 90, 250, 0);
	glEnd();
	glDisable(GL_BLEND);
	glDisable(GL_LINE_SMOOTH);

	RenderArrow(Vector3(0, 200, 10), Vector3(0, 200, sizeZ), 4.0);
	glBegin(GL_LINES);
		glVertex3f(0, 250, sizeZ);
		glVertex3f(0, 250, sizeZ + 90);
		glVertex3f(0, 250, sizeZ);
		glVertex3f(0, 150, sizeZ + 90);
		glVertex3f(0, 150, sizeZ);
		glVertex3f(0, 150, sizeZ + 90);
	glEnd();
	glDisable(GL_BLEND);
	glDisable(GL_LINE_SMOOTH);


    //
    // Render targetting crosshair

    g_app->m_renderer->SetupMatricesFor2D();
	glColor3ub(255,255,255);
    glLineWidth( 1.0 );
    glBegin( GL_LINES );
        glVertex2i( g_app->m_renderer->ScreenW()/2, g_app->m_renderer->ScreenH()/2 - 30 );
        glVertex2i( g_app->m_renderer->ScreenW()/2, g_app->m_renderer->ScreenH()/2 + 30 );

        glVertex2i( g_app->m_renderer->ScreenW()/2 - 30, g_app->m_renderer->ScreenH()/2 );
        glVertex2i( g_app->m_renderer->ScreenW()/2 + 30, g_app->m_renderer->ScreenH()/2 );
    glEnd();
    g_app->m_renderer->SetupMatricesFor3D();
    

	CHECK_OPENGL_STATE();
}
Beispiel #22
0
void Fire()
{
	if (!game.input->grabbing) return; // Ignore when not selected
	if (!NetCode::TryLock())
	{
		game.firing = true;
		return;
	}
	game.firing = false;
	switch (game.player->weapon)
	{
		case weapWrench:
			Build();
			return;
		case weapLaser:
		{
		        Camera &cam = game.controller->camera;
			Vd vec = ~(game.player->rotation * Vd(0,1,0));
			double yaw = atan2(vec.x, vec.y);
			Pd gunLoc = game.player->origin;// + game.player->model.weapon->origin;
			gunLoc.x = gunLoc.x + game.player->model.weapon->origin.x * cos(yaw)
			                    + game.player->model.weapon->origin.y * sin(yaw);
			gunLoc.y = gunLoc.y + game.player->model.weapon->origin.x * sin(yaw)
			                    + game.player->model.weapon->origin.y * cos(yaw);
			gunLoc.z = gunLoc.z + game.player->model.weapon->origin.z;
			
			Vd lookVec = (~(Vd(game.controller->target)+ -Vd(cam.origin))) * 38;
			Pd target = game.controller->target;
			ObjectHandle collision;
			if(game.controller->firstPerson){
				lookVec = (~(game.controller->camAngle * Vd(0,1,0)))*38;
				collision = game.world->trace(game.controller->camera.origin, lookVec, game.player);
			}else{
				collision = game.world->trace(game.controller->target, lookVec, game.player);
			}
			if (collision)
			{	
				Pd collisionPoint;
				if(game.controller->firstPerson){
					collisionPoint = game.controller->camera.origin + (lookVec);
				}else{
					collisionPoint = game.controller->target + (lookVec);
				}
				Qd beam = gunLoc.lookAt(collisionPoint);
				
				ObjectHandle laser = LaserBeam(gunLoc, beam, !lookVec);
				game.world->addLaserBeam(laser);
				NetCode::Fire(*TO(LaserBeam,laser));
				Player *p = TO(Player, collision);
				if(p){
					//if(p->team != game.player->team){//Precent teamkill
						p->damage(10.0, game.player->id);
						NetCode::Hit(p->id, 10.0, true);
					//}
				}else{
					Building *b = TO(Building, collision);
					if(b){
						/* Enable team kill on towers to demolish
						Player *own = NULL;
						if(Game::game.players.count(t->owner))
							own = TO(Player, Game::game.players[t->owner]); 
						if(own && own->team != game.player->team){*/
							b->damage(10.0, game.player->id);
							NetCode::Attack(b->loc, 10.0, true);
						//}
					}
				}
			}
			else{
				game.world->addLaserBeam(ObjectHandle(LaserBeam(gunLoc, cam.objective, !lookVec)));
			}
			return;
		}
		break;
	}
}
#include <catch.hpp>

#include <resourceshandler.hpp>

#include <world/building.hpp>
#include <world/buildingtypehandler.hpp>

using World::Building;

TEST_CASE("Basic Buildings tests")
{
    const auto house_bt = World::BuildingTypeHandler::instance().add(World::BuildingType{"House", {3, 3}, {}});

    SECTION("Creating a building that can't produce anything has no current recipe")
    {
        Building b{house_bt, {1, 1}, {{1, 0}, utils::SizeU{3, 3}}};
        CHECK_FALSE(b.currentRecipe());
    }

    ResourcesHandler::clear();
    ResourcesHandler::loadResources({"Wood", "Plank"});
    const auto wood_id = ResourcesHandler::const_instance().idOf("Wood");
    const auto plank_id = ResourcesHandler::const_instance().idOf("Plank");
    const auto lumbermill_bt = World::BuildingTypeHandler::instance().add(
        World::BuildingType{"LumberMill", {3, 3}, {}, {Recipe{1, {{wood_id, 1}}, {{plank_id, 1}}}}});

    SECTION("Creating a building with only one possible recipe has it as current recipe upon construction")
    {
        Building b{lumbermill_bt, {1, 1}, {{1, 0}, utils::SizeU{3, 3}}};
        CHECK(b.currentRecipe());
    }
boost::optional<IdfObject> ForwardTranslator::translateBuilding( Building & modelObject )
{
  Model model = modelObject.model();

  IdfObject idfObject(IddObjectType::Building);
  m_idfObjects.push_back(idfObject);

  for (LifeCycleCost lifeCycleCost : modelObject.lifeCycleCosts()){
    translateAndMapModelObject(lifeCycleCost);
  }
  
  OptionalString optS = modelObject.name();
  if( optS )
  {
    idfObject.setName(stripOS2(*optS));
  }

  if (!modelObject.isNorthAxisDefaulted()){
    idfObject.setDouble(openstudio::BuildingFields::NorthAxis, modelObject.northAxis());
  }

  // terrain comes from Site
  OptionalSite site = model.getOptionalUniqueModelObject<Site>();
  if (site){
    if (!site->isTerrainDefaulted()){
      idfObject.setString(openstudio::BuildingFields::Terrain, site->terrain());
    }
  }

  // these fields come from SimulationControl
  OptionalSimulationControl simulationControl = model.getOptionalUniqueModelObject<SimulationControl>();
  if (simulationControl){
    if (!simulationControl->isLoadsConvergenceToleranceValueDefaulted()){
      idfObject.setDouble(openstudio::BuildingFields::LoadsConvergenceToleranceValue, simulationControl->loadsConvergenceToleranceValue());
    }

    if (!simulationControl->isTemperatureConvergenceToleranceValueDefaulted()){
      idfObject.setDouble(openstudio::BuildingFields::TemperatureConvergenceToleranceValue, simulationControl->temperatureConvergenceToleranceValue());
    }

    if (!simulationControl->isSolarDistributionDefaulted()){
      idfObject.setString(openstudio::BuildingFields::SolarDistribution, simulationControl->solarDistribution());
    }

    if (!simulationControl->isMaximumNumberofWarmupDaysDefaulted()){
      idfObject.setInt(openstudio::BuildingFields::MaximumNumberofWarmupDays, simulationControl->maximumNumberofWarmupDays());
    }

    if (!simulationControl->isMinimumNumberofWarmupDaysDefaulted()) {
      idfObject.setInt(openstudio::BuildingFields::MinimumNumberofWarmupDays, simulationControl->minimumNumberofWarmupDays());
    }
  }

  // translate shading groups
  ShadingSurfaceGroupVector shadingSurfaceGroups = modelObject.shadingSurfaceGroups();
  std::sort(shadingSurfaceGroups.begin(), shadingSurfaceGroups.end(), WorkspaceObjectNameLess());
  for (ShadingSurfaceGroup& shadingSurfaceGroup : shadingSurfaceGroups){
    translateAndMapModelObject(shadingSurfaceGroup);
  }

  return boost::optional<IdfObject>(idfObject);
}
Beispiel #25
0
int main ()
{
	Building* b = new Building ("SoftUni", "SoftUni", 11, 106, 200, 60) ;
	cout <<(b->getBldgInfo()) <<endl  ;
	return 0;
}
void
NetworkManager::CreateBuildingForFemtocells (int idBuilding,
											 int buildingType,
											 double apartmentSide,
											 int nbFloors,
											 double pos_X,
											 double pos_Y,
											 int firstFemtoCellID,
											 int nbOfFemtocells)
{

	double side_X;
	double side_Y;

	if ( buildingType == 0)
	{
		side_X = 5 * apartmentSide;
		side_Y = 5 * apartmentSide;
	}
	else
	{
		side_X = 10 * apartmentSide;
		side_Y = 5 * apartmentSide;
	}

  Building* building = new Building (idBuilding,
									   buildingType,
									   nbFloors,
									   side_X,
									   side_Y,
									   pos_X,
									   pos_Y);

	// CREATE FEMTO _CELLS
	int idCell;

	for (int floor = 0; floor < nbFloors; floor++ )
	{
		int femtocellIndex = 0;
		while ( femtocellIndex < nbOfFemtocells )
		{
			idCell = femtocellIndex + firstFemtoCellID;

			double* offset = GetFemtoCellOffsetInBuilding ( building->GetBuildingType(), femtocellIndex, apartmentSide);

			building->AddFemtoCell( CreateFemtoCell( idCell,
					apartmentSide,
					offset[0] + pos_X,
					offset[1] + pos_Y) );

			GetFemtoCellByID(idCell)->GetCellCenterPosition()->SetCoordinateZ( floor );

			delete [] offset;

			femtocellIndex++;
		}
	}

	GetBuildingContainer()->push_back(building);

}