Compare commits
No commits in common. "8c01cab7c8f4233afd050b2e05758897c4f1dbcf" and "6946217c7e46785458652dd70b6b964d0d0d8224" have entirely different histories.
8c01cab7c8
...
6946217c7e
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1,4 +1,3 @@
|
||||
ReleaseBuilds/** filter=lfs diff=lfs merge=lfs -text
|
||||
Images/** filter=lfs diff=lfs merge=lfs -text
|
||||
Fonts/** filter=lfs diff=lfs merge=lfs -text
|
||||
Audio/** filter=lfs diff=lfs merge=lfs -text
|
||||
|
BIN
Audio/Dialogue/RAIMaquette_CustomDialogue/GLaDOS_HowHaveYouBeen.wav
(Stored with Git LFS)
BIN
Audio/Dialogue/RAIMaquette_CustomDialogue/GLaDOS_HowHaveYouBeen.wav
(Stored with Git LFS)
Binary file not shown.
@ -139,8 +139,7 @@ ManualIPAddress=
|
||||
+Profiles=(Name="Vehicle",CollisionEnabled=QueryAndPhysics,bCanModify=False,ObjectTypeName="Vehicle",CustomResponses=,HelpMessage="Vehicle object that blocks Vehicle, WorldStatic, and WorldDynamic. All other channels will be set to default.")
|
||||
+Profiles=(Name="UI",CollisionEnabled=QueryOnly,bCanModify=False,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="WorldStatic",Response=ECR_Overlap),(Channel="Pawn",Response=ECR_Overlap),(Channel="Visibility"),(Channel="WorldDynamic",Response=ECR_Overlap),(Channel="Camera",Response=ECR_Overlap),(Channel="PhysicsBody",Response=ECR_Overlap),(Channel="Vehicle",Response=ECR_Overlap),(Channel="Destructible",Response=ECR_Overlap)),HelpMessage="WorldStatic object that overlaps all actors by default. All new custom channels will use its own default response. ")
|
||||
+Profiles=(Name="Interactable",CollisionEnabled=QueryAndPhysics,bCanModify=True,ObjectTypeName="WorldDynamic",CustomResponses=((Channel="Interactable")),HelpMessage="WorldDynamic objects derived from AInteractable.")
|
||||
+Profiles=(Name="AgeOfWarUnitPlayer",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="Vehicle",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Vehicle",Response=ECR_Ignore),(Channel="Interactable")),HelpMessage="Minigame object")
|
||||
+Profiles=(Name="AgeOfWarUnitComputer",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="Destructible",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore),(Channel="Interactable")),HelpMessage="Minigame object")
|
||||
+Profiles=(Name="AgeOfWarUnit",CollisionEnabled=QueryOnly,bCanModify=True,ObjectTypeName="Vehicle",CustomResponses=((Channel="WorldStatic",Response=ECR_Ignore),(Channel="WorldDynamic",Response=ECR_Ignore),(Channel="Pawn",Response=ECR_Ignore),(Channel="Visibility",Response=ECR_Ignore),(Channel="Camera",Response=ECR_Ignore),(Channel="PhysicsBody",Response=ECR_Ignore),(Channel="Destructible",Response=ECR_Ignore)),HelpMessage="Minigame object")
|
||||
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="Interactable")
|
||||
-ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall")
|
||||
-ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn")
|
||||
@ -152,9 +151,6 @@ ManualIPAddress=
|
||||
+ProfileRedirects=(OldName="StaticMeshComponent",NewName="BlockAllDynamic")
|
||||
+ProfileRedirects=(OldName="SkeletalMeshActor",NewName="PhysicsActor")
|
||||
+ProfileRedirects=(OldName="InvisibleActor",NewName="InvisibleWallDynamic")
|
||||
+ProfileRedirects=(OldName="AgeOfWarUnitComputer",NewName="AgeOfWarUnitPlayerZone")
|
||||
+ProfileRedirects=(OldName="AgeOfWarUnit",NewName="AgeOfWarUnitPlayer")
|
||||
+ProfileRedirects=(OldName="AgeOfWarUnitPlayerZone",NewName="AgeOfWarUnitComputer")
|
||||
-CollisionChannelRedirects=(OldName="Static",NewName="WorldStatic")
|
||||
-CollisionChannelRedirects=(OldName="Dynamic",NewName="WorldDynamic")
|
||||
-CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
|
||||
|
BIN
UnrealProject/Lost_Edge/Content/Audio/Music/Minigames/SW_Minigame_RythmClick.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Audio/Music/Minigames/SW_Minigame_RythmClick.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/BP_Minigame_AgeOfWar.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/BP_Minigame_AgeOfWar.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/UI_Minigame_AgeOfWar.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/UI_Minigame_AgeOfWar.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_Base.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Blueprints/Minigames/AgeOfWar/Units/BP_Minigame_AgeOfWarUnit_Base.uasset
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Levels/Test/Actors/RuntimeLoadTest/BP_Test_RuntimeLoad.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Levels/Test/Actors/RuntimeLoadTest/BP_Test_RuntimeLoad.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Levels/Test/L_Test.umap
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Levels/Test/L_Test.umap
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/BP_ImportTest_Barrel.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/BP_ImportTest_Barrel.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/Build/pakchunk100-Windows.pak
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/Build/pakchunk100-Windows.pak
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/DA_ImportTest.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/DA_ImportTest.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/M_ImportTest_BarelWood.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/M_ImportTest_BarelWood.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/M_ImportTest_BarrelRings.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/M_ImportTest_BarrelRings.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/SM_ImportTest_Barrel.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/SM_ImportTest_Barrel.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomDialogue.pak
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomDialogue.pak
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomInteractable.pak
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomInteractable.pak
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomLevel.pak
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomLevel.pak
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/BP_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/BP_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/DA_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/DA_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/DT_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/DT_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/SW_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/SW_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/M_RAIMaquett_BarelWood.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/M_RAIMaquett_BarelWood.uasset
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/SM_RAIMaquett_Barrel.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/SM_RAIMaquett_Barrel.uasset
(Stored with Git LFS)
Binary file not shown.
@ -9,7 +9,7 @@ public class Lost_Edge : ModuleRules {
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OpenCV" });
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { "EnhancedInput", "UMG", "RHI", "RenderCore", "Lost_EdgeShaders", "PakFile", //"TextureCompressor",
|
||||
"LevelSequence", "MovieScene", "HTTP", "Json" }); // "Slate", "SlateCore"
|
||||
"LevelSequence", "MovieScene" }); // "Slate", "SlateCore"
|
||||
|
||||
// UE_LOG(LogTemp, Log, TEXT("capture: %s"), (capture ? TEXT("true") : TEXT("false")));
|
||||
// GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, TEXT("1"));
|
||||
|
@ -39,18 +39,6 @@ void UCommonFunctions::DestroyActorRecursively(AActor* actor)
|
||||
actor->Destroy();
|
||||
}
|
||||
|
||||
TArray<int32> UCommonFunctions::GetRandomIntArray(int32 size, int32 min, int32 max)
|
||||
{
|
||||
if(size <= 0)
|
||||
return {};
|
||||
|
||||
TArray<int32> arr;
|
||||
arr.Reserve(size);
|
||||
for(int32 i = 0; i < size; ++i)
|
||||
arr.Add(FMath::RandRange(min, max));
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ALevelBase* UCommonFunctions::GetCurrentLevelScript(UObject* obj)
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
|
||||
#include "CommonFunctions.generated.h"
|
||||
@ -21,8 +20,6 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = Actor)
|
||||
static void DestroyActorRecursively(class AActor* actor);
|
||||
|
||||
UFUNCTION(BlueprintPure)
|
||||
static TArray<int32> GetRandomIntArray(int32 size = 16, int32 min = 0, int32 max = 16);
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = Level)
|
||||
@ -40,12 +37,6 @@ public:
|
||||
|
||||
static FWorldDilationChangedDelegate& GetWorldDilationChangedDelegate();
|
||||
|
||||
|
||||
template<typename T>
|
||||
static TArray<T> ArrayDiff(const TArray<T>& a, const TArray<T>& b);
|
||||
template<typename T>
|
||||
static void ArrayRemoveFirstFromEnd(TArray<T>& array, T element);
|
||||
|
||||
private:
|
||||
static void SlowMotionTick();
|
||||
|
||||
@ -57,37 +48,3 @@ namespace SlowMotion
|
||||
constexpr float slowDilation = 0.2f;
|
||||
constexpr float interpolationSpeed = 0.1f;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline TArray<T> UCommonFunctions::ArrayDiff(const TArray<T>& a, const TArray<T>& b)
|
||||
{
|
||||
TSet<T> result;
|
||||
|
||||
if(a.Num() == 0)
|
||||
return b;
|
||||
else if(b.Num() == 0)
|
||||
return a;
|
||||
|
||||
for(auto& i : a)
|
||||
if(!b.Contains(i))
|
||||
result.Add(i);
|
||||
|
||||
for(auto& i : b)
|
||||
if(!a.Contains(i))
|
||||
result.Add(i);
|
||||
|
||||
return result.Array();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void UCommonFunctions::ArrayRemoveFirstFromEnd(TArray<T>& array, T element)
|
||||
{
|
||||
for(int32 i = array.Num() - 1; i > -1; --i)
|
||||
{
|
||||
if(array[i] == element)
|
||||
{
|
||||
array.RemoveAt(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,26 +3,7 @@
|
||||
|
||||
#include "ContentLoader.h"
|
||||
|
||||
#include "CommonFunctions.h"
|
||||
#include "IPlatformFilePak.h"
|
||||
#include "Misc/FileHelper.h"
|
||||
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto httpGet = TEXT("GET");
|
||||
|
||||
constexpr int32 httpResponseOK = 200;
|
||||
|
||||
constexpr auto httpContentTypeHtml = TEXT("text/html");
|
||||
constexpr auto httpContentTypeJson = TEXT("application/json");
|
||||
|
||||
constexpr auto pakIndexUrl = TEXT("https://pixelyfier.com/lost_edge/content/");
|
||||
const auto pakFileSavePath = FString::Printf(TEXT("%sDownloaded/"), *FPaths::ProjectDir());
|
||||
}
|
||||
|
||||
void UContentLoader::BeginDestroy()
|
||||
{
|
||||
@ -37,129 +18,9 @@ void UContentLoader::BeginDestroy()
|
||||
UObject::BeginDestroy();
|
||||
}
|
||||
|
||||
void UContentLoader::HttpGet(const FString& url, FHttpRequestCompleteDelegate requestCompleteCallback)
|
||||
{
|
||||
TSharedRef<IHttpRequest> request = FHttpModule::Get().CreateRequest();
|
||||
request->SetURL(url);
|
||||
request->SetVerb(httpGet);
|
||||
request->OnProcessRequestComplete() = std::move(requestCompleteCallback);
|
||||
request->ProcessRequest();
|
||||
}
|
||||
|
||||
TArray<FString> UContentLoader::ParseDirectoryIndex(const TArray<uint8>& content, const FString& contentType)
|
||||
{
|
||||
TArray<FString> result;
|
||||
|
||||
if(contentType == httpContentTypeHtml)
|
||||
{
|
||||
std::string contentHtml{ reinterpret_cast<const char*>(content.GetData()), static_cast<size_t>(content.Num()) };
|
||||
std::regex hrefRegex(R"(<a href="((?!\.)[^"]+))");
|
||||
std::smatch match;
|
||||
auto it = contentHtml.cbegin();
|
||||
auto end = contentHtml.cend();
|
||||
while(std::regex_search(it, end, match, hrefRegex))
|
||||
{
|
||||
if(match.size() > 1)
|
||||
{
|
||||
result.Add(UTF8_TO_TCHAR(match[1].str().c_str()));
|
||||
}
|
||||
it = match.suffix().first;
|
||||
}
|
||||
}
|
||||
else if(contentType == httpContentTypeJson)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
FString UContentLoader::SelectContentByMethod(const TArray<FString>& content, const EContentDownloadMethod method)
|
||||
{
|
||||
switch(method)
|
||||
{
|
||||
case EContentDownloadMethod::NonRepeatRandom:
|
||||
{
|
||||
auto filteredContent = UCommonFunctions::ArrayDiff(content, downloadedContent);
|
||||
if(filteredContent.Num() == 0 && content.Num() != 0)
|
||||
{
|
||||
downloadedContent.Reset();
|
||||
filteredContent = UCommonFunctions::ArrayDiff(content, downloadedContent);
|
||||
}
|
||||
return filteredContent[FMath::RandRange(0, filteredContent.Num() - 1)];
|
||||
}
|
||||
case EContentDownloadMethod::RatingOftenRandom:
|
||||
// TODO
|
||||
case EContentDownloadMethod::ClearRandom:
|
||||
default:
|
||||
return content[FMath::RandRange(0, content.Num() - 1)];
|
||||
}
|
||||
}
|
||||
|
||||
void UContentLoader::DownloadPak(FContentDownloadedCallback downloadedCallback, const EContentDownloadMethod method)
|
||||
{
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Requesting pak http index at %s."), pakIndexUrl);
|
||||
|
||||
FHttpRequestCompleteDelegate indexRequestCallback;
|
||||
indexRequestCallback.BindLambda([=, this](FHttpRequestPtr request, FHttpResponsePtr response, bool successful)
|
||||
{
|
||||
if(!successful || response->GetResponseCode() != httpResponseOK)
|
||||
{
|
||||
int32 responseCode = response.IsValid() ? response->GetResponseCode() : -1;
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Requesting pak http index failed with code: %d (-1 if response is null)."), responseCode);
|
||||
return;
|
||||
}
|
||||
|
||||
TArray<FString> availablePaks = ParseDirectoryIndex(response->GetContent(), response->GetContentType());
|
||||
if(availablePaks.Num() == 0)
|
||||
{
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Pak http index is empty."));
|
||||
return;
|
||||
}
|
||||
|
||||
FString pakToDownload = SelectContentByMethod(availablePaks, method);
|
||||
downloadedContent.Add(pakToDownload);
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Pak selected for loading: %s."), *pakToDownload);
|
||||
|
||||
auto savePath = FString::Printf(TEXT("%s%s"), *pakFileSavePath, *pakToDownload);
|
||||
if(FPlatformFileManager::Get().GetPlatformFile().FileExists(*savePath))
|
||||
{
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Selected pak already exists... skipping download."));
|
||||
downloadedCallback.ExecuteIfBound(savePath);
|
||||
return;
|
||||
}
|
||||
|
||||
FHttpRequestCompleteDelegate pakDownloadCallback;
|
||||
pakDownloadCallback.BindLambda([=, this](FHttpRequestPtr request, FHttpResponsePtr response, bool successful)
|
||||
{
|
||||
if(!successful || response->GetResponseCode() != httpResponseOK)
|
||||
{
|
||||
UCommonFunctions::ArrayRemoveFirstFromEnd(downloadedContent, pakToDownload);
|
||||
int32 responseCode = response.IsValid() ? response->GetResponseCode() : -1;
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Pak downloading failed with code: %d (-1 if response is null)."), responseCode);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!FFileHelper::SaveArrayToFile(response->GetContent(), *savePath))
|
||||
{
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Saving pak file %s failed."), *savePath);
|
||||
return;
|
||||
}
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Pak file saved as %s."), *savePath);
|
||||
|
||||
downloadedCallback.ExecuteIfBound(savePath);
|
||||
});
|
||||
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Starting to download pak %s from index."), *pakToDownload);
|
||||
HttpGet(FString::Printf(TEXT("%s%s"), pakIndexUrl, *pakToDownload), pakDownloadCallback);
|
||||
});
|
||||
|
||||
HttpGet(pakIndexUrl, indexRequestCallback);
|
||||
}
|
||||
|
||||
UClass* UContentLoader::LoadPak(const FString& pakFilePath)
|
||||
{
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Starting to mount pak %s."), *pakFilePath);
|
||||
UE_LOG(LogTemp, Log, TEXT("ContentLoader: Starting to mount pak %s"), *pakFilePath);
|
||||
|
||||
FPakPlatformFile* pakFileMgr = (FPakPlatformFile*)(FPlatformFileManager::Get().FindPlatformFile(TEXT("PakFile")));
|
||||
if(!pakFileMgr)
|
||||
@ -243,13 +104,13 @@ bool UContentLoader::UnloadPak(const FString& pakFilePath)
|
||||
FPakPlatformFile* pakFileMgr = (FPakPlatformFile*)(FPlatformFileManager::Get().FindPlatformFile(TEXT("PakFile")));
|
||||
if(!pakFileMgr)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("ContentLoader: Unable to get PakPlatformFile for pak file (Unmount): %s."), *pakFilePath);
|
||||
UE_LOG(LogTemp, Warning, TEXT("Unable to get PakPlatformFile for pak file (Unmount): %s"), *pakFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!pakFileMgr->Unmount(*pakFilePath))
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("ContentLoader: Unable to unmount pak: %s."), *pakFilePath);
|
||||
UE_LOG(LogTemp, Warning, TEXT("Unable to unmount pak: %s"), *pakFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2,45 +2,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Http.h"
|
||||
#include "UObject/Object.h"
|
||||
|
||||
#include "ContentLoader.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EContentDownloadMethod : uint8
|
||||
{
|
||||
ClearRandom = 0,
|
||||
NonRepeatRandom,
|
||||
RatingOftenRandom
|
||||
};
|
||||
|
||||
DECLARE_DYNAMIC_DELEGATE_OneParam(FContentDownloadedCallback, FString, pakFilePath);
|
||||
|
||||
UCLASS(BlueprintType)
|
||||
class UContentLoader : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "ContentLoader")
|
||||
void DownloadPak(FContentDownloadedCallback downloadedCallback, const EContentDownloadMethod method = EContentDownloadMethod::NonRepeatRandom);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "ContentLoader")
|
||||
UClass* LoadPak(const FString& pakFilePath);
|
||||
|
||||
protected:
|
||||
virtual void BeginDestroy() override;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "ContentLoader")
|
||||
bool UnloadPak(const FString& pakFilePath);
|
||||
|
||||
protected:
|
||||
virtual void BeginDestroy() override;
|
||||
|
||||
void HttpGet(const FString& url, FHttpRequestCompleteDelegate requestCompleteCallback);
|
||||
TArray<FString> ParseDirectoryIndex(const TArray<uint8>& content, const FString& contentType);
|
||||
FString SelectContentByMethod(const TArray<FString>& content, const EContentDownloadMethod method);
|
||||
|
||||
FString GetPakMountContent(const FString& pakFilePath, TArray<FString>* content = nullptr);
|
||||
UClass* GetPakClass(const FString& pakContentPath);
|
||||
|
||||
TArray<FString> downloadedContent;
|
||||
};
|
||||
|
@ -147,7 +147,7 @@ void UDialogueManager::PlayNextDialogue()
|
||||
{
|
||||
FDialogueEndCallback callback;
|
||||
_endCallbacks.Dequeue(callback);
|
||||
callback.ExecuteIfBound();
|
||||
callback.Execute();
|
||||
_nextDialogues.Pop();
|
||||
return;
|
||||
}
|
||||
|
@ -15,11 +15,6 @@ TMap<UClass*, FAgeOfWarUnitStats> AAgeOfWarManager::unitStats = {};
|
||||
const FAgeOfWarUnitStats& AAgeOfWarManager::UnitGetStats(TSubclassOf<AAgeOfWarUnit> unitClass)
|
||||
{
|
||||
check(unitStats.Contains(*unitClass));
|
||||
//if(!unitStats.Contains(*unitClass))
|
||||
//{
|
||||
// static FAgeOfWarUnitStats empty;
|
||||
// return empty;
|
||||
//}
|
||||
|
||||
return unitStats[unitClass];
|
||||
}
|
||||
@ -57,10 +52,6 @@ void AAgeOfWarManager::Start(APlayerBase* playerPawn, FMinigameEndCallback deleg
|
||||
|
||||
void AAgeOfWarManager::End()
|
||||
{
|
||||
for(auto& unit : spawnedUnits)
|
||||
unit->Destroy();
|
||||
spawnedUnits.Empty();
|
||||
|
||||
unitStats.Empty();
|
||||
|
||||
player->ReturnPlayerView();
|
||||
@ -69,12 +60,6 @@ void AAgeOfWarManager::End()
|
||||
AMinigame::End();
|
||||
}
|
||||
|
||||
void AAgeOfWarManager::UnitKill(AAgeOfWarUnit* unit)
|
||||
{
|
||||
OnUnitKill(unit);
|
||||
spawnedUnits.Remove(unit);
|
||||
}
|
||||
|
||||
void AAgeOfWarManager::AddUnitStats(TSubclassOf<AAgeOfWarUnit> unitClass, FAgeOfWarUnitStats stats)
|
||||
{
|
||||
unitStats.Add(unitClass, stats);
|
||||
@ -92,6 +77,4 @@ void AAgeOfWarManager::SpawnUnit(TSubclassOf<AAgeOfWarUnit> unitClass, FTransfor
|
||||
auto unit = GetWorld()->SpawnActor<AAgeOfWarUnit>(*unitClass, transform, spawnParams);
|
||||
unit->team = computer ? UnitTeam::AI : UnitTeam::Player;
|
||||
unit->manager = this;
|
||||
unit->UpdateStats();
|
||||
spawnedUnits.Add(unit);
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ public:
|
||||
virtual void Start(class APlayerBase* playerPawn, FMinigameEndCallback delegate) override;
|
||||
virtual void End() override;
|
||||
|
||||
void UnitKill(class AAgeOfWarUnit* unit);
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void OnUnitKill(class AAgeOfWarUnit* unit);
|
||||
|
||||
@ -39,5 +38,4 @@ protected:
|
||||
UPROPERTY(EditAnywhere)
|
||||
class UCameraComponent* camera;
|
||||
|
||||
TSet<AAgeOfWarUnit*> spawnedUnits;
|
||||
};
|
||||
|
@ -8,13 +8,6 @@
|
||||
#include "AgeOfWarManager.h"
|
||||
#include <Components/BoxComponent.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto PlayerCollision = TEXT("AgeOfWarUnitPlayer");
|
||||
constexpr auto ComputerCollision = TEXT("AgeOfWarUnitComputer");
|
||||
constexpr auto TagNoAuto = TEXT("NoAuto");
|
||||
}
|
||||
|
||||
const FAgeOfWarUnitStats& AAgeOfWarUnit::GetStats()
|
||||
{
|
||||
if(!stats)
|
||||
@ -26,25 +19,6 @@ const FAgeOfWarUnitStats& AAgeOfWarUnit::GetStats()
|
||||
void AAgeOfWarUnit::UpdateStats()
|
||||
{
|
||||
health = GetStats().health;
|
||||
attackStartRange = GetStats().attackStartRange;
|
||||
|
||||
switch(team)
|
||||
{
|
||||
case UnitTeam::AI:
|
||||
root->SetCollisionProfileName(ComputerCollision);
|
||||
allyblocker->SetCollisionProfileName(PlayerCollision);
|
||||
break;
|
||||
case UnitTeam::Player:
|
||||
root->SetCollisionProfileName(PlayerCollision);
|
||||
allyblocker->SetCollisionProfileName(ComputerCollision);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
allyblocker->SetBoxExtent(root->GetUnscaledBoxExtent(), false);
|
||||
allyblocker->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
|
||||
OnUpdateStats();
|
||||
}
|
||||
|
||||
void AAgeOfWarUnit::BeginPlay()
|
||||
@ -55,8 +29,6 @@ void AAgeOfWarUnit::BeginPlay()
|
||||
}
|
||||
|
||||
Super::BeginPlay();
|
||||
|
||||
world = GetWorld();
|
||||
}
|
||||
|
||||
void AAgeOfWarUnit::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
@ -66,12 +38,10 @@ void AAgeOfWarUnit::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
|
||||
AAgeOfWarUnit::AAgeOfWarUnit()
|
||||
{
|
||||
root = CreateDefaultSubobject<UBoxComponent>(TEXT("Collision"));
|
||||
allyblocker = CreateDefaultSubobject<UBoxComponent>(TEXT("AllyBlocker"));
|
||||
allyblocker->SetupAttachment(root);
|
||||
traceStart = CreateDefaultSubobject<USceneComponent>(TEXT("TraceStart"));
|
||||
traceStart->SetupAttachment(root);
|
||||
traceStart->AddRelativeLocation(FVector(0, 0, 200));
|
||||
//auto root = CreateDefaultSubobject<USceneComponent>(TEXT("Scene"));
|
||||
//
|
||||
//collision = CreateDefaultSubobject<UBoxComponent>(TEXT("Collision"));
|
||||
//collision->SetCollisionProfileName(TEXT("AgeOfWarUnit"));
|
||||
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
PrimaryActorTick.bStartWithTickEnabled = true;
|
||||
@ -84,26 +54,10 @@ void AAgeOfWarUnit::Tick(float deltaTime)
|
||||
if(!manager || GetStats().moveSpeed <= 0)
|
||||
return;
|
||||
|
||||
// try move
|
||||
FHitResult moveHit;
|
||||
// move unit forward
|
||||
auto moveStep = GetActorForwardVector() * GetStats().moveSpeed;
|
||||
this->AddActorWorldOffset(moveStep, true, &moveHit, ETeleportType::None);
|
||||
if(moveHit.bBlockingHit)
|
||||
allyblocker->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
||||
else
|
||||
allyblocker->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
|
||||
// look for units forward
|
||||
FHitResult hit;
|
||||
auto startLocation = traceStart->GetComponentLocation();
|
||||
auto endLocation = startLocation + (GetActorRotation().Vector() * attackStartRange * (moveHit.bBlockingHit ? 5 : 1));
|
||||
world->LineTraceSingleByChannel(
|
||||
hit,
|
||||
startLocation,
|
||||
endLocation,
|
||||
ECollisionChannel::ECC_GameTraceChannel1
|
||||
);
|
||||
DrawDebugLine(GetWorld(), startLocation, endLocation, FColor::Red, false, deltaTime * 10, 0, 4.0f);
|
||||
this->AddActorWorldOffset(moveStep, true, &hit, ETeleportType::None);
|
||||
|
||||
// check if blocked
|
||||
if(!hit.bBlockingHit)
|
||||
@ -117,7 +71,7 @@ void AAgeOfWarUnit::Tick(float deltaTime)
|
||||
}
|
||||
|
||||
// iterate to attackable unit
|
||||
for(int i = 1; forwardUnit->team == team && i < GetStats().attackUnitDistance; i += forwardUnit->GetStats().unitSize)
|
||||
for(int i = 1; forwardUnit->team == team && i < GetStats().attackDistance; i += forwardUnit->GetStats().unitSize)
|
||||
forwardUnit = forwardUnit->forwardUnit;
|
||||
|
||||
// if forward unit is in the same team skip attack
|
||||
@ -135,24 +89,15 @@ void AAgeOfWarUnit::Tick(float deltaTime)
|
||||
|
||||
void AAgeOfWarUnit::Damage(const int32 damage)
|
||||
{
|
||||
if(killed)
|
||||
return;
|
||||
|
||||
GEngine->AddOnScreenDebugMessage((int32)GetClass()->GetUniqueID(), 5.0f, FColor::Yellow, FString::Printf(TEXT("%d"), health));
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, FString::Printf(TEXT("Damage %d taken by %s"), damage, *GetClass()->GetName()));
|
||||
|
||||
health -= damage;
|
||||
|
||||
if(health > 0)
|
||||
return;
|
||||
|
||||
killed = true;
|
||||
|
||||
if(IsValid(manager))
|
||||
{
|
||||
manager->UnitKill(this);
|
||||
}
|
||||
manager->OnUnitKill(this);
|
||||
else
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
@ -27,10 +27,7 @@ struct FAgeOfWarUnitStats
|
||||
int32 attackDamage = 1;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 attackUnitDistance = 1;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
float attackStartRange = 100;
|
||||
int32 attackDistance = 1;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
float attackRate = 1.0f;
|
||||
@ -72,28 +69,17 @@ protected:
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void OnUpdateStats();
|
||||
|
||||
void Damage(const int32 damage);
|
||||
|
||||
AAgeOfWarUnit* forwardUnit = nullptr;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
class UBoxComponent* root;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
class UBoxComponent* allyblocker;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
class USceneComponent* traceStart;
|
||||
|
||||
private:
|
||||
UPROPERTY(EditAnywhere)
|
||||
class UBoxComponent* collision;
|
||||
|
||||
int32 health;
|
||||
float attackStartRange;
|
||||
FTimerHandle attackTimer;
|
||||
double lastAttackTimestamp = 0;
|
||||
|
||||
UWorld* world;
|
||||
bool killed = false;
|
||||
};
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "QuickTimeEvent.h" // forward declaration of EQuickTimeEventResult is somehow insufficient on some machines
|
||||
#include "Widgets/ResolutionResponsiveUserWidget.h"
|
||||
|
||||
#include "QuickTimeEventWidget.generated.h"
|
||||
@ -28,6 +27,7 @@ public:
|
||||
void ProcessBeforeRemoving();
|
||||
EQuickTimeEventResult _ProcessBeforeRemoving();
|
||||
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
class UTextBlock* keyText;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user