60 lines
1.2 KiB
C++
60 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "GameFramework/Actor.h"
|
|
#include "MecanumVehicleAdapter.generated.h"
|
|
|
|
class FSocket;
|
|
class ISocketSubsystem;
|
|
|
|
UCLASS()
|
|
class MECANUMVEHICLE_API AMecanumVehicleAdapter : public AActor
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
|
|
AMecanumVehicleAdapter(const FObjectInitializer& ObjectInitializer);
|
|
|
|
UPROPERTY(BlueprintReadOnly)
|
|
double PingTime;
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
void UpdataCompensation(const TArray<double>& Value);
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
void UpdataSocket(const FString& IP, const int32 Port = 6000);
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
void UpdataInput(const FVector Value, const bool bIsBrake);
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
//~ Begin AActor Interface.
|
|
virtual void BeginPlay() override;
|
|
virtual void Tick(float DeltaSeconds) override;
|
|
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
|
//~ End AActor Interface.
|
|
|
|
private:
|
|
|
|
ISocketSubsystem* SocketSubsystem;
|
|
|
|
FSocket* UDPSocket;
|
|
|
|
TSharedPtr<FInternetAddr> Addr;
|
|
|
|
TArray<uint8> UDPBuffer;
|
|
|
|
int32 UDPSequenceIndex = 0;
|
|
|
|
FDateTime UDPLastTime;
|
|
|
|
FDateTime UDPRecvTime[(int32)MAX_uint8 + 1];
|
|
|
|
double SpeedCompensationMax[4] = { 1.0, 1.0, 1.0, 1.0 };
|
|
|
|
double SpeedCompensationMin[4] = { 0.0, 0.0, 0.0, 0.0 };
|
|
|
|
};
|