Player::Player(){ Entity(); m_Speed = 0.2; m_MaxVel = 3.2; m_Velocity = 0; }
Marciano::Marciano() { Entity(); }
void localservertoclient(uchar *buf, int len) // processes any updates from the server { if (ENET_NET_TO_HOST_16(*(ushort *)buf) != len) neterr("packet length"); incomingdemodata(buf, len); uchar *end = buf + len; uchar *p = buf + 2; char text[MAXTRANS]; int cn = -1, type; Sprite *spr = NULL; bool mapchanged = false; while (p < end) switch (type = getint(p)) { case SV_INITS2C: // welcome messsage from the server { cn = getint(p); int prot = getint(p); if (prot != PROTOCOL_VERSION) { conoutf( "you are using a different game protocol (you: %d, server: %d)", PROTOCOL_VERSION, prot); disconnect(); return; }; toservermap = ""; clientnum = cn; // we are now fully connected if (!getint(p)) { toservermap = getclientmap(); // we are the first client on this server, set map } sgetstr(); if (text[0] && strcmp(text, clientpassword)) { conoutf( "you need to set the correct password to join this server!"); disconnect(); return; }; if (getint(p) == 1) { conoutf("server is FULL, disconnecting.."); }; break; } case SV_POS: // position of another client { cn = getint(p); spr = getclient(cn); if (!spr) return; spr->o.x = getint(p) / DMF; spr->o.y = getint(p) / DMF; spr->o.z = getint(p) / DMF; spr->yaw = getint(p) / DAF; spr->pitch = getint(p) / DAF; spr->roll = getint(p) / DAF; spr->vel.x = getint(p) / DVF; spr->vel.y = getint(p) / DVF; spr->vel.z = getint(p) / DVF; int f = getint(p); spr->strafe = (f & 3) == 3 ? -1 : f & 3; f >>= 2; spr->move = (f & 3) == 3 ? -1 : f & 3; spr->onfloor = (f >> 2) & 1; int state = f >> 3; if (state == CS_DEAD && spr->state != CS_DEAD) spr->lastaction = lastmillis; spr->state = state; if (!demoplayback) updatepos(spr); break; } case SV_SOUND: playsound(getint(p), &spr->o); break; case SV_TEXT: sgetstr(); conoutf("%s:\f %s", spr->name, text); break; case SV_MAPCHANGE: sgetstr(); changemapserv(text, getint(p)); mapchanged = true; break; case SV_ITEMLIST: { int n; if (mapchanged) { senditemstoserver = false; resetspawns(); }; while ((n = getint(p)) != -1) { if (mapchanged) setspawn(n, true); } break; } case SV_MAPRELOAD: // server requests next map { getint(p); std::string nextmapalias = std::string("nextmap_") + getclientmap(); std::string map = getalias(nextmapalias); // look up map in the cycle changemap(map.empty() ? getclientmap() : map); break; } case SV_INITC2S: // another client either connected or changed name/team { sgetstr(); if (spr->name[0]) { // already connected if (strcmp(spr->name, text)) conoutf("%s is now known as %s", spr->name, text); } else { // new client c2sinit = false; // send new players my info again conoutf("connected: %s", text); }; strcpy_s(spr->name, text); sgetstr(); strcpy_s(spr->team, text); spr->lifesequence = getint(p); break; } case SV_CDIS: cn = getint(p); if (!(spr = getclient(cn))) break; conoutf("player %s disconnected", spr->name[0] ? spr->name : "[incompatible client]"); zapSprite(players[cn]); break; case SV_SHOT: { int gun = getint(p); Vec3 s, e; s.x = getint(p) / DMF; s.y = getint(p) / DMF; s.z = getint(p) / DMF; e.x = getint(p) / DMF; e.y = getint(p) / DMF; e.z = getint(p) / DMF; if (gun == GUN_SG) createrays(s, e); shootv(gun, s, e, spr); break; } case SV_DAMAGE: { int target = getint(p); int damage = getint(p); int ls = getint(p); if (target == clientnum) { if (ls == player1->lifesequence) selfdamage(damage, cn, spr); } else playsound(S_PAIN1 + rnd(5), &getclient(target)->o); break; } case SV_DIED: { int actor = getint(p); if (actor == cn) { conoutf("%s suicided", spr->name); } else if (actor == clientnum) { int frags; if (isteam(player1->team, spr->team)) { frags = -1; conoutf("you fragged a teammate (%s)", spr->name); } else { frags = 1; conoutf("you fragged %s", spr->name); }; addmsg(1, 2, SV_FRAGS, player1->frags += frags); } else { Sprite *a = getclient(actor); if (a) { if (isteam(a->team, spr->name)) { conoutf("%s fragged his teammate (%s)", a->name, spr->name); } else { conoutf("%s fragged %s", a->name, spr->name); }; }; }; playsound(S_DIE1 + rnd(2), &spr->o); spr->lifesequence++; break; } case SV_FRAGS: players[cn]->frags = getint(p); break; case SV_ITEMPICKUP: setspawn(getint(p), false); getint(p); break; case SV_ITEMSPAWN: { int i = getint(p); setspawn(i, true); if (i >= entityList.size()) break; Vec3 v = { entityList[i].x, entityList[i].y, entityList[i].z }; playsound(S_ITEMSPAWN, &v); break; } case SV_ITEMACC: // server acknowledges that I picked up this item realpickup(getint(p), player1); break; case SV_EDITH: // coop editing messages, should be extended to include all possible editing ops case SV_EDITT: case SV_EDITS: case SV_EDITD: case SV_EDITE: { int x = getint(p); int y = getint(p); int xs = getint(p); int ys = getint(p); int v = getint(p); Rect b = { x, y, xs, ys }; switch (type) { case SV_EDITH: editheightxy(v != 0, getint(p), b); break; case SV_EDITT: edittexxy(v, getint(p), b); break; case SV_EDITS: edittypexy(v, b); break; case SV_EDITD: setvdeltaxy(v, b); break; case SV_EDITE: editequalisexy(v != 0, b); break; }; break; } case SV_EDITENT: // coop edit of ent { int i = getint(p); while (entityList.size() <= i) { entityList.emplace_back(Entity()); entityList.back().type = NOTUSED; } int to = entityList[i].type; entityList[i].type = getint(p); entityList[i].x = getint(p); entityList[i].y = getint(p); entityList[i].z = getint(p); entityList[i].attr1 = getint(p); entityList[i].attr2 = getint(p); entityList[i].attr3 = getint(p); entityList[i].attr4 = getint(p); entityList[i].spawned = false; if (entityList[i].type == LIGHT || to == LIGHT) calclight(); break; } case SV_PING: getint(p); break; case SV_PONG: addmsg(0, 2, SV_CLIENTPING, player1->ping = (player1->ping * 5 + lastmillis - getint(p)) / 6); break; case SV_CLIENTPING: players[cn]->ping = getint(p); break; case SV_GAMEMODE: nextmode = getint(p); break; case SV_TIMEUP: timeupdate(getint(p)); break; case SV_RECVMAP: { sgetstr(); conoutf("received map \"%s\" from server, reloading..", text); int mapsize = getint(p); writemap(text, mapsize, p); p += mapsize; changemapserv(text, gamemode); break; } case SV_SERVMSG: sgetstr(); conoutf("%s", text); break; case SV_EXT: // so we can messages without breaking previous clients/servers, if necessary { for (int n = getint(p); n; n--) getint(p); break; } default: neterr("type"); return; } }
void PhysicsData::reset(void) { data.data = nullptr; data.entity = Entity(); }
void makeEntites() { sphereModel = createSphere(shader1, 0, 30, 30, 1.0f); cylinderModel = createCylinder(shader1, 0, 30, 2.0f, 1.0f, 1.0f); legLeft = Entity(Vector3(0, -1.5, 0), cylinderModel); legRight = Entity(Vector3(0, -1.5, 0), cylinderModel); kneeLeft = Entity(Vector3(0, -1.5, 0), sphereModel); kneeRight = Entity(Vector3(0, -1.5, 0), sphereModel); thighLeft = Entity(Vector3(-.5, -1.5, 0), cylinderModel); thighRight = Entity(Vector3(.5, -1.5, 0), cylinderModel); cylinder1 = Entity(Vector3(0, 0, 0), cylinderModel); cylinder1.setScale(.2, .2, .2); thighLeft.setScale(.4, .4, .4); thighRight.setScale(.4, .4, .4); cylinder1.addChild(&thighLeft); cylinder1.addChild(&thighRight); thighLeft.addChild(&kneeLeft); thighRight.addChild(&kneeRight); kneeLeft.addChild(&legLeft); kneeRight.addChild(&legRight); skybox = new Skybox(skyboxShader, images["skybox"]); wallModel = createCube(wallShader, images["cubeTexture"]); enemyModel = createCube(wallShader, images["slimeTexture"]); floorModel = createCube(wallShader, images["cubeTexture2"]); flagModel = createCube(wallShader, images["flagTexture"]); saveFlag = new Entity(Vector3(0,0,0), flagModel); saveFlag->setScale(.2, 5, .2); levels[currLevel]->initLevel(wallModel, floorModel); Title = new Text(textShader, images["font1"], 30, 35); Title->setPosition(Vector3(-220, 120, 0)); PlayBut = new Text(textShader, images["font1"], 20,25); PlayBut->setPosition(Vector3(-210, 20, 0)); ControlsBut = new Text(textShader, images["font1"], 20, 25); ControlsBut->setPosition(Vector3(-210, -10, 0)); notice = new Text(textShader, images["font1"], 15, 20); CreditsBut = new Text(textShader, images["font1"], 20, 25); CreditsBut->setPosition(Vector3(-210, -40, 0)); Exitbut = new Text(textShader, images["font1"], 20, 25); Exitbut->setPosition(Vector3(-210, -70, 0)); Restartbut = new Text(textShader, images["font1"], 20, 25); Restartbut->setPosition(Vector3(-210, -100, 0)); Paused = new Text(textShader, images["font1"], 20, 25); Paused->setColor(Color(1, 0, 0,1)); Back = new Text(textShader, images["font1"], 20, 25); Back->setColor(Color(1, 1, 0, 1)); Credits1 = new Text(textShader, images["font1"], 20, 25); Credits1->setPosition(Vector3(-250, 50, 0)); time = new Text(textShader, images["font1"], 20, 25); Credits2 = new Text(textShader, images["font1"], 20, 25); Credits2->setPosition(Vector3(-270, 0, 0)); Controls1 = new Text(textShader, images["font1"], 15, 20); Controls1->setPosition(Vector3(-250, 120, 0)); Controls2 = new Text(textShader, images["font1"], 15, 20); Controls2->setPosition(Vector3(-250, 60, 0)); Controls3 = new Text(textShader, images["font1"], 15, 20); Controls3->setPosition(Vector3(-250, 0, 0)); Controls4 = new Text(textShader, images["font1"], 15, 20); Controls4->setPosition(Vector3(-250, -60, 0)); Controls5 = new Text(textShader, images["font1"], 15, 20); Controls5->setPosition(Vector3(-250, -120, 0)); Controls6 = new Text(textShader, images["font1"], 15, 20); Controls6->setPosition(Vector3(-250, -180, 0)); Loading = new Text(textShader, images["font1"], 15, 20); Loading->setPosition(Vector3(-60, 120, 0)); for (int i = 0; i < 30; i++){ enemies[i] = new Enemy(Vector3(0,-.5,0),enemyModel); enemies[i]->setScale(3,.5,3); } }
//----------------------------------------------------------------------------- // Purpose: All types must be able to display as strings for debugging purposes. // Output : Returns a pointer to the string that represents this value. // // NOTE: The returned pointer should not be stored by the caller as // subsequent calls to this function will overwrite the contents // of the buffer! //----------------------------------------------------------------------------- const char *variant_t::ToString( void ) const { COMPILE_TIME_ASSERT( sizeof(string_t) == sizeof(int) ); static char szBuf[512]; switch (fieldType) { case FIELD_STRING: { return(STRING(iszVal)); } case FIELD_BOOLEAN: { if (bVal == 0) { Q_strncpy(szBuf, "false",sizeof(szBuf)); } else { Q_strncpy(szBuf, "true",sizeof(szBuf)); } return(szBuf); } case FIELD_INTEGER: { Q_snprintf( szBuf, sizeof( szBuf ), "%i", iVal ); return(szBuf); } case FIELD_FLOAT: { Q_snprintf(szBuf,sizeof(szBuf), "%g", flVal); return(szBuf); } case FIELD_COLOR32: { Q_snprintf(szBuf,sizeof(szBuf), "%d %d %d %d", (int)rgbaVal.r, (int)rgbaVal.g, (int)rgbaVal.b, (int)rgbaVal.a); return(szBuf); } case FIELD_VECTOR: { Q_snprintf(szBuf,sizeof(szBuf), "[%g %g %g]", (double)vecVal[0], (double)vecVal[1], (double)vecVal[2]); return(szBuf); } case FIELD_VOID: { szBuf[0] = '\0'; return(szBuf); } case FIELD_EHANDLE: { const char *pszName = (Entity()) ? STRING(Entity()->GetEntityName()) : "<<null entity>>"; Q_strncpy( szBuf, pszName, 512 ); return (szBuf); } } return("No conversion to string"); }
std::vector<Entity> Entity::watch(cv::Mat image, std::vector<Entity> known, int timeMS, bool newWorldType) { std::vector<Entity> ret; // Find holes in the ground int startX = -1; int endX = -1; for (int i = 0; i < image.cols; i++) { while (image.at<cv::Vec3b>(205, i) == holeColor) { if (startX > -1) { endX = i; } else { startX = i; } if (++i >= image.cols) { break; } } if (startX > -1) { if (endX - startX > 16) { ret.push_back(Entity(cv::Rect(startX, 205, endX - startX, 5), EntityType::HOLE, timeMS)); } startX = -1; endX = -1; } } cv::Mat result; cv::Point minLoc; cv::Point maxLoc; double minVal; double maxVal; int method = cv::TM_SQDIFF; int origWidth = image.size().width; int result_cols; int result_rows; // Search the entire image (other than top 40) for bricks cv::Mat brickImage = image(cv::Rect(0, 40, image.size().width, image.size().height - 40)); // Create the result matrix result_cols = brickImage.cols - spriteTable[EntityType::BRICK].cols + 1; result_rows = brickImage.rows - spriteTable[EntityType::BRICK].rows + 1; result.create(result_rows, result_cols, CV_32FC1); // Do the Matching and Normalize cv::matchTemplate(brickImage, spriteTable[EntityType::BRICK], result, method); // Try and find the first enemy template while (true) { cv::minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, cv::Mat()); // minLoc = cv::Point(minLoc.x + spriteTable[t].cols - 1, minLoc.y + spriteTable[t].rows - 1); if (minVal < getDetThresh(EntityType::BRICK)) { cv::Point originLoc = minLoc; originLoc.y += 40; ret.push_back(Entity(originLoc, EntityType::BRICK, timeMS)); } else { break; } result.at<float>(minLoc) = getDetThresh(EntityType::BRICK); } // Search the bottom and the top for beams cv::Mat beamSearchTop = image(cv::Rect(0, 24, image.size().width, 40)).clone(); cv::Mat beamSearchBot = image(cv::Rect(0, image.size().height - 40, image.size().width, 40)).clone(); // Create the result matrix result_cols = beamSearchTop.cols - spriteTable[EntityType::BEAM].cols + 1; result_rows = beamSearchTop.rows - spriteTable[EntityType::BEAM].rows + 1; result.create(result_rows, result_cols, CV_32FC1); // Remove currently known beams for (int i = 0; i < known.size(); i++) { if (known[i].getType() == EntityType::BEAM) { cv::Rect bbox = known[i].getBBox(); bbox.y -= 24; cv::rectangle(beamSearchTop, bbox, cv::Scalar::all(255), CV_FILLED); bbox.y -= (image.size().height - 64); cv::rectangle(beamSearchBot, bbox, cv::Scalar::all(255), CV_FILLED); } } // Do the Matching and Normalize cv::Mat resultTop, resultBot; cv::Point minLocTop, minLocBot; cv::Point maxLocTop, maxLocBot; double minValTop, minValBot; double maxValTop, maxValBot; cv::matchTemplate(beamSearchTop, spriteTable[EntityType::BEAM], resultTop, method); cv::matchTemplate(beamSearchBot, spriteTable[EntityType::BEAM], resultBot, method); // Try and find the first beam template cv::minMaxLoc(resultTop, &minValTop, &maxValTop, &minLocTop, &maxLocTop, cv::Mat()); cv::minMaxLoc(resultBot, &minValBot, &maxValBot, &minLocBot, &maxLocBot, cv::Mat()); // minLoc = cv::Point(minLoc.x + spriteTable[t].cols - 1, minLoc.y + spriteTable[t].rows - 1); if (minValTop < getDetThresh(EntityType::BEAM)) { // We found one minLocTop.y += 24; ret.push_back(Entity(minLocTop, EntityType::BEAM, timeMS)); } if (minValBot < getDetThresh(EntityType::BEAM)) { // We found one minLocBot.y += (image.size().height - 40); ret.push_back(Entity(minLocBot, EntityType::BEAM, timeMS)); } // Now only look at the right (regular entities) unless we are in a new world int watchWidth = 40; if (newWorldType) { watchWidth = image.size().width; } image = image(cv::Rect(image.size().width - watchWidth, 40, watchWidth, image.size().height - 40)); for (EntityType t = EntityType::GOOMBA; t != EntityType::SIZE_ENTITY_TYPE; t = static_cast<EntityType>(t + 1)) { if (t == EntityType::HOLE || t == EntityType::BEAM || t == EntityType::BRICK || t == EntityType::BEAM) { continue; } // Create the result matrix int result_cols = image.cols - spriteTable[t].cols + 1; int result_rows = image.rows - spriteTable[t].rows + 1; result.create(result_rows, result_cols, CV_32FC1); cv::Mat maskedImage = image.clone(); for (int i = 0; i < known.size(); i++) { if (known[i].getType() == t) { cv::Rect bbox = known[i].getBBox(); bbox.x -= (origWidth - maskedImage.cols); bbox.y -= 40; // std::cout << bbox.x << std::endl; cv::rectangle(maskedImage, bbox, cv::Scalar::all(255), CV_FILLED); } } // Do the Matching and Normalize cv::matchTemplate(maskedImage, spriteTable[t], result, method); while (true) { cv::minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, cv::Mat()); // minLoc = cv::Point(minLoc.x + spriteTable[t].cols - 1, minLoc.y + spriteTable[t].rows - 1); if (minVal < getDetThresh(t)) { cv::Point originLoc = minLoc; originLoc.x += (origWidth - maskedImage.cols); originLoc.y += 40; ret.push_back(Entity(originLoc, t, timeMS)); } else { break; } result.at<float>(minLoc) = getDetThresh(t); } } return ret; }
int FalconTrackMessage::Process(uchar autodisp) { if (autodisp){ return 0; } FalconEntity *theEntity = static_cast<FalconEntity*>(Entity()); if (!theEntity){ return 0; } FalconEntity *taggedEntity = static_cast<FalconEntity*>(vuDatabase->Find(dataBlock.id)); // 2002-02-25 ADDED BY S.G. 'Entity' can be a campaign object if the missile being launch // (ie, dataBlock.trackType is Launch) is a SARH and its platform is still aggregated since // the platform becomes the launching object. Get in if it's a Mover class only... if (theEntity->IsMover()){ SimMoverClass *mEntity = static_cast<SimMoverClass*>(theEntity); if ( !mEntity->IsLocal () && mEntity->numSensors > 1 && // MN 2002-03-03 CTD mEntity->sensorArray[1] && // JB 010604 CTD mEntity->IsAirplane() ){ #if NO_REMOTE_BUGGED_TARGET // sfr: there should be a higher level function for doing this all... if (dataBlock.trackType == Track_Lock){ SimObjectType *nt = new SimObjectType(taggedEntity); mEntity->sensorArray[1]->SetSensorTarget(nt); //mEntity->SetTarget(nt); } else if (dataBlock.trackType == Track_Unlock){ mEntity->sensorArray[1]->SetSensorTarget(NULL); //mEntity->SetTarget(NULL); } #else if (dataBlock.trackType == Track_Lock){ mEntity->sensorArray[1]->RemoteBuggedTarget = taggedEntity; } else if (dataBlock.trackType == Track_Unlock){ mEntity->sensorArray[1]->RemoteBuggedTarget = NULL ; } #endif } } if (taggedEntity){ // HACK HACK HACK! This should be status info on the aircraft concerned... // check for smoke on/off messages if (dataBlock.trackType == Track_SmokeOn){ ((AircraftClass *)taggedEntity)->playerSmokeOn = TRUE; } else if (dataBlock.trackType == Track_SmokeOff){ ((AircraftClass *)taggedEntity)->playerSmokeOn = FALSE; } else if (dataBlock.trackType == Track_JettisonAll){ if ((!IsLocal ()) && (taggedEntity->IsAirplane ())){ //MonoPrint ("JettisonAll %08x\n", dataBlock.id, dataBlock.hardpoint); ((AircraftClass*)taggedEntity)->Sms->EmergencyJettison (); } } else if (dataBlock.trackType == Track_JettisonWeapon){ if ((!IsLocal ()) && (taggedEntity->IsAirplane ())){ //MonoPrint ("Jettison Weapon %08x %d\n", dataBlock.id, dataBlock.hardpoint); ((AircraftClass*)taggedEntity)->Sms->JettisonWeapon (dataBlock.hardpoint); } } else if (dataBlock.trackType == Track_RemoveWeapon){ if ((!IsLocal ()) && (taggedEntity->IsAirplane ())){ //MonoPrint ("RemoveWeapon %08x %d\n", dataBlock.id, dataBlock.hardpoint); ((AircraftClass*)taggedEntity)->Sms->RemoveWeapon (dataBlock.hardpoint); } } else if (taggedEntity->IsLocal()){ // 2002-02-09 COMMENT BY S.G. // In here, hardpoint will be used to specify the kind of radar mode the radar was in when. if (taggedEntity->IsAirplane()){ // Find RWR and/or HTS for (int j=0; j<((SimVehicleClass*)taggedEntity)->numSensors; j++){ if (((SimVehicleClass*)taggedEntity)->sensorArray[j]->Type() == SensorClass::RWR){ ((RwrClass*)((SimVehicleClass*)taggedEntity)->sensorArray[j])->ObjectDetected( theEntity, dataBlock.trackType, dataBlock.hardpoint ); // 2002-02-09 MODIFIED BY S.G. Added hardpoint to ObjectDetected } if (((SimVehicleClass*)taggedEntity)->sensorArray[j]->Type() == SensorClass::HTS){ ((RwrClass*)((SimVehicleClass*)taggedEntity)->sensorArray[j])->ObjectDetected( theEntity, dataBlock.trackType, dataBlock.hardpoint ); // 2002-02-09 MODIFIED BY S.G. Added hardpoint to ObjectDetected } } } else if (taggedEntity->IsFlight()){ if ((dataBlock.trackType == Track_Lock) || (dataBlock.trackType == Track_Launch)){ // Tell the campaign entity that it's being locked on to. ((Flight)taggedEntity)->RegisterLock(theEntity); } } } } return 1; }
void Entity::destroy() { if(physicsObject) physicsObject->destroy(); *this = Entity(); }
////////////////////////////////////////////////////////////////////////// // update //virtual void ScnCore::update() { // Tick all entities. BcReal Tick = SysKernel::pImpl()->getFrameTime(); // Do add/remove. processAddRemove(); // Update all entities. for( ScnEntityListIterator It( EntityList_.begin() ); It != EntityList_.end(); ++It ) { ScnEntityRef Entity( *It ); if( Entity.isReady() ) // HACK. Put in a list along side the main one to test. { Entity->update( Tick ); } } // Render to all clients. // TODO: Move client/context into the view component instead. // TODO: Use spatial tree to render. for( BcU32 Idx = 0; Idx < OsCore::pImpl()->getNoofClients(); ++Idx ) { // Grab client. OsClient* pClient = OsCore::pImpl()->getClient( Idx ); // Get context. RsContext* pContext = RsCore::pImpl()->getContext( pClient ); // Allocate a frame to render using default context. RsFrame* pFrame = RsCore::pImpl()->allocateFrame( pContext ); // Iterate over all view components. for( ScnViewComponentListIterator It( ViewComponentList_.begin() ); It != ViewComponentList_.end(); ++It ) { ScnViewComponentRef ViewComponent( *It ); ViewComponent->bind( pFrame, RsRenderSort( 0 ) ); for( ScnEntityListIterator It( EntityList_.begin() ); It != EntityList_.end(); ++It ) { ScnEntityRef& Entity( *It ); if( Entity.isReady() ) // HACK. Put in a list along side the main one to test. { for( BcU32 ComponentIdx = 0; ComponentIdx < Entity->getNoofComponents(); ++ComponentIdx ) { ScnMaterialComponentRef MaterialComponent( Entity->getComponent( ComponentIdx ) ); if( MaterialComponent.isValid() ) { ViewComponent->setMaterialParameters( MaterialComponent ); } } Entity->render( pFrame, RsRenderSort( 0 ) ); } } } // Queue frame for render. RsCore::pImpl()->queueFrame( pFrame ); } }
int FalconFACMessage::Process(uchar autodisp) { SimVehicleClass* theEntity; SimVehicleClass* theFighter; if (autodisp) return 0; theEntity = (SimVehicleClass*)Entity(); if (!theEntity) theEntity = (SimVehicleClass*)(vuDatabase->Find (EntityId())); theFighter = (SimVehicleClass*)(vuDatabase->Find (dataBlock.caller)); if(!theFighter) // PJW: E3 Hack... make sure (theFighter) is valid return 0; switch (dataBlock.type) { case CheckIn: if (theEntity && theEntity->IsLocal()) ((FACBrain*)theEntity->Brain())->AddToQ(theFighter); // Play message here if (theFighter != SimDriver.playerEntity) { } break; case Wilco: // Play message here if (theFighter != SimDriver.playerEntity) { } break; case Unable: // Play message here if (theFighter != SimDriver.playerEntity) { } break; case In: // Play message here if (theFighter != SimDriver.playerEntity) { } break; case Out: // Play message here if (theFighter != SimDriver.playerEntity) { } break; case RequestMark: break; case RequestTarget: if (theEntity && theFighter && theEntity->IsLocal()) ((FACBrain*)theEntity->Brain())->RequestTarget(theFighter); break; case RequestBDA: if (theEntity && theFighter && theEntity->IsLocal()) ((FACBrain*)theEntity->Brain())->RequestBDA(theFighter); break; case RequestLocation: if (theEntity && theEntity->IsLocal()) ((FACBrain*)theEntity->Brain())->RequestLocation(); break; case RequestTACAN: if (theEntity && theEntity->IsLocal()) ((FACBrain*)theEntity->Brain())->RequestTACAN(); break; case HoldAtCP: break; case FacSit: break; case Mark: break; case NoTargets: break; case GroundTargetBr: break; case BDA: break; case NoBDA: break; case ReattackQuery: if (theFighter && theFighter->IsLocal()) { } break; case HartsTarget: break; case HartsOpen: if (theFighter && theFighter->IsLocal()) { } break; case ScudLaunch: break; case SanitizeLZ: break; case AttackMyTarget: if (theFighter && theFighter->IsLocal()) { } break; case SendChoppers: break; }; return 0; }
Entity *ResourceManager::createEntity(std::string nome) { g_entitymap.insert(nome, Entity() ); return &g_entitymap.find(nome).value(); }
Entity Entity::getParent() const { if (impl_.get()) return *impl_->parent_; else return Entity(); }
TEST(Entity, render) { Entity e = Entity(); Window w({{0,0},{10,10}}); // 10x10 Window in top-left position e.render(w); // Void function - deprecated anyway }
void PlatformerGame::Init() { SDL_Init(SDL_INIT_VIDEO); displayWindow = SDL_CreateWindow("My Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL); SDL_GLContext context = SDL_GL_CreateContext(displayWindow); SDL_GL_MakeCurrent(displayWindow, context); glViewport(0, 0, 800, 600); glMatrixMode(GL_PROJECTION); glOrtho(-1.33, 1.33, -1.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); keys = SDL_GetKeyboardState(NULL); GLuint sprites = loadTexture("sprites.png"); Entity player = Entity(sprites, 0.0f, 0.0f, 64.0 / 256.0f, 64.0 / 256.0f, true, false); player.setX(0.0f); player.setY(-0.5f); player.setScale(0.3); //player.insertUVPoints(0.0f, (66.0 / 256.0f)); //Facing left - 0,1 //player.insertUVPoints((66.0 / 256.0f), (66.0 / 256.0f)); //Facing left idle - 2,3 //player.insertUVPoints(0.0f, (66.0 / 256.0f)); //Facing left - 4,5 //player.insertUVPoints(0.0f, (132.0 / 25.0f)); //Facing right - 6,7 //player.insertUVPoints((66.0 / 256.0f), 0.0f); //Facing right idle - 8,9 //player.insertUVPoints((66.0 / 256.0f), (132.0 / 256.0f)); //Facing right - 10,11 dynamicEntities.push_back(player); Entity floor = Entity(sprites, 0.0f, 198.0 / 256.0f, 48.0 / 256.0f, 48.0 / 256.0f, true, true); floor.setY(-0.9f); floor.setX(-0.9f); floor.setScale(0.3); for (int floorCount = 0; floorCount < 18; floorCount++) { floor.setX(floor.getX() + (48.0 / 256.0)*0.5); staticEntities.push_back(floor); } Entity floor1 = Entity(sprites, 0.0f, 198.0 / 256.0f, 48.0 / 256.0f, 48.0 / 256.0f, true, true); floor1.setY(-0.3f); floor1.setX(-0.9); floor1.setScale(0.3); for (int floorCounter = 0; floorCounter < 9; floorCounter++) { floor1.setX(floor1.getX() + (48.0 / 256.0)*0.5); staticEntities.push_back(floor1); } Entity wallL = Entity(sprites, 50.0 / 256.0f, 198.0 / 256.0f, 48.0 / 256.0f, 48.0 / 256.0f, true, true); wallL.setX(-0.9); wallL.setY(-0.9); wallL.setScale(0.3); for (int wallCount = 0; wallCount < 20; wallCount++) { wallL.setY(wallL.getY() + (48.0 / 256.0)*0.5); staticEntities.push_back(wallL); } Entity wallR = Entity(sprites, 50.0 / 256.0f, 198.0 / 256.0f, 48.0 / 256.0f, 48.0 / 256.0f, true, true); wallR.setX(0.9); wallR.setY(-0.9); wallR.setScale(0.3); for (int wallCounter = 0; wallCounter < 20; wallCounter++) { wallR.setY(wallR.getY() + (48.0 / 256.0)*0.5); staticEntities.push_back(wallR); } Entity floor2 = Entity(sprites, 0.0f, 198.0 / 256.0f, 48.0 / 256.0f, 48.0 / 256.0f, true, true); floor2.setX(0.0f); floor2.setY(0.3f); floor2.setScale(0.3); for (int floorCounter1 = 0; floorCounter1 < 9; floorCounter1++) { floor2.setX(floor2.getX() + (48.0 / 256.0)*0.5); staticEntities.push_back(floor2); } Entity floor3 = Entity(sprites, 0.0f, 198.0 / 256.0f, 48.0 / 256.0f, 48.0 / 256.0f, true, true); floor3.setY(0.9f); floor3.setX(-0.9f); floor3.setScale(0.3); for (int floorCount3 = 0; floorCount3 < 18; floorCount3++) { floor3.setX(floor3.getX() + (48.0 / 256.0)*0.5); staticEntities.push_back(floor3); } // Creating target entities Entity target = Entity(sprites, 100.0 / 256.0f, 198.0 / 256.0f, 48.0 / 256.0f, 48.0 / 256.0f, true, true); target.setScale(0.5); target.setX(staticEntities[staticEntities.size() - 20].getX()); target.setY(staticEntities[staticEntities.size() - 20].getY() + staticEntities[staticEntities.size() - 20].getHeight() * 0.5); target.setVisible(true); dynamicEntities.push_back(target); }
int main( int argc, char* args[] ) { SDL_Color BACKGROUND_COLOR = SDL_Color(); BACKGROUND_COLOR.r = 0; BACKGROUND_COLOR.g = 0; BACKGROUND_COLOR.b = 0; BACKGROUND_COLOR.a = 255; SDL_Color HUNTER_COLOR = SDL_Color(); HUNTER_COLOR.r = 255; HUNTER_COLOR.g = 0; HUNTER_COLOR.b = 0; HUNTER_COLOR.a = 255; SDL_Color BOUND_COLOR = SDL_Color(); BOUND_COLOR.r = 0; BOUND_COLOR.g = 255; BOUND_COLOR.b = 0; BOUND_COLOR.a = 255; SDL_Color PREY_COLOR = SDL_Color(); PREY_COLOR.r = 0; PREY_COLOR.g = 0; PREY_COLOR.b = 255; PREY_COLOR.a = 255; // Init GUI SDL_Window *screen = NULL; if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 ) { std::cout << "Error on SDL_Init:" << std::endl << SDL_GetError() << std::endl; return 1; } screen = SDL_CreateWindow(WINDOW_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); if( screen == NULL ) { std::cout << "Error on SDL_CreateWindow:" << std::endl << SDL_GetError() << std::endl; return 1; } SDL_Renderer* bgRenderer = NULL; bgRenderer = SDL_CreateRenderer( screen, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); if( bgRenderer == NULL ) { std::cout << "Error on SDL_CreateRenderer:" << std::endl << SDL_GetError() << std::endl; return 1; } // Define neural network LinearNeuralNetwork nn = LinearNeuralNetwork( 0, { 1 }, NULL, NULL ); if(std::ifstream(FILENAME)) { nn = LinearNeuralNetwork( FILENAME, Neuron::SIGMOID, Neuron::SIGMOID_DER ); } else { nn = LinearNeuralNetwork( ALPHA, NEURAL_NETWORK_DESCRIPTOR, Neuron::SIGMOID, Neuron::SIGMOID_DER ); } // Inizialization SDL_Rect bounds = SDL_Rect(); bounds.x = BOUND_MIN_X; bounds.y = BOUND_MIN_Y; bounds.w = BOUND_MAX_X - BOUND_MIN_X; bounds.h = BOUND_MAX_Y - BOUND_MIN_Y; Entity hunter = Entity( HUNTER_WIDTH, HUNTER_HEIGHT, HUNTER_SPEED, HUNTER_START_X, HUNTER_START_Y, bounds, HUNTER_COLOR ); Entity prey = Entity( PREY_WIDTH, PREY_HEIGHT, PREY_SPEED, PREY_START_X, PREY_START_Y, bounds, PREY_COLOR ); // Render clr(bgRenderer,BACKGROUND_COLOR); renderRect(bounds, BOUND_COLOR, bgRenderer, false); renderEntity(hunter, bgRenderer); renderEntity(prey, bgRenderer); SDL_RenderPresent(bgRenderer); // TIMERS SDL_TimerID renderTimerId = SDL_AddTimer(TIME_GAP_RENDER, render_callback, NULL); if( renderTimerId == 0 ) { std::cout << "Error on SDL_AddTimer:" << std::endl << SDL_GetError() << std::endl; return 1; } SDL_TimerID movementTimerId = SDL_AddTimer(TIME_GAP_MOVEMENT, movement_callback, NULL); if( movementTimerId == 0 ) { std::cout << "Error on SDL_AddTimer:" << std::endl << SDL_GetError() << std::endl; return 1; } // main cycle //// structure to read user events SDL_Event event; //// to check when the key is pressed or released bool isKeyPressed[4] = { false, false, false, false }; bool quit = false; while( quit == false ) { bool matchIsOver = false; while(!matchIsOver) { // event handling while( SDL_PollEvent( &event ) ) { switch( event.type ) { case SDL_QUIT: quit = true; break; case SDL_KEYDOWN: // Keyboard input handling - keydown checkKeyPressed( event.key.keysym.sym, isKeyPressed, true ); break; case SDL_KEYUP: // Keyboard input handling - keyup checkKeyPressed( event.key.keysym.sym, isKeyPressed, false ); break; case SDL_USEREVENT: switch(event.user.code) { case RENDER_CB: // Render clr(bgRenderer,BACKGROUND_COLOR); renderRect(bounds, BOUND_COLOR, bgRenderer, false); renderEntity(hunter, bgRenderer); renderEntity(prey, bgRenderer); SDL_RenderPresent(bgRenderer); break; case MOVEMENT_CB: int initialDistance = dist(hunter,prey); // Entities movement hunter.move( actHunter(hunter,prey) ); //userMovement(prey, isKeyPressed); // DEBUG std::vector<float> outputNn = outPrey( hunter, prey, nn ); Entity::Action preyAction = actPrey( outputNn ); prey.move( preyAction ); // check contact if( checkContact( hunter, prey ) ) { std::vector<float> err (5, 0); err[preyAction] = - REWARD_CAPTURE * outputNn[preyAction]; nn.learn( err ); matchIsOver = true; } else { int distance = dist(hunter, prey); // std::cout << "distances" << distance << " " << initialDistance << std::endl; std::vector<float> err (5, 0); if( distance > initialDistance ) { err[preyAction] = ( 1 - outputNn[preyAction] ) * REWARD_DISTANCE; } else if( distance < initialDistance ) { err[preyAction] = - outputNn[preyAction] * REWARD_DISTANCE; } nn.learn( err ); } break; // default: // std::cout << "!!! UserEvent code not defined!!!" << std::endl; // return 1; //break; } break; default: break; } } } hunter.reset(); prey.reset(); } SDL_Quit(); return 0; }
Entity makewiimote(const VRBackendBasics& graphics_objects) { std::vector<Vertex> vertices; VertexType vertex_type = VertexType(std::vector<D3D11_INPUT_ELEMENT_DESC>({ { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, })); vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f })); vertices.push_back(Vertex(vertex_type, { 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f })); Model model = graphics_objects.resource_pool->LoadModel("wiimote", vertices, D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); ConstantBufferTyped<TransformationMatrixAndInvTransData>* object_settings = new ConstantBufferTyped<TransformationMatrixAndInvTransData>(CB_PS_VERTEX_SHADER); object_settings->CreateBuffer(graphics_objects.view_state->device_interface); object_settings->SetBothTransformations(DirectX::XMMatrixMultiply(DirectX::XMMatrixRotationY(3.14f), DirectX::XMMatrixTranslation(0, 0, -4))); object_settings->PushBuffer(graphics_objects.view_state->device_context); return Entity( ES_NORMAL, graphics_objects.resource_pool->LoadPixelShader("shaders.hlsl"), graphics_objects.resource_pool->LoadVertexShader("shaders.hlsl", vertex_type.GetVertexType(), vertex_type.GetSizeVertexType()), ShaderSettings(NULL), model, object_settings); }
void PlayerSystem::onEntityRemoved(Entity & entity) { m_player = Entity(); }
Entity getEntity() { // return (Entity) this.getAncestorOrSelf("org.xbrlapi.Impl.EntityImpl"); return Entity(); }
Field::Field(Loader * loader, GLuint size, glm::vec3 position) : GameObject() { if (size % 2 != 1) throw new invalid_argument("Expected an odd number"); this->size = size; this->position = position; enum SIDE { TOP, RIGHT, BOTTOM, LEFT }; SIDE side = TOP; static vector<TexturedModel> models = loader->objToModel(fieldPath); int sides = 1; int curElement = 0; for (unsigned int i = 0; i < size*size; i++) { int sideLength = sides / 4; if (i == 0) { for (TexturedModel model : models) entities.push_back(Entity(model, position, 0.0f, 0.0f, 0.0f, 1.0f)); sides = 8; continue; } GLfloat x; GLfloat z; int offset = sides / 8; switch (side) { case TOP: { x = position.x - offset + curElement % sideLength; z = position.z - offset; }break; case RIGHT: { x = position.x + offset; z = position.z - offset + curElement % sideLength; }break; case BOTTOM: { x = position.x + offset - curElement % sideLength; z = position.z + offset; }break; case LEFT: { x = position.x - offset; z = position.z + offset - curElement % sideLength; }break; } for (TexturedModel model : models) entities.push_back(Entity(model, glm::vec3(x, 0.0f, z), 0.0f, 0.0f, 0.0f, 1.0f)); // Changing sides if (side == TOP && curElement == (sideLength - 1)) side = RIGHT; else if (side == RIGHT && curElement == (2 * sideLength - 1)) side = BOTTOM; else if (side == BOTTOM && curElement == (3 * sideLength - 1)) side = LEFT; curElement++; // Resetting after a circle if (curElement == sides) { sides = sides + 8; curElement = 0; side = TOP; } } }
int CEntityCheckInComponent::CheckIn(unsigned int nDayIndex) { CCheckInConfig * pCheckInConfig = CCheckInDataManager::Instance().GetCheckInConfig(nDayIndex); if (pCheckInConfig == NULL) { return ECheckInErrorMsg_ConfigError; } // have checkin if (m_CheckInInfo.m_nDayIndex >= nDayIndex) { return ECheckInErrorMsg_HaveCheckIn; } // index CCheckInConfig * pNextCheckInConfig = CCheckInDataManager::Instance().GetNextCheckInConfig(m_CheckInInfo.m_nDayIndex); if (pNextCheckInConfig == NULL || pNextCheckInConfig->m_nDayIndex != nDayIndex) { return ECheckInErrorMsg_DayIndexError; } // vip add int nVipRate = 1; if (m_pRoleVip->IsVIP() && m_pRoleVip->VIPLevel() >= (int)pCheckInConfig->m_nVipRewardLevel && pCheckInConfig->m_nVipRewardLevel >= 1) { nVipRate = pCheckInConfig->m_nVipRewardRate; } nVipRate = nVipRate > 1 ? nVipRate : 1; // item reward if (m_pRoleAttr->GetSex() == ESexType_Male) { CItem maleitem(pCheckInConfig->m_maleItemReward); ItemConfig * pItemInfo = ConfigManager::Instance().GetItemConfigManager().GetByID(pCheckInConfig->m_maleItemReward.m_nItemType); if (pItemInfo != NULL) { if (pItemInfo->IsEquip()) { if (nVipRate > 1) { maleitem.m_nValidTime = -1; } } else { maleitem.m_nItemCount = (itemcount_t)(maleitem.m_nItemCount*nVipRate); } std::list<CItem> listitem; listitem.push_back(maleitem); CItemProcess::AddItems(*(CRoleEntity *)Entity(), listitem, EItemAction_Add_ChekcInReward, 0, true); } } else { CItem femaleitem(pCheckInConfig->m_femaleItemReward); ItemConfig * pItemInfo = ConfigManager::Instance().GetItemConfigManager().GetByID(pCheckInConfig->m_femaleItemReward.m_nItemType); if (pItemInfo != NULL) { if (pItemInfo->IsEquip()) { if (nVipRate > 1) { femaleitem.m_nValidTime = -1; } } else { femaleitem.m_nItemCount = (itemcount_t)(femaleitem.m_nItemCount*nVipRate); } std::list<CItem> listitem; listitem.push_back(femaleitem); CItemProcess::AddItems(*(CRoleEntity *)Entity(), listitem, EItemAction_Add_ChekcInReward, 0, true); } } // money reward m_pRoleAttr->ChangeMoney(pCheckInConfig->m_nMoney*nVipRate, EChangeMoneyCause_Add_CheckIn, 0); // bindcoin reward m_pRoleAttr->ChangeBindBill(pCheckInConfig->m_nBindCoin*nVipRate, EChangeBindBillCause_Add_CheckIn); // set check info m_CheckInInfo.m_nDayIndex = nDayIndex; m_CheckInInfo.m_nCheckInTime = (unsigned int)time(NULL); // save to db SaveCheckInInfoToDB(); // log _LogRoleCheckIn(m_pRoleAttr->GetRoleID(), CRoleCheckInLog::ECheckInAction_Check, nDayIndex, m_pRoleVip->IsVIP(), m_pRoleVip->VIPLevel()); return ECheckInErrorMsg_Success; }
bool running = true; const int window_width = 600,window_height = 600; double old_time = glfwGetTime(); Screen screen= Screen(window_width,window_height);; tPlate plate = tPlate(.5,.2); tPlate square = tPlate(.2,.2); Entity entity=Entity(); int main() { Init(); Main_Loop(); Shut_Down(0); } void Init() { plate.Orient(1,0); plate.Pos(.8,0); square.Orient(1,1); }
#ifndef CHIASMUS_CORE_ENCOSY_ENTITYMANAGER_HPP #define CHIASMUS_CORE_ENCOSY_ENTITYMANAGER_HPP #include <queue> #include <stack> #include "Source/Utility/Utility.hpp" #include "Entity.hpp" /* Used to indicate the absence of an entity. * Immediately, this "entity" is created by * the entity manger and then orphaned. */ const Entity NullEntity = Entity(0,0); class EntityManager { static const uint32 MinimumFreeIndices = 1024; public: EntityManager(); Entity create(); bool alive(Entity e) const; void destroy(Entity e); private: std::queue<uint32> freeIndices; std::vector<uint32> counters; }; #endif // CHIASMUS_CORE_ENCOSY_ENTITYMANAGER_HPP