Advertisement
Guest User

Class with bad USphereComponent

a guest
Sep 2nd, 2015
189
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #pragma once
  4.  
  5. #include "GameFramework/Actor.h"
  6. #include "TargetComponent.h"
  7. #include "SensorMeshComponent.h"
  8. #include "DataNode.h"
  9. #include "ActionManagerInterface.h"
  10. #include "RRNodeTarget.h"
  11. #include "RRLevelDataAsset.h"
  12. #include "RRStaticFigureNode.generated.h"
  13.  
  14. UENUM(BlueprintType)// The way in which the node becomes activated in game
  15. enum class ENodeActivationType : uint8
  16. {
  17.     // Becomes active as soon as its on the players screen, no matter how far away
  18.     OnScreen                          UMETA(DisplayName = "OnScreen"),
  19.     // Becomes active when its on screen and in range of the player
  20.     OnScreenInRange           UMETA(DisplayName = "OnScreenInRange"),
  21.     // Becomes active when the player looks straight at it and its in range
  22.     LookedAtInRange           UMETA(DisplayName = "LookedAtInRange"),
  23.     // Becomes active when the player is a certain distance away, regardless of whether its looked at or on screen
  24.     Distance                         UMETA(DisplayName = "Distance")
  25. };
  26.  
  27.  
  28.  
  29. UCLASS()
  30. class RRDEVELOP_API ARRStaticFigureNode : public ACharacter, public IActionManagerInterface
  31. {
  32.     GENERATED_BODY()
  33.    
  34. public:
  35.     // Sets default values for this actor's properties
  36.     ARRStaticFigureNode(const FObjectInitializer& ObjectInitializer);
  37.  
  38.  
  39.  
  40.     UPROPERTY(EditAnywhere, Category = "StaticFigureNode")
  41.     class UBehaviorTree* NodeBehavior;
  42.  
  43.  
  44.  
  45.     // Called when the game starts or when spawned
  46.     virtual void BeginPlay() override;
  47.    
  48.     // Called every frame
  49.     virtual void Tick( float DeltaSeconds ) override;
  50.  
  51.  
  52.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "StaticFigureNode", meta = (ToolTip = "SpringArm component used to raise or lower the sensorcomponent if necessary"))
  53.     class USpringArmComponent* SensorPositionComponent;
  54.  
  55.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "StaticFigureNode", meta = (ToolTip = "Large interaction sphere used to register the node with an approaching player, or activate the node"))
  56.     class USphereComponent* InteractionSphere;
  57.  
  58.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "StaticFigureNode", meta = (ToolTip = "Optional subobject where the BodyMeshes are loaded/made visible"))
  59.     class USensorMeshComponent* BodyMesh;
  60.  
  61.     static FName StaticBodyMeshName;
  62.  
  63.  
  64.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "StaticFigureNode", meta = (ToolTip = "Resizeable sensor that is used to activate node by lookAt"))
  65.     class USensorMeshComponent* StaticFigureSensor;
  66.  
  67.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StaticFigureNode", meta = (ToolTip = "The next target that the node should progress to"))
  68.     class ARRNodeTarget* NextTargetInSequence;
  69.  
  70.  
  71.  
  72.  
  73.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  74.         virtual FName GetNameViaInterface() override;
  75.  
  76.     virtual void SpeakerIsTooFar(AActor* Speaker) override;
  77.  
  78.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  79.     virtual EObjectType GetObjectType() override;
  80.  
  81.  
  82.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  83.     virtual void UpdateCharacterData(FStringAssetReference NewSoundCue, FStringAssetReference NewAnimMontage) override;
  84.  
  85.  
  86.  
  87.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StaticFigureNode")
  88.     FName NodeName;
  89.  
  90.     virtual void PostInitializeComponents() override;
  91.  
  92.  
  93.  
  94.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  95.     void MinimizeSensorMesh();
  96.  
  97.  
  98.     // Specific function to destroy figure and cue sequences etc, called from Act
  99.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  100.     void CallDestroyFigureNode();
  101.  
  102.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  103.     bool IsInView();
  104.  
  105.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StaticFigureNode", meta = (ToolTip = "The way in which the node becomes active"))
  106.     ENodeActivationType ActivationType;
  107.  
  108.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "StaticFigureNode", meta = (ToolTip = "If activation type is distance, this value must be set"))
  109.     float ActivationDistance;
  110.  
  111.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  112.     int32 GetNumInRangePlayer();
  113.  
  114.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  115.     void LoadNodeMesh();
  116.  
  117.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  118.     void ExecuteCurrentNodeTarget();
  119.  
  120.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  121.     void AddToInRange(APawn* Incoming);
  122.  
  123.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  124.     void RemoveFromInRange(APawn* Outgoing);
  125.  
  126.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  127.     void LoadNodeMeshData();
  128.  
  129. private:
  130.  
  131.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  132.         void StartSensorLookAt(class USensorMeshComponent* HitSensor);
  133.  
  134.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  135.         void FinishSensorLookAt(class USensorMeshComponent* HitSensor);
  136.  
  137.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  138.         void StartFigureMeshLookAt(class USensorMeshComponent* HitSensor);
  139.  
  140.     UFUNCTION(BlueprintCallable, Category = "StaticFigureNode")
  141.         void FinishFigureMeshLookAt(class USensorMeshComponent* HitSensor);
  142.  
  143.  
  144.     FTimerHandle Load_Asset_Data;
  145.  
  146.     TArray<FQueryKVPair> NodeHistory;
  147.  
  148.     TArray<APawn*> InRangePlayers;
  149.  
  150.     EObjectType ObjectType;
  151.  
  152.     // Node target bool activates per tick events such as delta counting etc
  153.     bool bFigureMeshIsLoaded;
  154.  
  155.     // Mesh is loaded set by async loading delegate
  156.     bool bMeshTimerIsOn;
  157.  
  158.     bool bRunSequenceIsOn;
  159.  
  160.  
  161.  
  162.     float LifeTime;// when spawned time == lifetime the figure is unloaded
  163.  
  164.     //bool IsCounting;// Sets whether or not the spawned time is being updated
  165.     float RunTime;// How long the figure has been spawned (loaded) for
  166.  
  167.     EStaticFigureType CurrentFigureType;
  168.  
  169.     // Array to hold mesh data for all of the meshes loaded by the current NodeTarget
  170.     TArray<FRRLevelStaticMeshInfo> NodeTargetMeshData;
  171.  
  172.     // Array to hold mesh data for all of the meshes that can be loaded by this node
  173.     TArray<FRRLevelStaticMeshInfo> NodeMeshData;
  174.  
  175.  
  176.  
  177.     FStringAssetReference BodyMeshToLoad;
  178.    
  179.     FStringAssetReference MinimizedMeshToLoad;
  180.  
  181.     FStringAssetReference MaximizedMeshToLoad;
  182.  
  183.  
  184.     void DoAsyncMeshLoad();
  185.  
  186.     void InitStaticMesh(class UStaticMeshComponent* StaticMeshPointer, bool AttachToParent);
  187.  
  188.     void UnloadNodeMesh();
  189.  
  190.     UStaticMesh* MinimizedSensor;
  191. };
  192.  
  193. // Fill out your copyright notice in the Description page of Project Settings.
  194.  
  195. #include "RRDevelop.h"
  196. #include "RRDevelopGameMode.h"
  197. #include "RRGameSingleton.h"
  198. #include "RRStreamingLevelScriptActor.h"
  199. #include "RRDevelopGameMode.h"
  200. #include "RRFigureNodeAIController.h"
  201. #include "RRStaticFigureNode.h"
  202.  
  203. FName ARRStaticFigureNode::StaticBodyMeshName = FName(TEXT("StaticBodyMesh"));
  204.  
  205.  
  206.  
  207. ARRStaticFigureNode::ARRStaticFigureNode(const class FObjectInitializer& PCIP)
  208.     : Super(PCIP.DoNotCreateDefaultSubobject(TEXT("CharacterMesh0")))
  209. {
  210.  
  211.     SensorPositionComponent = CreateDefaultSubobject<USpringArmComponent>(TEXT("BodyMeshPositionComponent"));
  212.     SensorPositionComponent->AttachParent = GetCapsuleComponent();
  213.     SensorPositionComponent->TargetArmLength = 0.0f; // if the camera is in fps mode, the boom length is zero
  214.     SensorPositionComponent->SetRelativeLocation(FVector(0.f, 0.f, 0.f));
  215.  
  216.     InteractionSphere = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("InteractionSphere"));
  217. //  InteractionSphere->OnComponentBeginOverlap.AddDynamic(this, &ARRStaticFigureNode::OnBeginOverlap);
  218. //  InteractionSphere->OnComponentEndOverlap.AddDynamic(this, &ARRStaticFigureNode::OnEndOverlap);
  219.     InteractionSphere->AttachParent = SensorPositionComponent;;
  220.     InteractionSphere->SetCollisionObjectType(ECC_WorldDynamic);
  221.     InteractionSphere->SetSphereRadius(400.f);
  222.  
  223.  
  224.     BodyMesh = CreateOptionalDefaultSubobject<USensorMeshComponent>(ARRStaticFigureNode::StaticBodyMeshName);
  225.     BodyMesh->OnSensorStartHit.AddDynamic(this, &ARRStaticFigureNode::StartFigureMeshLookAt);
  226.     BodyMesh->OnSensorEndHit.AddDynamic(this, &ARRStaticFigureNode::FinishFigureMeshLookAt);
  227.     BodyMesh->SensorType = ESensorType::StaticFigure;
  228.     BodyMesh->AttachParent = GetCapsuleComponent();
  229.     BodyMesh->SetRelativeLocation(FVector(0.f, 0.f, -75.f));
  230.     BodyMesh->SetRelativeRotation(FRotator(0.f, -90.f, 0.f));
  231.     BodyMesh->SensorName = "static_figure_mesh";
  232.     BodyMesh->SensorType = ESensorType::StaticFigure;
  233.  
  234.  
  235.  
  236.     StaticFigureSensor = PCIP.CreateOptionalDefaultSubobject<USensorMeshComponent>(this, TEXT("StaticFigureSensor"));
  237.     StaticFigureSensor->OnSensorStartHit.AddDynamic(this, &ARRStaticFigureNode::StartSensorLookAt);
  238.     StaticFigureSensor->OnSensorEndHit.AddDynamic(this, &ARRStaticFigureNode::FinishSensorLookAt);
  239.     StaticFigureSensor->AttachParent = SensorPositionComponent;
  240.     StaticFigureSensor->bHiddenInGame = true;
  241.     StaticFigureSensor->SetCollisionObjectType(INTERACTION_CHANNEL);
  242.     StaticFigureSensor->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
  243.     StaticFigureSensor->SetCollisionResponseToChannel(ECC_GameTraceChannel1, ECR_Block);
  244.    
  245.     StaticFigureSensor->SensorName = "static_figure_sensor";
  246.     StaticFigureSensor->SensorType = ESensorType::StaticFigure;
  247.    
  248.    
  249.     bRunSequenceIsOn = false;
  250.     bMeshTimerIsOn = false;
  251.     RunTime = 0.f;
  252.  
  253.     ObjectType = EObjectType::StaticFigureNode;
  254.  
  255. }
  256.  
  257. // Called when the game starts or when spawned
  258. void ARRStaticFigureNode::BeginPlay()
  259. {
  260.     Super::BeginPlay();
  261.  
  262.    
  263.     //GetWorldTimerManager().SetTimer(Load_Asset_Data, this, &ARRStaticFigureNode::LoadNodeMeshData, 0.5f, true);
  264.    
  265. }
  266.  
  267. // Called every frame
  268. void ARRStaticFigureNode::Tick( float DeltaTime )
  269. {
  270.     Super::Tick( DeltaTime );
  271.  
  272.    
  273.  
  274.     if (bMeshTimerIsOn)
  275.     {
  276.         RunTime = RunTime + DeltaTime;
  277.         if (RunTime >= LifeTime)
  278.         {
  279.             UnloadNodeMesh();
  280.         }
  281.     }
  282.    
  283. }
  284.  
  285.  
  286.  
  287. void ARRStaticFigureNode::PostInitializeComponents()
  288. {
  289.     Super::PostInitializeComponents();
  290.     //ThisCharRace = FCharacterRace::RACESEX_ElfMale; //<- This could be coming from a save file overriding
  291.  
  292.     // Picks the right Database Path and name;
  293. //  switch (ThisCharRace)
  294. //  {
  295. //  case FCharacterRace::RACESEX_ElfMale:
  296. //      DatabasePath = "/Game/SubDirectory/ElfMaleData.ElfMaleData"; // <- You need databases to load from!
  297. //      break;
  298. //
  299. //  default:
  300. //      DatabasePath = "/Game/SubDirectory/ElfFemaleData.ElfFemaleData"; // <- You need databases to load from!
  301. //      break
  302. //  }
  303.  
  304.     // Call to load library and setup meshes
  305. //  InitDefaultMeshes(0, 1, 2, 3, 4);
  306. }
  307.  
  308.  
  309. void ARRStaticFigureNode::CallDestroyFigureNode()
  310. {
  311. //  if ()
  312. //  {
  313.  
  314.         ARRDevelopGameMode* GameMode = Cast<ARRDevelopGameMode>(UGameplayStatics::GetGameMode(this));
  315.  
  316.         GameMode->SelectAndDestroy(this);
  317.     //}
  318. }
  319.  
  320. void ARRStaticFigureNode::InitStaticMesh(class UStaticMeshComponent* StaticMeshPointer, bool AttachToParent)
  321. {
  322.     StaticMeshPointer->AlwaysLoadOnClient = true;
  323.     StaticMeshPointer->AlwaysLoadOnServer = true;
  324.     StaticMeshPointer->bOwnerNoSee = false;
  325.     //StaticMeshPointer->MeshComponentUpdateFlag = EMeshComponentUpdateFlag::AlwaysTickPose;
  326.     StaticMeshPointer->bCastDynamicShadow = true;
  327.     StaticMeshPointer->bAffectDynamicIndirectLighting = true;
  328.     StaticMeshPointer->PrimaryComponentTick.TickGroup = TG_PrePhysics;
  329.     //StaticMeshPointer->bChartDistanceFactor = false;
  330.     //StaticMeshPointer->AttachParent = RootComponent;
  331.  
  332.     if (AttachToParent)
  333.     {
  334.         StaticMeshPointer->AttachParent = GetCapsuleComponent();
  335. //      StaticMeshPointer->SetMasterPoseComponent(HeadMSHComponent);
  336. //      StaticMeshPointer->bUseBoundsFromMasterPoseComponent = true;
  337.     }
  338. }
  339.  
  340.  
  341. void ARRStaticFigureNode::StartSensorLookAt(class USensorMeshComponent* HitSensor)
  342. {
  343.     GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::White, TEXT("StaticFigureNode LOOKAT Fired"));
  344.     ARRFigureNodeAIController* NodeController = Cast<ARRFigureNodeAIController>(this->GetController());
  345.     if (ActivationType == ENodeActivationType::LookedAtInRange)
  346.     {
  347.         if (NodeController->GetNodeBehaviorType() == ENodeBehaviorType::Inactive)
  348.         {
  349.             NodeController->SetNodeBehaviorType(ENodeBehaviorType::ExecuteSequence);
  350.             MinimizeSensorMesh();
  351.         }
  352.     }
  353.     //LoadNewMesh();
  354. }
  355.  
  356. void ARRStaticFigureNode::FinishSensorLookAt(class USensorMeshComponent* HitSensor)
  357. {
  358.     GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::White, TEXT("StaticFigureNode FINISHLOOKAT Fired"));
  359.    
  360. }
  361.  
  362. void ARRStaticFigureNode::StartFigureMeshLookAt(class USensorMeshComponent* HitSensor)
  363. {
  364.     switch (CurrentFigureType)
  365.     {
  366.     case EStaticFigureType::ProximityOrLookAt:
  367.     {
  368.         UnloadNodeMesh();
  369.     }
  370.     break;
  371.     case EStaticFigureType::LookAtTimeout:
  372.     {
  373.         bMeshTimerIsOn = true;
  374.     }
  375.     break;
  376.     }
  377.     GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::White, TEXT("StaticFigureNode LOOKAT Fired"));
  378.    
  379. }
  380.  
  381. void ARRStaticFigureNode::FinishFigureMeshLookAt(class USensorMeshComponent* HitSensor)
  382. {
  383.     if (CurrentFigureType == EStaticFigureType::LookAtTimeout)
  384.     {
  385.         bMeshTimerIsOn = false;
  386.     }
  387.  
  388.     GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::White, TEXT("StaticFigureNode FINISHLOOKAT Fired"));
  389.  
  390. }
  391.  
  392.  
  393. void ARRStaticFigureNode::AddToInRange(APawn* Incoming)
  394. {
  395.     if (!InRangePlayers.Contains(Incoming))
  396.     {
  397.         InRangePlayers.Add(Incoming);
  398.         if (bRunSequenceIsOn)
  399.         {
  400.             switch (CurrentFigureType)
  401.             {
  402.             case EStaticFigureType::Proximity:
  403.             {
  404.                 UnloadNodeMesh();
  405.             }
  406.             break;
  407.             case EStaticFigureType::ProximityOrLookAt:
  408.             {
  409.                 UnloadNodeMesh();
  410.             }
  411.             break;
  412.             }
  413.         }
  414.     }
  415. }
  416.  
  417. void ARRStaticFigureNode::RemoveFromInRange(APawn* Outgoing)
  418. {
  419.     if (InRangePlayers.Contains(Outgoing))
  420.     {
  421.         InRangePlayers.Remove(Outgoing);
  422.     }
  423. }
  424.  
  425. // void ARRStaticFigureNode::OnBeginOverlap(AActor* Other, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
  426. // {
  427. //  GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::White, TEXT("StaticFigureNode ONBEGINOVERLAP Fired"));
  428. //  APlayerController* Controller = UGameplayStatics::GetPlayerController(GetWorld(), 0);
  429. //  APawn* PlayerPawn = Controller->GetPawn();
  430. //  APawn* IncomingPawn = Cast<APawn>(Other);
  431. //
  432. //  if (PlayerPawn == Other)
  433. //  {
  434. //      InRangePlayers.Add(IncomingPawn);
  435. //  }
  436. // }
  437.  
  438. // void ARRStaticFigureNode::OnEndOverlap(AActor* Other, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
  439. // {
  440. //  GEngine->AddOnScreenDebugMessage(-1, 2.0f, FColor::White, TEXT("StaticFigureNode ONENDOVERLAP Fired"));
  441. //
  442. //  APawn* OutgoingPawn = Cast<APawn>(Other);
  443. //
  444. //  if (InRangePlayers.Contains(OutgoingPawn))
  445. //  {
  446. //      InRangePlayers.Remove(OutgoingPawn);
  447. //  }
  448. // }
  449.  
  450. void ARRStaticFigureNode::ExecuteCurrentNodeTarget()
  451. {
  452.     NodeTargetMeshData.Empty();
  453.     if (NextTargetInSequence != NULL && NodeMeshData.Num() > 0)
  454.     {
  455.         for (int32 i = 0; i < NextTargetInSequence->NumFiguresToSpawn; i++)
  456.         {
  457.             if (NodeMeshData.IsValidIndex(0))
  458.             {
  459.                 NodeTargetMeshData.Add(NodeMeshData[0]);
  460.                 NodeMeshData.RemoveAt(0);
  461.             }
  462.         }
  463.     }
  464.     bRunSequenceIsOn = true;
  465.     LoadNodeMesh();
  466. }
  467.  
  468.  
  469.  
  470.  
  471. void ARRStaticFigureNode::LoadNodeMeshData()
  472. {
  473.    
  474.     ARRDevelopGameMode* GameMode = Cast<ARRDevelopGameMode>(UGameplayStatics::GetGameMode(this));
  475.  
  476.     ARRStreamingLevelScriptActor* Level = GameMode->GetCurrentStreamingLevel();
  477.  
  478.     NodeMeshData = Level->GetStaticFigureInfo(NodeName);
  479.     MinimizedMeshToLoad = Level->GetMinimizedSensorRef();
  480. }
  481.  
  482. void ARRStaticFigureNode::LoadNodeMesh()
  483. {
  484.     if (NodeTargetMeshData.Num() > 0)
  485.     {
  486.         if (NodeTargetMeshData.IsValidIndex(0))
  487.         {
  488.             BodyMeshToLoad = NodeTargetMeshData[0].FRRLevelStaticMeshInfo::BodyMeshAsset.ToStringReference();
  489.             LifeTime = NodeTargetMeshData[0].Lifetime;
  490.             CurrentFigureType = NodeTargetMeshData[0].StaticFigureType;
  491.  
  492.             FStreamableManager& BaseLoader = URRGameSingleton::Get().AssetLoader;
  493.  
  494.             BaseLoader.RequestAsyncLoad(BodyMeshToLoad, FStreamableDelegate::CreateUObject(this, &ARRStaticFigureNode::DoAsyncMeshLoad));
  495.  
  496.             NodeTargetMeshData.RemoveAt(0);
  497.         }
  498.     }
  499.  
  500.     else
  501.     {
  502.         bRunSequenceIsOn = false;
  503.         bMeshTimerIsOn = false;
  504.     }
  505. }
  506.  
  507. void ARRStaticFigureNode::UnloadNodeMesh()
  508. {
  509.     BodyMesh->SetStaticMesh(NULL);
  510.     LoadNodeMesh();
  511. }
  512.  
  513. void ARRStaticFigureNode::DoAsyncMeshLoad()
  514. {
  515.     check(BodyMeshToLoad.ResolveObject() != nullptr)
  516.     {
  517.         UObject* NewMesh = BodyMeshToLoad.ResolveObject();      // Creates a pointer to store the loaded object
  518.         BodyMesh->SetStaticMesh(Cast<UStaticMesh>(NewMesh));
  519.         RunTime = 0;
  520.         switch (CurrentFigureType)
  521.         {
  522.         case EStaticFigureType::Timeout:
  523.         {
  524.             bMeshTimerIsOn = true;
  525.         }
  526.         break;
  527.         case EStaticFigureType::TimeoutOrProximity:
  528.         {
  529.             bMeshTimerIsOn = true;
  530.         }
  531.         break;
  532.         case EStaticFigureType::Proximity:
  533.         {
  534.             bMeshTimerIsOn = false;
  535.         }
  536.         break;
  537.         case EStaticFigureType::ProximityOrLookAt:
  538.         {
  539.             bMeshTimerIsOn = false;
  540.         }
  541.         break;
  542.         case EStaticFigureType::LookAtTimeout:
  543.         {
  544.             bMeshTimerIsOn = false;
  545.         }
  546.         break;
  547.         case EStaticFigureType::Interact:
  548.         {
  549.             bMeshTimerIsOn = false;
  550.         }
  551.         break;
  552.         }
  553.     }
  554. }
  555.  
  556.  
  557.  
  558. void ARRStaticFigureNode::MinimizeSensorMesh()
  559. {
  560.     StaticFigureSensor->SetRelativeScale3D(FVector(0.001, 0.001, 0.001));
  561. }
  562.  
  563.  
  564.  
  565. FName ARRStaticFigureNode::GetNameViaInterface()
  566. {
  567.     return NodeName;
  568. }
  569.  
  570.  
  571. void ARRStaticFigureNode::SpeakerIsTooFar(AActor* Speaker)
  572. {
  573.  
  574. }
  575.  
  576. void ARRStaticFigureNode::UpdateCharacterData(FStringAssetReference NewSoundCue, FStringAssetReference NewAnimMontage)
  577. {
  578.  
  579. }
  580.  
  581. EObjectType ARRStaticFigureNode::GetObjectType()
  582. {
  583.     return ObjectType;
  584. }
  585.  
  586. int32 ARRStaticFigureNode::GetNumInRangePlayer()
  587. {
  588.     return InRangePlayers.Num();
  589. }
  590.  
  591.  
  592. bool ARRStaticFigureNode::IsInView()
  593. {
  594.  
  595.    
  596. //  TArray<UPrimitiveComponent*> Components;
  597. //  GetComponents(Components);
  598.  
  599. //  for (int32 i = 0; i < Components.Num(); i++)
  600. //  {
  601. //      UPrimitiveComponent* Component = Components[i];
  602. //      if (Component->IsA(USphereComponent::StaticClass()))
  603. //      {
  604.  
  605.             //float RenderTime = Component->UPrimitiveComponent::LastRenderTime;
  606.             float WorldTime = GetWorld()->TimeSeconds;
  607.             float RenderTime = this->GetLastRenderTime();
  608.             float Difference = WorldTime - RenderTime;
  609.             FString Rendertimestring = FString::SanitizeFloat(RenderTime);
  610.             FString worldtimestring = FString::SanitizeFloat(WorldTime);
  611.             GEngine->AddOnScreenDebugMessage(2, 10.0f, FColor::Red, TEXT("Rendertime: " + Rendertimestring));
  612.             GEngine->AddOnScreenDebugMessage(3, 10.0f, FColor::Red, TEXT("Worldtime: " + worldtimestring));
  613.             if (Difference < 0.2) {
  614.                 return true;
  615.             }
  616. //      }
  617. //
  618. //  }
  619.     else return false;
  620. }
Advertisement
RAW Paste Data Copied
Advertisement