void SPFlowregionExclude::UpdateComputed(void) { SPObject* object=SP_OBJECT(this); if (computed) { delete computed; computed = NULL; } for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { GetDest(child,&computed); } }
void SPFlowregion::UpdateComputed(void) { SPObject* object=SP_OBJECT(this); for (std::vector<Shape*>::iterator it = computed.begin() ; it != computed.end() ; it++) delete *it; computed.clear(); for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { Shape *shape = NULL; GetDest(child,&shape); computed.push_back(shape); } }
void Room::Update() { float east = m_tilesize.x * m_gridsize.x * 0.5f; float west = -east; float south = m_tilesize.y * m_gridsize.y * 0.5f; float north = -south; float smallDistX = 20.0f; // TODO CONFIG float smallDistY = 40.0f; // TODO CONFIG bool changeLoc = false; int destLocation = 0; Vec3f destPos; // Check if local player has left room Player* p = GetLocalPlayer(); if (p) { Vec3f pos = p->GetPos(); if (pos.x < west + smallDistX) { int w = GetDest(AMJU_ROOM_W); if (w) { // Go to West room changeLoc = true; destLocation = w; destPos = pos; Vec2f size = GetRoomSize(w); // get size of dest room destPos.x = size.x * 0.5f - smallDistX; } } else if (pos.x > east - smallDistX) { int e = GetDest(AMJU_ROOM_E); if (e) { // Go to East room changeLoc = true; destLocation = e; destPos = pos; Vec2f size = GetRoomSize(e); // get size of dest room destPos.x = size.x * -0.5f + smallDistX; } } if (pos.z > south - smallDistY) // off bottom { int s = GetDest(AMJU_ROOM_S); if (s) { // Go to West room changeLoc = true; destLocation = s; destPos = pos; Vec2f size = GetRoomSize(s); // Get size of dest room destPos.z = size.y * -0.5f + smallDistY; } } else if (pos.z < north + smallDistY) // up, off top of room { int n = GetDest(AMJU_ROOM_N); if (n) { // Go to East room changeLoc = true; destLocation = n; destPos = pos; Vec2f size = GetRoomSize(n); // Get size of dest room destPos.z = size.y * 0.5f - smallDistY; } } if (changeLoc) { SetLocalPlayerLocation(destLocation); // LocalPlayer // Just do this, and wait for round trip from server. Ensures consistency..? TheObjectUpdater::Instance()->SendChangeLocationReq(p->GetId(), destPos, destLocation); // Set new position immediately p->SetPos(destPos); p->MoveTo(destPos); // stop moving ? return; } // Check for collision with obstacles layer (tilemap [1]) // (Another way could be to create an Obstacle game object for each tile, // but this is linear time anyway.) TileVec& tv = m_tiles[1]; for (TileVec::iterator it = tv.begin(); it != tv.end(); ++it) { Tile& tile = *it; Vec3f& pos = tile.m_pos; Vec2f& size = tile.m_size; AABB aabb(pos.x,pos.x + size.x, 0, 10, pos.y, pos.y + size.y); if (aabb.Intersects(p->GetAABB())) { // Slow down if in contact with obstacle?? //Vec3f vel = p->GetVel(); //vel *= 0.5f; // TODO Config //p->SetVel(vel); UnCollide(p, p->GetOldPos(), aabb); } } } }