コード例 #1
0
void CreatureCore::ParseEvents(float deltaTime)
{
	SCOPE_CYCLE_COUNTER(STAT_CreatureCore_ParseEvents);

	float cur_runtime = (creature_manager->getActualRunTime());
	animation_frame = cur_runtime;

	auto load_filename = ConvertToString(absolute_creature_filename);

	auto cur_animation_name = creature_manager->GetActiveAnimationName();

	auto cur_token = GetAnimationToken(load_filename, cur_animation_name);
	CreatureModule::CreatureAnimation * cur_animation = NULL;
	if (global_animations.count(cur_token) > 0)
	{
		cur_animation = global_animations[cur_token].get();
	}


	if (cur_animation)
	{
		int cur_start_time = cur_animation->getStartTime();
		int cur_end_time = cur_animation->getEndTime();

		float diff_val_start = fabs(cur_runtime - cur_start_time);
		const float cutoff = 0.01f;

		if ((diff_val_start <= cutoff)
			&& !is_looping
			&& !play_start_done
			&& should_play)
		{
			play_start_done = true;
			should_process_animation_start = true;
		}

		if ((cur_runtime + 1.0f >= cur_end_time)
			&& !is_looping
			&& !play_end_done
			&& should_play)
		{
			play_end_done = true;
			should_play = false;
			should_process_animation_end = true;
		}
	}

}
コード例 #2
0
bool ACreatureActor::AddLoadedAnimation(const std::string& filename_in, const std::string& name_in)
{
	auto cur_token = GetAnimationToken(filename_in, name_in);
	if (global_animations.count(cur_token) > 0)
	{
		creature_manager->AddAnimation(global_animations[cur_token]);
		creature_manager->SetIsPlaying(true);
		creature_manager->SetShouldLoop(true);
		return true;
	}
	else {
		std::cout << "ERROR! ACreatureActor::AddLoadedAnimation() Animation with filename: " << filename_in << " and name: " << name_in << " not loaded!" << std::endl;
	}

	return false;
}
コード例 #3
0
void ACreatureActor::LoadAnimation(const std::string& filename_in, const std::string& name_in)
{
	auto cur_token = GetAnimationToken(filename_in, name_in);
	if (global_animations.count(cur_token) > 0)
	{
		// animation already exists, just return
		return;
	}

	auto load_data = global_load_data_packets[filename_in];

	std::shared_ptr<CreatureModule::CreatureAnimation> new_animation =
		std::make_shared<CreatureModule::CreatureAnimation>(*load_data, name_in);

	global_animations[cur_token] = new_animation;
}