Exemple #1
0
	void Door::Update(float delta)
	{
		if(!_active && _counter < 1.0f)
		{
			Player *player = Player::GetSharedInstance();
			
			if(player->GetWorldPosition().GetDistance(GetWorldPosition() - GetForward()) <= 1.0f)
			{
				_active = true;
			}
		}
		else
		{
			Rotate(RN::Vector3(delta*70.0f, 0.0f, 0.0f));
			_counter += delta;
		}
		
		if(_counter > 1.0f && _active)
		{
			_active = false;
			RN::Kernel::GetSharedInstance()->ScheduleFunction([](){
				World *world = static_cast<World*>(RN::World::GetActiveWorld());
				world->SetLevel(world->GetLevel() + 1);
				world->DropSceneNodes();
				world->LoadOnThread(RN::Thread::GetCurrentThread(), nullptr);
			});
		}
	}