new parallax, cpp lvl manager, tagged trigger etc

This commit is contained in:
2023-08-04 19:07:15 +05:00
parent d9570faa39
commit b943592108
89 changed files with 23532 additions and 1 deletions
+15
View File
@@ -0,0 +1,15 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class MasharovDevTarget : TargetRules
{
public MasharovDevTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "MasharovDev" } );
}
}
+23
View File
@@ -0,0 +1,23 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class MasharovDev : ModuleRules
{
public MasharovDev(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
+6
View File
@@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "MasharovDev.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, MasharovDev, "MasharovDev" );
+6
View File
@@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
+112
View File
@@ -0,0 +1,112 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "cppGI.h"
#include "Kismet/GameplayStatics.h"
#include "Engine/levelstreamingdynamic.h"
/*for working tarray::Contains*/
bool operator==(const Fcppcoords& c1, const Fcppcoords& c2) {
return c1.flat == c2.flat &&
c1.floor == c2.floor &&
c1.house == c2.house &&
c1.section == c2.section &&
c1.type == c2.type &&
c1.zone == c2.zone;
}
void UcppGI::cppLvlManage(UObject* WorldContextObject, Fcppcoords currentCoords, uint8 currentState, TArray<ULevelStreaming*>& Levelss)
{
bool loadthis = false;
int32 temp1[5] = { currentCoords.flat,currentCoords.zone,currentCoords.house,currentCoords.section,currentCoords.floor };
/*complete lvls for loading*/
for (auto& lvl : cpplvlsForLoading) {
int32* temp[5] = { &lvl.flat,&lvl.zone,&lvl.house,&lvl.section,&lvl.floor };
int8 n = 0;
for (auto i : temp) {
if (*i == -2) *i = temp1[n];
n++;
}
}
cpplvlsForLoading.AddUnique(currentCoords);
for (auto& lvl : cpplevelLIst) {
if (currentCoords.floor == 100);
else {
loadthis = false;
for (auto& lvl1 : cpplvlsForLoading) {
bool ceq[6];
/*cppCoordEq(lvl1,lvl,ceq[0],ceq[1],ceq[2],ceq[3],ceq[4],ceq[5],false,true)*/
if (((lvl.coords.flat == -1) || ceq[0] || ((lvl1.flat == lvl.anotherLvl) && (lvl.anotherLvl >= 0)))
&& ceq[1]
&& ceq[2]
&& ceq[3]
&& (ceq[4] || ((lvl1.flat == lvl.anotherLvl) && (lvl.anotherLvl >= 0) && (currentState == 11/*3d tour*/)) || ((lvl1.flat == lvl.anotherLvl) && (lvl.anotherLvl >= 0) && ((currentState == 9) || (currentState == 10)/*sel or view plan*/) && (lvl1.flat > lvl.coords.flat)))) loadthis = true;
}
}
TArray<FString> blya;
blya.Add(FString::FromInt(lvl.coords.flat));
blya.Add(FString::FromInt(lvl.coords.zone));
blya.Add(FString::FromInt(lvl.coords.house));
blya.Add(FString::FromInt(lvl.coords.section));
blya.Add(FString::FromInt(lvl.coords.floor));
FString instanceStr = FString::Join(blya, L"_");
FString temp2;
FString* temp3=&temp2;
lvl.path.Split(FString(L"."), nullptr, temp3);
instanceStr.Append(L"_").Append(*temp3);
FName instanceName = FName(instanceStr);
if (loadthis) {
if (cppdynamicLvls.Contains(instanceName)) {
ULevelStreaming* lvl1 = UGameplayStatics::GetStreamingLevel(WorldContextObject, instanceName);
lvl1->bShouldBlockOnLoad = (currentState != 11) && lvl.dontUnload;
lvl1->SetShouldBeLoaded(true);
lvl1->SetShouldBeVisible(true);
Levelss.Add(lvl1);
}
else {
bool b;
if (ULevelStreamingDynamic* newlvl = ULevelStreamingDynamic::LoadLevelInstance(WorldContextObject, lvl.path, FVector(0, 0, lvl.Z), FRotator(), b, instanceStr)) {
newlvl->SetPriority(lvl.coords.flat == -1 ? 1 : 0);
newlvl->bShouldBlockOnLoad = lvl.dontUnload;
cppdynamicLvls.Add(instanceName);
Levelss.Add(newlvl);
}
}
}
else {
if (cppdynamicLvls.Contains(instanceName)) UGameplayStatics::GetStreamingLevel(WorldContextObject, instanceName)->SetShouldBeLoaded(false);
}
}
return;
}
void UcppGI::cppCoordsEq(Fcppcoords coords, Fcppcoords coords1, bool relevantMinus2, bool fastEq, bool& flat_, bool& type_, bool& zone_, bool& house_, bool& section_, bool& floor_, bool& fullEq)
{
bool* outLvl[6] = { &flat_, &type_, &zone_, &house_, &section_, &floor_ };
int32 c1[6] = { coords.flat,coords.type, coords.zone, coords.house, coords.section, coords.floor };
int32 c2[6] = { coords1.flat,coords1.type, coords1.zone, coords1.house, coords1.section, coords1.floor };
int32 mins[6] = { 0,0,1,1,1,0 };
if (fastEq) {
for (int32 i = 0; i < 6; i++)
{
*outLvl[i] = (c1[i] == c2[i]);
}
}
else {
for (int32 i = 0; i < 6; i++) {
*outLvl[i] = ((c1[i] < mins[i]) && (c2[i] < mins[i])) || (c1[i] == c2[i]) || (c1[i] == -2) || ((c2[i] == -2) && relevantMinus2);
}
}
fullEq = true;
for (const auto var : outLvl)
{
if (!*var)fullEq = false;
}
}
+71
View File
@@ -0,0 +1,71 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "cppGI.generated.h"
/**
*
*/
USTRUCT(BlueprintType)
struct Fcppcoords
{
GENERATED_BODY()
UPROPERTY(BlueprintReadWrite, category = "default")
int32 flat = -1;
UPROPERTY(BlueprintReadWrite, category = "default")
int32 type = 0;
UPROPERTY(BlueprintReadWrite, category = "default")
int32 zone = 1;
UPROPERTY(BlueprintReadWrite, category = "default")
int32 house = -1;
UPROPERTY(BlueprintReadWrite, category = "default")
int32 section = -1;
UPROPERTY(BlueprintReadWrite, category = "default")
int32 floor = -1;
};
USTRUCT(BlueprintType)
struct FcppLevelStruct
{
GENERATED_BODY()
UPROPERTY(BlueprintReadWrite)
Fcppcoords coords;
UPROPERTY(BlueprintReadWrite)
bool dontUnload = false;
UPROPERTY(BlueprintReadWrite)
FString path;
UPROPERTY(BlueprintReadWrite)
float Z = 0;
UPROPERTY(BlueprintReadWrite)
int32 anotherLvl = -1;
};
UCLASS()
class MASHAROVDEV_API UcppGI : public UGameInstance
{
GENERATED_BODY()
public:
UFUNCTION(blueprintcallable, category = "cppFuncLib")
static void cppCoordsEq(Fcppcoords coords, Fcppcoords coords1, bool relevantMinus2, bool fastEq, bool& flat_, bool& type_, bool& zone_, bool& house_, bool& section_, bool& floor_, bool& fullEq);
/*returns array of levels for binding and array of lvlstruct for loading*/
UFUNCTION(blueprintcallable, Category = "Level Loading", meta = (WorldContext = "WorldContextObject"))
void cppLvlManage(UObject* WorldContextObject, Fcppcoords currentCoords, uint8 currentState, TArray<ULevelStreaming*>& Levelss);
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "levelLoading", meta = (MultiLine = "true"))
TArray<FcppLevelStruct> cpplevelLIst;
/** used if need to load some levels instantly. -2 of any coord is use current. */
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Level Loading", meta = (MultiLine = "true"))
TArray<Fcppcoords> cpplvlsForLoading;
UPROPERTY(BlueprintReadWrite, EditDefaultsOnly, Category = "Level Loading", meta = (MultiLine = "true"))
TArray<FName> cppdynamicLvls;
};
+15
View File
@@ -0,0 +1,15 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class MasharovDevEditorTarget : TargetRules
{
public MasharovDevEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "MasharovDev"} );
}
}