Creedbloom

OST_WheeledVehicle.cpp

Nov 16th, 2016
145
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. #include "OST_Game.h"
  4. #include "OST_Character.h"
  5. #include "OST_WheeledVehicle.h"
  6. #include "Vehicles/WheeledVehicleMovementComponent4W.h"
  7.  
  8.  
  9. AOST_WheeledVehicle::AOST_WheeledVehicle(const class FObjectInitializer& PCIP)
  10.     : Super(PCIP)
  11. {
  12.     Name = "noname";
  13.     About = "no about info";
  14.     Usable = true;
  15.     VehicleID = 0;
  16. }
  17.  
  18. bool AOST_WheeledVehicle::CanUsing()
  19. {
  20.     return Usable;
  21. }
  22.  
  23. FString AOST_WheeledVehicle::GetUsableName()
  24. {
  25.     return Name;
  26. }
  27. FString AOST_WheeledVehicle::GetUsableAbout()
  28. {
  29.     return About;
  30. }
  31.  
  32. void AOST_WheeledVehicle::DoUse(AActor* OtherUser)
  33. {
  34.     OnCustomUse(OtherUser);
  35.     OnUsed.Broadcast(OtherUser);
  36.     if (Cast<ACharacter>(OtherUser))
  37.     {
  38.         SetDriver(Cast<ACharacter>(OtherUser));
  39.     }
  40. }
  41.  
  42. bool AOST_WheeledVehicle::UseByThisKey(TSubclassOf<class AOST_Inventory> key)
  43. {
  44.     return true;
  45. }
  46.  
  47. void AOST_WheeledVehicle::ReceiveActorBeginOverlap(class AActor * OtherActor)
  48. {
  49.     if (Cast<AOST_Character>(OtherActor)) Cast<AOST_Character>(OtherActor)->AddUsingActor(this);
  50. }
  51.  
  52. void AOST_WheeledVehicle::ReceiveActorEndOverlap(class AActor * OtherActor)
  53. {
  54.     if (Cast<AOST_Character>(OtherActor)) Cast<AOST_Character>(OtherActor)->RemoveUsingActor(this);
  55. }
  56.  
  57. FTransform AOST_WheeledVehicle::GetAboutTextPlace()
  58. {
  59.     if (TextAboutComp)
  60.     {
  61.         return TextAboutComp->GetComponentTransform();
  62.     }
  63.     return GetTransform();
  64. }
  65.  
  66. USceneComponent* AOST_WheeledVehicle::GetSitPlaceComp()
  67. {
  68.     return SitPlaceComp;
  69. }
  70.  
  71. void AOST_WheeledVehicle::SetDriver(ACharacter* NewDriver)
  72. {
  73.     AOST_Character* _driver = Cast<AOST_Character>(NewDriver);
  74.     DriverCharacter = NewDriver;
  75.     if (_driver && _driver->bCanUsingVehicle)
  76.     {
  77.         _driver->StartDrivingOfVehicle(this, bIsHideDriver);
  78.         _driver->GetController()->Possess(this);
  79.     }
  80. }
  81.  
  82. void AOST_WheeledVehicle::ClearDriver()
  83. {
  84.     AOST_Character* _driver = Cast<AOST_Character>(DriverCharacter);
  85.  
  86.     if (_driver)
  87.     {
  88.         _driver->StopDrivingOfVehicle();
  89.  
  90.         if (OutPlace.Num() > 0)
  91.         {
  92.             //_driver->SetActorLocation(OutPlace[0]->GetComponentTransform().GetLocation());
  93.         }
  94.  
  95.         GetController()->Possess(_driver);
  96.     }
  97.     DriverCharacter = NULL;
  98. }
  99.  
  100. void AOST_WheeledVehicle::StartContactMaterialSurface(UVehicleWheel* wheel, UPhysicalMaterial* material)
  101. {
  102.     OnStartContactMaterialSurface(wheel, material);
  103. }
  104.  
  105. void AOST_WheeledVehicle::StopContactMaterialSurface(UVehicleWheel* wheel)
  106. {
  107.     OnStopContactMaterialSurface(wheel);
  108. }
  109.  
  110. void AOST_WheeledVehicle::Tick(float DeltaSeconds)
  111. {
  112.     bool _bIsContacting = false;
  113.  
  114.     Super::Tick(DeltaSeconds);
  115.  
  116.     if (!GetVehicleMovement() || GetVehicleMovement()->Wheels.Num() < 1)
  117.     {
  118.         return;
  119.     }
  120.  
  121.     for (int32 i = 0; i < GetVehicleMovement()->Wheels.Num(); i++)
  122.     {
  123.         UPhysicalMaterial* ContactMat = GetVehicleMovement()->Wheels[i]->GetContactSurfaceMaterial();
  124.         if (ContactMat)
  125.         {
  126.             _bIsContacting = true;
  127.             StartContactMaterialSurface(GetVehicleMovement()->Wheels[i], ContactMat);
  128.         }
  129.         else
  130.         {
  131.             StopContactMaterialSurface(GetVehicleMovement()->Wheels[i]);
  132.         }
  133.     }
  134.  
  135.     if (!_bIsContacting)
  136.     {
  137.         OnVehicleStopContactAnySurface();
  138.     }
  139.  
  140.     int32 _gear = GetVehicleMovement()->GetTargetGear();
  141.     if (LastGear != _gear)
  142.     {
  143.         OnChangeGear(_gear);
  144.         LastGear = _gear;
  145.     }  
  146. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×