Skip to content

Commit

Permalink
Merge pull request #343 from RozeDoyanawa/development
Browse files Browse the repository at this point in the history
feat: compass rose to display grid position
  • Loading branch information
Panakotta00 authored Nov 14, 2024
2 parents d33f9f3 + 45ce145 commit a676568
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 0 deletions.
Binary file modified Content/Buildings/-Shared/BP_ModuleHoloWithCompass_def.uasset
Binary file not shown.
Binary file modified Content/Buildings/-Shared/BP_TestArrow.uasset
Binary file not shown.
Binary file added Content/Buildings/-Shared/MI_ArrowFont.uasset
Binary file not shown.
Binary file modified Content/Buildings/-Shared/MI_UpArrow.uasset
Binary file not shown.
Binary file added Content/Buildings/-Shared/M_ArrowFont.uasset
Binary file not shown.
Binary file modified Content/Buildings/-Shared/M_ArrowMaterial.uasset
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
AFINModuleSystemHolo::AFINModuleSystemHolo() {
PrimaryActorTick.bCanEverTick = true;
SetActorTickEnabled(true);

InformationComponent = CreateDefaultSubobject<UTextRenderComponent>(TEXT("InformationDisplay"));
InformationComponent->SetupAttachment(RootComponent);
InformationComponent->SetMobility(EComponentMobility::Movable);
InformationComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
}

AFINModuleSystemHolo::~AFINModuleSystemHolo() {}
Expand Down Expand Up @@ -142,6 +147,19 @@ void AFINModuleSystemHolo::SetHologramLocationAndRotation(const FHitResult& hit)
//FVector ArrowLocation = {0, }
CompassRose->SetRelativeLocation(ActorLocation);
}
if(EnableInformationDisplay && IsValid(InformationComponent)) {
// Roze is having issues getting the Z position correct for the text.
const FVector ModuleSize = getModuleSize();
InformationComponent->SetMobility(EComponentMobility::Movable);
InformationComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
FVector ActorLocation = { (ModuleSize.X - 1) * 5, (ModuleSize.Y - 1 ) * 5,0};
ActorLocation += InformationDisplayOffset;
if(ShowCompass && IsValid(CompassRose)) {
ActorLocation.Z = CompassRose->GetRelativeLocation().Z; // Dunno why this works, but it does.
}
InformationComponent->SetRelativeLocation(ActorLocation);
OnInformationUpdate(InformationComponent, hit, Snapped, SnappedLoc, SnappedRot);
}

//if(IsValid(CompassComponent)) {
// FVector ActorOrigin = {0, 0, 0};
Expand Down Expand Up @@ -192,4 +210,9 @@ void AFINModuleSystemHolo::OnConstruction(const FTransform& MovieSceneBlends) {

CompassRose->SetRelativeLocation(ActorLocation);
}
if(EnableInformationDisplay) {
InformationComponent->SetVisibility(true);
}else{
InformationComponent->SetVisibility(false);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include "CoreMinimal.h"
#include "FINModuleSystemPanel.h"
#include "Components/TextRenderComponent.h"
#include "Hologram/FGBuildableHologram.h"
#include "FINModuleSystemHolo.generated.h"

Expand Down Expand Up @@ -49,9 +51,22 @@ class FICSITNETWORKSMISC_API AFINModuleSystemHolo : public AFGBuildableHologram

UPROPERTY(EditAnywhere)
bool ShowCompass = false;

UPROPERTY(EditAnywhere, BlueprintReadOnly)
UTextRenderComponent* InformationComponent;

UPROPERTY(EditAnywhere)
bool EnableInformationDisplay = false;

UPROPERTY(EditAnywhere)
FVector InformationDisplayOffset = FVector(1,6.5,7);

UFUNCTION(BlueprintImplementableEvent)
void OnInformationUpdate(UTextRenderComponent* Component, const FHitResult& HitResult, UFINModuleSystemPanel* SnappedPanel, const FVector ModuleLocation, const int ModuleRotation);

private:
bool checkSpace(FVector min, FVector max);

FVector getModuleSize();

UPROPERTY()
Expand Down

0 comments on commit a676568

Please sign in to comment.