diff --git a/Source/Blaster/Character/BlasterCharacter.cpp b/Source/Blaster/Character/BlasterCharacter.cpp index 44c6945..97d7629 100644 --- a/Source/Blaster/Character/BlasterCharacter.cpp +++ b/Source/Blaster/Character/BlasterCharacter.cpp @@ -6,6 +6,7 @@ #include "Blaster/Blaster.h" #include "Blaster/Components/BuffComponent.h" #include "Blaster/Components/CombatComponent.h" +#include "Blaster/Components/LagCompensationComponent.h" #include "Blaster/GameMode/BlasterGameMode.h" #include "Blaster/PlayerController/BlasterPlayerController.h" #include "Blaster/PlayerState/BlasterPlayerState.h" @@ -45,6 +46,8 @@ ABlasterCharacter::ABlasterCharacter() Combat = CreateDefaultSubobject(TEXT("CombatComponent")); Combat->SetIsReplicated(true); + LagCompensation = CreateDefaultSubobject(TEXT("LagCompensation")); + Buff = CreateDefaultSubobject(TEXT("BuffComponent")); Buff->SetIsReplicated(true); @@ -336,6 +339,14 @@ void ABlasterCharacter::PostInitializeComponents() Buff->SetInitialSpeeds(GetCharacterMovement()->MaxWalkSpeed, GetCharacterMovement()->MaxWalkSpeedCrouched); Buff->SetInitialJumpVelocity(GetCharacterMovement()->JumpZVelocity); } + if (LagCompensation) + { + LagCompensation->Character = this; + if (Controller) + { + LagCompensation->Controller = Cast(Controller); + } + } } void ABlasterCharacter::PlayFireMontage(bool bAiming) diff --git a/Source/Blaster/Character/BlasterCharacter.h b/Source/Blaster/Character/BlasterCharacter.h index b5baf81..2c7d8d9 100644 --- a/Source/Blaster/Character/BlasterCharacter.h +++ b/Source/Blaster/Character/BlasterCharacter.h @@ -150,11 +150,16 @@ private: UFUNCTION() void OnRep_OverlappingWeapon(AWeapon* LastWeapon); + // Blaster Components + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) class UCombatComponent* Combat; UPROPERTY(VisibleAnywhere) class UBuffComponent* Buff; + + UPROPERTY(VisibleAnywhere) + class ULagCompensationComponent* LagCompensation; UFUNCTION(Server, Reliable) void ServerEquipButtonPressed(); diff --git a/Source/Blaster/Components/LagCompensationComponent.h b/Source/Blaster/Components/LagCompensationComponent.h index cb55632..6a34afa 100644 --- a/Source/Blaster/Components/LagCompensationComponent.h +++ b/Source/Blaster/Components/LagCompensationComponent.h @@ -3,9 +3,35 @@ #pragma once #include "CoreMinimal.h" +#include "Blaster/Character/BlasterCharacter.h" #include "Components/ActorComponent.h" #include "LagCompensationComponent.generated.h" +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 HitBoxInfo; +}; UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class BLASTER_API ULagCompensationComponent : public UActorComponent @@ -14,12 +40,19 @@ class BLASTER_API ULagCompensationComponent : public UActorComponent public: ULagCompensationComponent(); + friend ABlasterCharacter; + virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; protected: virtual void BeginPlay() override; -public: +private: + UPROPERTY() + ABlasterCharacter* Character; + + UPROPERTY() + ABlasterPlayerController* Controller; };