blaster/Source/Blaster/Components/LagCompensationComponent.h

67 lines
1.5 KiB
C
Raw Normal View History

2022-05-26 15:32:23 +00:00
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
2022-05-27 09:06:39 +00:00
#include "Blaster/Character/BlasterCharacter.h"
2022-05-26 15:32:23 +00:00
#include "Components/ActorComponent.h"
#include "LagCompensationComponent.generated.h"
2022-05-27 09:06:39 +00:00
USTRUCT(BlueprintType)
struct FBoxInformation
{
GENERATED_BODY()
UPROPERTY()
FVector Location;
UPROPERTY()
FRotator Rotation;
UPROPERTY()
FVector BoxExtend;
};
USTRUCT(BlueprintType)
struct FFramePackage
{
GENERATED_BODY()
UPROPERTY()
float Time;
TMap<FName, FBoxInformation> HitBoxInfo;
};
2022-05-26 15:32:23 +00:00
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BLASTER_API ULagCompensationComponent : public UActorComponent
{
GENERATED_BODY()
public:
ULagCompensationComponent();
2022-05-27 09:06:39 +00:00
friend ABlasterCharacter;
2022-05-26 15:32:23 +00:00
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
2022-05-27 09:29:32 +00:00
void ShowFramePackage(const FFramePackage& Package, const FColor Color);
2022-05-27 14:06:23 +00:00
void ServerSideRewind(class ABlasterCharacter* HitCharacter, const FVector_NetQuantize& TraceStart, const FVector_NetQuantize& HitLocation, float HitTime);
2022-05-27 09:29:32 +00:00
2022-05-26 15:32:23 +00:00
protected:
virtual void BeginPlay() override;
2022-05-27 09:29:32 +00:00
void SaveFramePackage(FFramePackage& Package);
2022-05-27 15:05:07 +00:00
FFramePackage InterpBetweenFrames(const FFramePackage& OlderFrame, const FFramePackage& YoungerFrame, float HitTime);
2022-05-27 09:29:32 +00:00
2022-05-27 09:06:39 +00:00
private:
UPROPERTY()
ABlasterCharacter* Character;
2022-05-26 15:32:23 +00:00
2022-05-27 09:06:39 +00:00
UPROPERTY()
ABlasterPlayerController* Controller;
2022-05-27 13:36:32 +00:00
TDoubleLinkedList<FFramePackage> FrameHistory;
UPROPERTY(EditAnywhere)
float MaxRecordTime = 4.f;
2022-05-26 15:32:23 +00:00
};