예제 #1
0
bool 
CreatureCore::RunTick(float delta_time)
{
	std::lock_guard<std::mutex> scope_lock(*update_lock);

	if (is_driven)
	{
		UpdateCreatureRender();
		FillBoneData();

		return true;
	}

	if (is_disabled)
	{
		return false;
	}

	if (creature_manager)
	{
		ParseEvents(delta_time);

		if (should_play) {
			creature_manager->Update(delta_time);
		}

		UpdateCreatureRender();

		FillBoneData();

	}

	return true;
}
void ACreatureActor::Tick(float DeltaTime)
{
	if (creature_manager)
	{
		creature_manager->Update(DeltaTime * animation_speed);
		UpdateCreatureRender();

		FillBoneData();
	}
}
bool ACreatureActor::InitCreatureRender()
{
	FString cur_creature_filename = creature_filename;
	bool does_exist = FPlatformFileManager::Get().GetPlatformFile().FileExists(*cur_creature_filename);
	if (!does_exist)
	{
		// see if it is in the content directory
		cur_creature_filename = FPaths::GameContentDir() + FString(TEXT("/")) + cur_creature_filename;
		does_exist = FPlatformFileManager::Get().GetPlatformFile().FileExists(*cur_creature_filename);
	}

	if (does_exist)
	{
		auto load_filename = ConvertToString(cur_creature_filename);
		// try to load creature
		ACreatureActor::LoadDataPacket(load_filename);
		LoadCreature(load_filename);

		// try to load all animations
		auto all_animation_names = creature_manager->GetCreature()->GetAnimationNames();
		auto first_animation_name = all_animation_names[0];
		for (auto& cur_name : all_animation_names)
		{
			ACreatureActor::LoadAnimation(load_filename, cur_name);
			AddLoadedAnimation(load_filename, cur_name);
		}

		auto cur_str = ConvertToString(start_animation_name);
		for (auto& cur_name : all_animation_names)
		{
			if (cur_name == cur_str)
			{
				first_animation_name = cur_name;
				break;
			}
		}

		SetActiveAnimation(first_animation_name);

		if (smooth_transitions)
		{
			creature_manager->SetAutoBlending(true);
		}

		FillBoneData();

		return true;
	}
	else {
		UE_LOG(LogTemp, Warning, TEXT("ACreatureActor::BeginPlay() - ERROR! Could not load creature file: %s"), *creature_filename);
	}


	return false;
}
예제 #4
0
bool CreatureCore::InitCreatureRender()
{
	FString cur_creature_filename = creature_filename;
	bool init_success = false;
	std::string load_filename;

	//////////////////////////////////////////////////////////////////////////
	//Changed by God of Pen
	//////////////////////////////////////////////////////////////////////////
	if (pJsonData != nullptr)
	{
		if (cur_creature_filename.IsEmpty())
		{
			cur_creature_filename = creature_asset_filename;
		}

		absolute_creature_filename = cur_creature_filename;
		load_filename = ConvertToString(cur_creature_filename);

		// try to load creature
		init_success = CreatureCore::LoadDataPacket(load_filename, pJsonData);;
	}
	else{
		bool does_exist = FPlatformFileManager::Get().GetPlatformFile().FileExists(*cur_creature_filename);
		if (!does_exist)
		{
			// see if it is in the content directory
			cur_creature_filename = FPaths::GameContentDir() + FString(TEXT("/")) + cur_creature_filename;
			does_exist = FPlatformFileManager::Get().GetPlatformFile().FileExists(*cur_creature_filename);
		}

		if (does_exist)
		{
			absolute_creature_filename = cur_creature_filename;
			load_filename = ConvertToString(cur_creature_filename);

			// try to load creature
			CreatureCore::LoadDataPacket(load_filename);
			init_success = true;
		}
		else {

			if (do_file_warning && (!load_filename.empty())) {
				UE_LOG(LogTemp, Warning, TEXT("ACreatureActor::BeginPlay() - ERROR! Could not load creature file: %s"), *creature_filename);
				GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("ACreatureActor::BeginPlay() - ERROR! Could not load creature file: %s"), *creature_filename));
			}
		}
	}
	
	if (init_success)
	{
		LoadCreature(load_filename);

		// try to load all animations
		auto all_animation_names = creature_manager->GetCreature()->GetAnimationNames();
		auto first_animation_name = all_animation_names[0];
		for (auto& cur_name : all_animation_names)
		{
			CreatureCore::LoadAnimation(load_filename, cur_name);
			AddLoadedAnimation(load_filename, cur_name);
		}

		auto cur_str = ConvertToString(start_animation_name);
		for (auto& cur_name : all_animation_names)
		{
			if (cur_name == cur_str)
			{
				first_animation_name = cur_name;
				break;
			}
		}

		SetActiveAnimation(first_animation_name);

		if (smooth_transitions)
		{
			creature_manager->SetAutoBlending(true);
		}

		FillBoneData();
	}


	return init_success;
}