15#include "Kismet/GameplayStatics.h"
16#include "NiagaraFunctionLibrary.h"
17#include "NiagaraComponent.h"
18#include "NiagaraSystem.h"
22 PrimaryActorTick.bCanEverTick =
false;
23 SensorsManager = CreateDefaultSubobject<USensorsManagerComponent>(TEXT(
"SensorsManagerComp"));
24 InteractableName = NSLOCTEXT(
"Agrarsense",
"VehicleInteractableName",
"Vehicle");
34 FTransform transform = GetTransform();
37 FString VehicleCollisionSensorID =
ActorID +
"/collision";
41 FString VehicleTransformSensorID =
ActorID +
"/transform";
44 float NiagaraComponentHeight = 500.0f;
45 float OverlapBoundsSize = 5000.0f;
50 OverlapBoundsSize = 2500.0f;
51 NiagaraComponentHeight = 200.0f;
54 FVector RelativePosition = FVector(0.0f, 0.0f, 0.0f);
58 RelativePosition = FVector(150.0f, -120.0f, 250.0f);
64 Params.
Size = FVector(OverlapBoundsSize, OverlapBoundsSize, OverlapBoundsSize);
67 FString OverlapSensorID =
ActorID +
"/overlap";
71 UNiagaraSystem* NiagaraSystem = LoadObject<UNiagaraSystem>(
nullptr, TEXT(
"/Game/Agrarsense/Particles/WaterAndSnow/NS_Particles.NS_Particles"));
74 NiagaraComponent = UNiagaraFunctionLibrary::SpawnSystemAttached(NiagaraSystem, this->GetRootComponent(),
75 FName(
"NiagaraEmitterSocketName"),
76 FVector(0.0, 0.0, NiagaraComponentHeight), FRotator::ZeroRotator, EAttachLocation::KeepRelativeOffset,
true);
82 Super::PossessedBy(NewController);
89 Super::EndPlay(EndPlayReason);
110 if (IsValid(
SensorsManager) && EndPlayReason == EEndPlayReason::Destroyed)
123 TArray<AActor*> AttachedActors;
124 GetAttachedActors(AttachedActors);
125 for (AActor* Actor : AttachedActors)
136 SetActorLocationAndRotation(NewLocation, NewRotation,
false,
nullptr, ETeleportType::TeleportPhysics);
151 FTransform TransformToUse = GetActorTransform();
153 if (OverrideTransform)
void SetVisualizeOverlapArea(bool Visualize)
ACollisionSensor * CollisionSensor
FTransform MovedFromGarageTransform
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
virtual void BeginPlay() override
virtual void PossessedBy(AController *NewController) override
virtual void TeleportVehicleTo_Implementation(FVector NewLocation, FRotator NewRotation)
bool IsVehicleInGarage() const
FString ExportToJsonFile(const FString &FileName)
void SetVisualizeVehicleOverlapArea(bool Visible)
AOverlapSensor * OverlapSensor
virtual EVehicleTypes GetVehicleType() const
void TogglePhysics(bool isOn)
ATransformSensor * TransformSensor
UNiagaraComponent * NiagaraComponent
TObjectPtr< USensorsManagerComponent > SensorsManager
static ATransformSensor * SpawnTransformSensor(const FTransform &transform, AActor *Owner, const FString sensorIdentifier, const FString sensorName, bool SimulateSensor=true)
static ACollisionSensor * SpawnCollisionSensor(const FTransform &transform, AActor *Owner, const FString sensorIdentifier, const FString sensorName, bool SimulateSensor=true)
static AOverlapSensor * SpawnOverlapSensor(const FTransform &transform, FOverlapSensorParameters Parameters, const FString sensorIdentifier, const FString sensorName)
static FString ExportVehicleAndSensorsToJSON(FString FileName, AVehicle *Vehicle, bool OverrideTransform=false, const FTransform &Transform=FTransform())
ETriggerShape TriggerShape