Started working on grab range
Signed-off-by: TjgL <lithmoneo@gmail.com>
This commit is contained in:
parent
13c0dbe486
commit
a7f9137dd5
BIN
Content/Legumix/Player/BP_GrabComponent.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Player/BP_GrabComponent.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Content/Legumix/Player/C_GrabMovement.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Legumix/Player/C_GrabMovement.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
53
Source/LegumeMix/Private/Player/LMGrabRange.cpp
Normal file
53
Source/LegumeMix/Private/Player/LMGrabRange.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "LMGrabRange.h"
|
||||||
|
|
||||||
|
#include "LMItemDrop.h"
|
||||||
|
#include "Player/LMPlayer.h"
|
||||||
|
|
||||||
|
|
||||||
|
ULMGrabRange::ULMGrabRange()
|
||||||
|
{
|
||||||
|
PrimaryComponentTick.bCanEverTick = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULMGrabRange::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||||
|
{
|
||||||
|
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULMGrabRange::OnDropOverlapped_Implementation(ALMItemDrop* ItemDrop)
|
||||||
|
{
|
||||||
|
Drops.AddUnique(ItemDrop);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ULMGrabRange::ConsumeDrop(ALMItemDrop* ItemDrop)
|
||||||
|
{
|
||||||
|
ItemDrop->ConsumePack(Player);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULMGrabRange::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
Player = CastChecked<ALMPlayer>(GetOwner());
|
||||||
|
OnComponentBeginOverlap.AddUniqueDynamic(this, &ULMGrabRange::OnComponentOverlap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ULMGrabRange::OnComponentOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
|
||||||
|
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||||
|
{
|
||||||
|
if (!bIsEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ALMItemDrop* ItemDrop = Cast<ALMItemDrop>(OtherActor))
|
||||||
|
{
|
||||||
|
OnDropOverlapped(ItemDrop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
52
Source/LegumeMix/Private/Player/LMGrabRange.h
Normal file
52
Source/LegumeMix/Private/Player/LMGrabRange.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Components/SphereComponent.h"
|
||||||
|
#include "LMGrabRange.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ALMPlayer;
|
||||||
|
class ALMItemDrop;
|
||||||
|
|
||||||
|
UCLASS(Blueprintable, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
|
||||||
|
class LEGUMEMIX_API ULMGrabRange : public USphereComponent
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
private:
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true))
|
||||||
|
bool bIsEnabled = true;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category=Legumix, meta=(AllowPrivateAccess=true))
|
||||||
|
TArray<ALMItemDrop*> Drops;
|
||||||
|
|
||||||
|
/** The range at which the drop is consumed. */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true, ClampMin=0.1f))
|
||||||
|
float RangeToGrab = 10.f;
|
||||||
|
|
||||||
|
/** Distance curve from 0-1 to the player. */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Legumix, meta=(AllowPrivateAccess=true))
|
||||||
|
TObjectPtr<UCurveFloat> SpeedAtPosition;
|
||||||
|
|
||||||
|
TObjectPtr<ALMPlayer> Player;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ULMGrabRange();
|
||||||
|
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category=Legumix)
|
||||||
|
void OnDropOverlapped(ALMItemDrop* ItemDrop);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category=Legumix)
|
||||||
|
void ConsumeDrop(ALMItemDrop* ItemDrop);
|
||||||
|
|
||||||
|
void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
UFUNCTION()
|
||||||
|
void OnComponentOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp,
|
||||||
|
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
|
||||||
|
};
|
Reference in New Issue
Block a user