Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- patri@DESKTOP-F81JRPJ MINGW64 /d/git/UrbanHeat (master)
- $ git diff
- diff --git a/Source/UrbanHeat/CityManager.h b/Source/UrbanHeat/CityManager.h
- index 08b1870..2cb1bb8 100644
- --- a/Source/UrbanHeat/CityManager.h
- +++ b/Source/UrbanHeat/CityManager.h
- @@ -43,7 +43,7 @@ public:
- // IMaterialInterface* TT;
- UPROPERTY(VisibleAnywhere)
- - TArray<ATile*> Tiles;
- + TArray<ATile*> Tiles;
- protected:
- diff --git a/Source/UrbanHeat/Tile.h b/Source/UrbanHeat/Tile.h
- index bb23b4d..0b65135 100644
- --- a/Source/UrbanHeat/Tile.h
- +++ b/Source/UrbanHeat/Tile.h
- @@ -50,10 +50,10 @@ public:
- void Initialize(VoronoiGenerator::Site & Site);
- UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
- - UBaseTileSceneComp* TileContent = nullptr;
- + UBaseTileSceneComp* TileContent = nullptr;
- UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
- - TArray<UBaseTileSceneComp*> SubComponents;
- + TArray<UBaseTileSceneComp*> SubComponents;
- UPROPERTY(VisibleAnywhere)
- float AirHindrance;
- diff --git a/Source/UrbanHeat/TileComponents/BaseTileSceneComp.cpp b/Source/UrbanHeat/TileComponents/BaseTileSceneComp.cpp
- index 6514781..42344d3 100644
- --- a/Source/UrbanHeat/TileComponents/BaseTileSceneComp.cpp
- +++ b/Source/UrbanHeat/TileComponents/BaseTileSceneComp.cpp
- @@ -24,14 +24,12 @@ void UBaseTileSceneComp::Init(FString type)
- {
- AUrbanHeatGameState* gameStateRef = Cast<AUrbanHeatGameState>(GetWorld()->GetGameState());
- - TArray<UDataTable*>* arrayRef = &gameStateRef->DataTableReferences;
- -
- UDataTable* RootDataTableRef = gameStateRef->GetDataTableByName("ComponentData");
- UScriptStruct* Struct = RootDataTableRef->RowStruct;
- uint8* DataAddr = RootDataTableRef->FindRowUnchecked(FName(*type));
- -
- +
- UProperty* Prop = Struct->CustomFindProperty(FName("EnvironmentalValues"));
- if (Prop)
- {
- @@ -43,7 +41,6 @@ void UBaseTileSceneComp::Init(FString type)
- float* subFound = subProp->ContainerPtrToValuePtr<float>(Prop->ContainerPtrToValuePtr<void>(DataAddr));
- if (subFound) {
- BalanceInfluence = *subFound;
- - UE_LOG(LogTemp, Warning, TEXT("found Float %f"), subFound);
- }
- subProp = Found->CustomFindProperty(FName("AirQualityValue"));
- @@ -51,7 +48,6 @@ void UBaseTileSceneComp::Init(FString type)
- subFound = subProp->ContainerPtrToValuePtr<float>(Prop->ContainerPtrToValuePtr<void>(DataAddr)); if (subFound) {
- AirQualityInfluence = *subFound;
- - UE_LOG(LogTemp, Warning, TEXT("found Float %f"), subFound);
- }
- subProp = Found->CustomFindProperty(FName("WaterRetentionRate"));
- @@ -59,7 +55,6 @@ void UBaseTileSceneComp::Init(FString type)
- subFound = subProp->ContainerPtrToValuePtr<float>(Prop->ContainerPtrToValuePtr<void>(DataAddr)); if (subFound) {
- WaterRetentionInfluence = *subFound;
- - UE_LOG(LogTemp, Warning, TEXT("found Float %f"), subFound);
- }
- subProp = Found->CustomFindProperty(FName("AirHindrance"));
- @@ -67,7 +62,6 @@ void UBaseTileSceneComp::Init(FString type)
- subFound = subProp->ContainerPtrToValuePtr<float>(Prop->ContainerPtrToValuePtr<void>(DataAddr)); if (subFound) {
- AirHindranceInfluence = *subFound;
- - UE_LOG(LogTemp, Warning, TEXT("found Float %f"), subFound);
- }
- }
- }
- @@ -105,12 +99,18 @@ void UBaseTileSceneComp::Init(FString type)
- meshComp->SetRelativeTransform(modelTransform);
- }
- }
- + SpecializationInit(type);
- +}
- +
- +void UBaseTileSceneComp::SpecializationInit(FString tileType)
- +{
- + //Fill in special Init things here in Subclasses
- }
- void UBaseTileSceneComp::PostLoad()
- {
- Super::PostLoad();
- - UE_LOG(LogTemp, Warning, TEXT("PostLoad"));
- - Init("Office");
- + //UE_LOG(LogTemp, Warning, TEXT("PostLoad"));
- + //Init("Office");
- }
- diff --git a/Source/UrbanHeat/TileComponents/BaseTileSceneComp.h b/Source/UrbanHeat/TileComponents/BaseTileSceneComp.h
- index b6cfe05..de6e359 100644
- --- a/Source/UrbanHeat/TileComponents/BaseTileSceneComp.h
- +++ b/Source/UrbanHeat/TileComponents/BaseTileSceneComp.h
- @@ -8,21 +8,6 @@
- #include "Engine/UserDefinedStruct.h"
- #include "BaseTileSceneComp.generated.h"
- -
- -/*
- -#define GETPROP(T, M) \
- -{ \
- - UProperty* M##Prop = Struct->FindField<UProperty>(TEXT(#M)); \
- - if (M##Prop) \
- - { \
- - T* Found = M##Prop->ContainerPtrToValuePtr<T>(DataAddr); \
- - if (Found) \
- - { \
- - Mirr.M = *Found; \
- - } \
- - } \
- -}*/
- -
- UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
- class URBANHEAT_API UBaseTileSceneComp : public USceneComponent
- {
- @@ -35,6 +20,7 @@ public:
- virtual void BeginPlay() override;
- void Init(FString type);
- + virtual void SpecializationInit(FString tileType);
- virtual void PostLoad() override;
- diff --git a/Source/UrbanHeat/TileComponents/BuildingSceneComp.cpp b/Source/UrbanHeat/TileComponents/BuildingSceneComp.cpp
- index ff657f2..6c2652f 100644
- --- a/Source/UrbanHeat/TileComponents/BuildingSceneComp.cpp
- +++ b/Source/UrbanHeat/TileComponents/BuildingSceneComp.cpp
- @@ -32,6 +32,30 @@ void UBuildingSceneComp::TickComponent(float DeltaTime, ELevelTick TickType, FAc
- // ...
- }*/
- +void UBuildingSceneComp::SpecializationInit(FString tileType)
- +{
- + roofSubComp = NewObject<USubTileSceneComp>(GetOwner()->GetRootComponent());
- + fasadeSubComp = NewObject<USubTileSceneComp>(GetOwner()->GetRootComponent());
- +
- +
- + AUrbanHeatGameState* gameStateRef = Cast<AUrbanHeatGameState>(GetWorld()->GetGameState());
- +
- + if (tileType == "Office") {
- + roofSubComp->Init(gameStateRef->GetDataTableByName("Office_RoofsData"),meshComp);
- + fasadeSubComp->Init(gameStateRef->GetDataTableByName("Office_FasadeData"), meshComp);
- + }
- +
- + if (tileType == "Shops") {
- + roofSubComp->Init(gameStateRef->GetDataTableByName("Shop_RoofsData"), meshComp);
- + fasadeSubComp->Init(gameStateRef->GetDataTableByName("Shop_FasadeData"), meshComp);
- + }
- +
- + if (tileType == "House") {
- + roofSubComp->Init(gameStateRef->GetDataTableByName("House_RoofsData"), meshComp);
- + fasadeSubComp->Init(gameStateRef->GetDataTableByName("House_FasadeData"), meshComp);
- + }
- +}
- +
- void UBuildingSceneComp::setRoof(FString type)
- {
- }
- diff --git a/Source/UrbanHeat/TileComponents/BuildingSceneComp.h b/Source/UrbanHeat/TileComponents/BuildingSceneComp.h
- index c9ea087..8a8458e 100644
- --- a/Source/UrbanHeat/TileComponents/BuildingSceneComp.h
- +++ b/Source/UrbanHeat/TileComponents/BuildingSceneComp.h
- @@ -6,6 +6,7 @@
- #include "Components/SceneComponent.h"
- #include "SubTileSceneComp.h"
- #include "BaseTileSceneComp.h"
- +#include "UrbanHeatGameState.h"
- #include "BuildingSceneComp.generated.h"
- @@ -18,9 +19,14 @@ public:
- // Sets default values for this component's properties
- UBuildingSceneComp();
- + UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
- USubTileSceneComp* roofSubComp;
- +
- + UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
- USubTileSceneComp* fasadeSubComp;
- + virtual void SpecializationInit(FString tileType) override;
- +
- protected:
- // Called when the game starts
- //virtual void BeginPlay() override;
- diff --git a/Source/UrbanHeat/TileComponents/SubTileSceneComp.cpp b/Source/UrbanHeat/TileComponents/SubTileSceneComp.cppindex 64f4ef4..355c54a 100644
- --- a/Source/UrbanHeat/TileComponents/SubTileSceneComp.cpp
- +++ b/Source/UrbanHeat/TileComponents/SubTileSceneComp.cpp
- @@ -13,9 +13,104 @@ USubTileSceneComp::USubTileSceneComp()
- }
- -void USubTileSceneComp::Init(UDataTable * table)
- +void USubTileSceneComp::Init(UDataTable * table, UStaticMeshComponent* MeshReference)
- {
- DataTable = table;
- +
- + meshComp = MeshReference;
- +
- + LoadType("Default");
- +}
- +
- +void USubTileSceneComp::LoadType(FString name)
- +{
- + UScriptStruct* Struct = DataTable->RowStruct;
- +
- + uint8* DataAddr = DataTable->FindRowUnchecked(FName(*name));
- +
- + UProperty* Prop = Struct->CustomFindProperty(FName("EnvironmentalValues"));
- + if (Prop)
- + {
- + UScriptStruct* Found = Cast<UStructProperty>(Prop)->Struct;
- + if (Found)
- + {
- + UProperty* subProp = Found->CustomFindProperty(FName("EconomicValue"));
- +
- + float* subFound = subProp->ContainerPtrToValuePtr<float>(Prop->ContainerPtrToValuePtr<void>(DataAddr));
- + if (subFound) {
- + BalanceInfluence = *subFound;
- + UE_LOG(LogTemp, Warning, TEXT("found Float %f"), subFound);
- + }
- +
- + subProp = Found->CustomFindProperty(FName("AirQualityValue"));
- +
- + subFound = subProp->ContainerPtrToValuePtr<float>(Prop->ContainerPtrToValuePtr<void>(DataAddr));+ if (subFound) {
- + AirQualityInfluence = *subFound;
- + UE_LOG(LogTemp, Warning, TEXT("found Float %f"), subFound);
- + }
- +
- + subProp = Found->CustomFindProperty(FName("WaterRetentionRate"));
- +
- + subFound = subProp->ContainerPtrToValuePtr<float>(Prop->ContainerPtrToValuePtr<void>(DataAddr));+ if (subFound) {
- + WaterRetentionInfluence = *subFound;
- + UE_LOG(LogTemp, Warning, TEXT("found Float %f"), subFound);
- + }
- +
- + subProp = Found->CustomFindProperty(FName("AirHindrance"));
- +
- + subFound = subProp->ContainerPtrToValuePtr<float>(Prop->ContainerPtrToValuePtr<void>(DataAddr));+ if (subFound) {
- + AirHindranceInfluence = *subFound;
- + UE_LOG(LogTemp, Warning, TEXT("found Float %f"), subFound);
- + }
- + }
- + }
- +
- + Prop = Struct->CustomFindProperty(FName("ReplaceModel"));
- + if (Prop)
- + {
- + bool* ShouldReplaceObject = Prop->ContainerPtrToValuePtr<bool>(DataAddr);
- + if (ShouldReplaceObject && *ShouldReplaceObject)
- + {
- + //ToDo following part should be replaced through proper authentic building placement
- + FTransform modelTransform = FTransform();
- + Prop = Struct->CustomFindProperty(FName("ModelTransform"));
- + if (Prop)
- + {
- + FTransform* Found = Prop->ContainerPtrToValuePtr<FTransform>(DataAddr);
- + if (Found)
- + {
- + modelTransform = *Found;
- + }
- + }
- +
- + Prop = Struct->CustomFindProperty(FName("Model"));
- + if (Prop)
- + {
- + FSoftObjectPath* Found = Prop->ContainerPtrToValuePtr<FSoftObjectPath>(DataAddr);
- +
- + if (Found)
- + {
- +
- + if (meshComp)
- + meshComp->DestroyComponent();
- +
- + meshComp = NewObject<UStaticMeshComponent>(this);
- + meshComp->RegisterComponent();
- + meshComp->AttachToComponent(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
- + UStaticMesh* Mesh = LoadObject<UStaticMesh>(nullptr, *Found->ToString());
- + if (Mesh) {
- + meshComp->SetStaticMesh(Mesh);
- + }
- + meshComp->SetRelativeTransform(modelTransform);
- + }
- + }
- + }
- + }
- +
- +
- }
- // Called when the game starts
- diff --git a/Source/UrbanHeat/TileComponents/SubTileSceneComp.h b/Source/UrbanHeat/TileComponents/SubTileSceneComp.h
- index 733c4dd..a74a536 100644
- --- a/Source/UrbanHeat/TileComponents/SubTileSceneComp.h
- +++ b/Source/UrbanHeat/TileComponents/SubTileSceneComp.h
- @@ -5,6 +5,7 @@
- #include "CoreMinimal.h"
- #include "Components/SceneComponent.h"
- #include "Engine/DataTable.h"
- +#include "Components/StaticMeshComponent.h"
- #include "SubTileSceneComp.generated.h"
- @@ -17,10 +18,11 @@ public:
- // Sets default values for this component's properties
- USubTileSceneComp();
- + UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
- UDataTable* DataTable;
- - void Init(UDataTable* table);
- - void SetType(FString name);
- + void Init(UDataTable* table, UStaticMeshComponent* MeshReference);
- + void LoadType(FString name);
- UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
- float BalanceInfluence = 0;
- @@ -34,6 +36,7 @@ public:
- UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
- float AirHindranceInfluence = 0;
- +
- protected:
- // Called when the game starts
- virtual void BeginPlay() override;
- @@ -41,4 +44,8 @@ protected:
- public:
- // Called every frame
- virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
- +
- +private:
- +
- + UStaticMeshComponent * meshComp;
- };
- (END)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement