Compare commits
6 Commits
6946217c7e
...
8c01cab7c8
Author | SHA1 | Date | |
---|---|---|---|
8c01cab7c8 | |||
6da4620dc5 | |||
579100f45c | |||
cbb8a5bc14 | |||
a3eca9d441 | |||
8e73eaff6b |
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1,3 +1,4 @@
|
||||
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)
Normal file
BIN
Audio/Dialogue/RAIMaquette_CustomDialogue/GLaDOS_HowHaveYouBeen.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -139,7 +139,8 @@ 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="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")
|
||||
+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")
|
||||
+DefaultChannelResponses=(Channel=ECC_GameTraceChannel1,DefaultResponse=ECR_Ignore,bTraceType=True,bStaticObject=False,Name="Interactable")
|
||||
-ProfileRedirects=(OldName="BlockingVolume",NewName="InvisibleWall")
|
||||
-ProfileRedirects=(OldName="InterpActor",NewName="IgnoreOnlyPawn")
|
||||
@ -151,6 +152,9 @@ 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)
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/BP_ImportTest_Barrel.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/Build/pakchunk100-Windows.pak
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/Build/pakchunk100-Windows.pak
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/DA_ImportTest.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/DA_ImportTest.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/M_ImportTest_BarelWood.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/M_ImportTest_BarelWood.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/M_ImportTest_BarrelRings.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/M_ImportTest_BarrelRings.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/SM_ImportTest_Barrel.uasset
(Stored with Git LFS)
BIN
UnrealProject/Lost_Edge/Content/Misc/ImportTest/SM_ImportTest_Barrel.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomDialogue.pak
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomDialogue.pak
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomInteractable.pak
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomInteractable.pak
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomLevel.pak
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/BuildedPaks/CustomLevel.pak
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomAnimatedLight/BP_RAIMaquett_CustomAnimatedLightLoader.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomAnimatedLight/BP_RAIMaquett_CustomAnimatedLightLoader.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomAnimatedLight/Content/BP_RAIMaquett_SmokeLamp.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomAnimatedLight/Content/BP_RAIMaquett_SmokeLamp.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomAnimatedLight/Content/L_RAIMaquett_CustomAnimatedLightWorld.umap
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomAnimatedLight/Content/L_RAIMaquett_CustomAnimatedLightWorld.umap
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomAnimatedLight/Content/Seq_RAIMaquett_CustomAnimatedLightAnimation.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomAnimatedLight/Content/Seq_RAIMaquett_CustomAnimatedLightAnimation.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomAnimatedLight/DA_RAIMaquett_CustomAnimatedLight.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomAnimatedLight/DA_RAIMaquett_CustomAnimatedLight.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/BP_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/BP_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/DA_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/DA_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/DT_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/DT_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/SW_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomDialogue/SW_RAIMaquett_CustomDialogue.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/BP_RAIMaquett_CustomBarrel.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/BP_RAIMaquett_CustomBarrel.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/DA_RAIMaquett_CustomMovableInteractable.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/DA_RAIMaquett_CustomMovableInteractable.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/M_RAIMaquett_BarelWood.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/M_RAIMaquett_BarelWood.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/M_RAIMaquett_BarrelRings.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/M_RAIMaquett_BarrelRings.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/SM_RAIMaquett_Barrel.uasset
(Stored with Git LFS)
Normal file
BIN
UnrealProject/Lost_Edge/Content/Misc/RAIMaquetts/CustomMovableInteractable/SM_RAIMaquett_Barrel.uasset
(Stored with Git LFS)
Normal file
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" }); // "Slate", "SlateCore"
|
||||
"LevelSequence", "MovieScene", "HTTP", "Json" }); // "Slate", "SlateCore"
|
||||
|
||||
// UE_LOG(LogTemp, Log, TEXT("capture: %s"), (capture ? TEXT("true") : TEXT("false")));
|
||||
// GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, TEXT("1"));
|
||||
|
@ -39,6 +39,18 @@ 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,6 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
|
||||
#include "CommonFunctions.generated.h"
|
||||
@ -20,6 +21,8 @@ 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)
|
||||
@ -37,6 +40,12 @@ 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();
|
||||
|
||||
@ -48,3 +57,37 @@ 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,7 +3,26 @@
|
||||
|
||||
#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()
|
||||
{
|
||||
@ -18,9 +37,129 @@ 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)
|
||||
@ -104,13 +243,13 @@ bool UContentLoader::UnloadPak(const FString& pakFilePath)
|
||||
FPakPlatformFile* pakFileMgr = (FPakPlatformFile*)(FPlatformFileManager::Get().FindPlatformFile(TEXT("PakFile")));
|
||||
if(!pakFileMgr)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Unable to get PakPlatformFile for pak file (Unmount): %s"), *pakFilePath);
|
||||
UE_LOG(LogTemp, Warning, TEXT("ContentLoader: Unable to get PakPlatformFile for pak file (Unmount): %s."), *pakFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!pakFileMgr->Unmount(*pakFilePath))
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("Unable to unmount pak: %s"), *pakFilePath);
|
||||
UE_LOG(LogTemp, Warning, TEXT("ContentLoader: Unable to unmount pak: %s."), *pakFilePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,21 @@
|
||||
|
||||
#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
|
||||
{
|
||||
@ -13,15 +24,23 @@ class UContentLoader : public UObject
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "ContentLoader")
|
||||
UClass* LoadPak(const FString& pakFilePath);
|
||||
void DownloadPak(FContentDownloadedCallback downloadedCallback, const EContentDownloadMethod method = EContentDownloadMethod::NonRepeatRandom);
|
||||
|
||||
protected:
|
||||
virtual void BeginDestroy() override;
|
||||
UFUNCTION(BlueprintCallable, Category = "ContentLoader")
|
||||
UClass* LoadPak(const FString& pakFilePath);
|
||||
|
||||
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.Execute();
|
||||
callback.ExecuteIfBound();
|
||||
_nextDialogues.Pop();
|
||||
return;
|
||||
}
|
||||
|
@ -15,6 +15,11 @@ 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];
|
||||
}
|
||||
@ -52,6 +57,10 @@ void AAgeOfWarManager::Start(APlayerBase* playerPawn, FMinigameEndCallback deleg
|
||||
|
||||
void AAgeOfWarManager::End()
|
||||
{
|
||||
for(auto& unit : spawnedUnits)
|
||||
unit->Destroy();
|
||||
spawnedUnits.Empty();
|
||||
|
||||
unitStats.Empty();
|
||||
|
||||
player->ReturnPlayerView();
|
||||
@ -60,6 +69,12 @@ 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);
|
||||
@ -77,4 +92,6 @@ 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,6 +19,7 @@ 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);
|
||||
|
||||
@ -38,4 +39,5 @@ protected:
|
||||
UPROPERTY(EditAnywhere)
|
||||
class UCameraComponent* camera;
|
||||
|
||||
TSet<AAgeOfWarUnit*> spawnedUnits;
|
||||
};
|
||||
|
@ -8,6 +8,13 @@
|
||||
#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)
|
||||
@ -19,6 +26,25 @@ 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()
|
||||
@ -29,6 +55,8 @@ void AAgeOfWarUnit::BeginPlay()
|
||||
}
|
||||
|
||||
Super::BeginPlay();
|
||||
|
||||
world = GetWorld();
|
||||
}
|
||||
|
||||
void AAgeOfWarUnit::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
@ -38,10 +66,12 @@ void AAgeOfWarUnit::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
|
||||
AAgeOfWarUnit::AAgeOfWarUnit()
|
||||
{
|
||||
//auto root = CreateDefaultSubobject<USceneComponent>(TEXT("Scene"));
|
||||
//
|
||||
//collision = CreateDefaultSubobject<UBoxComponent>(TEXT("Collision"));
|
||||
//collision->SetCollisionProfileName(TEXT("AgeOfWarUnit"));
|
||||
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));
|
||||
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
PrimaryActorTick.bStartWithTickEnabled = true;
|
||||
@ -54,10 +84,26 @@ void AAgeOfWarUnit::Tick(float deltaTime)
|
||||
if(!manager || GetStats().moveSpeed <= 0)
|
||||
return;
|
||||
|
||||
// move unit forward
|
||||
// try move
|
||||
FHitResult moveHit;
|
||||
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;
|
||||
this->AddActorWorldOffset(moveStep, true, &hit, ETeleportType::None);
|
||||
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);
|
||||
|
||||
// check if blocked
|
||||
if(!hit.bBlockingHit)
|
||||
@ -71,7 +117,7 @@ void AAgeOfWarUnit::Tick(float deltaTime)
|
||||
}
|
||||
|
||||
// iterate to attackable unit
|
||||
for(int i = 1; forwardUnit->team == team && i < GetStats().attackDistance; i += forwardUnit->GetStats().unitSize)
|
||||
for(int i = 1; forwardUnit->team == team && i < GetStats().attackUnitDistance; i += forwardUnit->GetStats().unitSize)
|
||||
forwardUnit = forwardUnit->forwardUnit;
|
||||
|
||||
// if forward unit is in the same team skip attack
|
||||
@ -89,15 +135,24 @@ void AAgeOfWarUnit::Tick(float deltaTime)
|
||||
|
||||
void AAgeOfWarUnit::Damage(const int32 damage)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, FString::Printf(TEXT("Damage %d taken by %s"), damage, *GetClass()->GetName()));
|
||||
if(killed)
|
||||
return;
|
||||
|
||||
GEngine->AddOnScreenDebugMessage((int32)GetClass()->GetUniqueID(), 5.0f, FColor::Yellow, FString::Printf(TEXT("%d"), health));
|
||||
|
||||
health -= damage;
|
||||
|
||||
if(health > 0)
|
||||
return;
|
||||
|
||||
killed = true;
|
||||
|
||||
if(IsValid(manager))
|
||||
manager->OnUnitKill(this);
|
||||
{
|
||||
manager->UnitKill(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,10 @@ struct FAgeOfWarUnitStats
|
||||
int32 attackDamage = 1;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
int32 attackDistance = 1;
|
||||
int32 attackUnitDistance = 1;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
float attackStartRange = 100;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
float attackRate = 1.0f;
|
||||
@ -69,17 +72,28 @@ 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;
|
||||
|
||||
private:
|
||||
UPROPERTY(EditAnywhere)
|
||||
class UBoxComponent* collision;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
class UBoxComponent* root;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
class UBoxComponent* allyblocker;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
class USceneComponent* traceStart;
|
||||
|
||||
private:
|
||||
int32 health;
|
||||
float attackStartRange;
|
||||
FTimerHandle attackTimer;
|
||||
double lastAttackTimestamp = 0;
|
||||
|
||||
UWorld* world;
|
||||
bool killed = false;
|
||||
};
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "QuickTimeEvent.h" // forward declaration of EQuickTimeEventResult is somehow insufficient on some machines
|
||||
#include "Widgets/ResolutionResponsiveUserWidget.h"
|
||||
|
||||
#include "QuickTimeEventWidget.generated.h"
|
||||
@ -27,7 +28,6 @@ public:
|
||||
void ProcessBeforeRemoving();
|
||||
EQuickTimeEventResult _ProcessBeforeRemoving();
|
||||
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
class UTextBlock* keyText;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user