15#include "NiagaraFunctionLibrary.h"
16#include "NiagaraComponent.h"
17#include "NiagaraSystem.h"
21 PrimaryActorTick.bCanEverTick =
false;
22 SensorsManager = CreateDefaultSubobject<USensorsManagerComponent>(TEXT(
"SensorsManagerComp"));
23 InteractableName = NSLOCTEXT(
"Agrarsense",
"VehicleInteractableName",
"Vehicle");
33 FTransform transform = GetTransform();
36 FString VehicleCollisionSensorID =
ActorID +
"/collision";
40 FString VehicleTransformSensorID =
ActorID +
"/transform";
43 float NiagaraComponentHeight = 500.0f;
44 float OverlapBoundsSize = 5000.0f;
49 OverlapBoundsSize = 2500.0f;
50 NiagaraComponentHeight = 200.0f;
53 FVector RelativePosition = FVector(0.0f, 0.0f, 0.0f);
57 RelativePosition = FVector(150.0f, -120.0f, 250.0f);
63 Params.
Size = FVector(OverlapBoundsSize, OverlapBoundsSize, OverlapBoundsSize);
66 FString OverlapSensorID =
ActorID +
"/overlap";
70 UNiagaraSystem* NiagaraSystem = LoadObject<UNiagaraSystem>(
nullptr, TEXT(
"/Game/Agrarsense/Particles/WaterAndSnow/NS_Particles.NS_Particles"));
73 NiagaraComponent = UNiagaraFunctionLibrary::SpawnSystemAttached(NiagaraSystem, this->GetRootComponent(),
74 FName(
"NiagaraEmitterSocketName"),
75 FVector(0.0, 0.0, NiagaraComponentHeight), FRotator::ZeroRotator, EAttachLocation::KeepRelativeOffset,
true);
81 Super::PossessedBy(NewController);
88 Super::EndPlay(EndPlayReason);
109 if (IsValid(
SensorsManager) && EndPlayReason == EEndPlayReason::Destroyed)
124 SetActorLocationAndRotation(NewLocation, NewRotation,
false,
nullptr, ETeleportType::TeleportPhysics);
139 FTransform TransformToUse = GetActorTransform();
141 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