ExoWest/Source/Exo/Private/Items/ThrowableBase.cpp
Foxim 2b6bdf9f80 feat: add grenade pickup, throw, and drop mechanics
Implemented basic grenade interaction:
- Player can pick up, throw, and drop grenades.

To-do:
- Refine throwing mechanics (e.g. direction, force).
- Clean up and refactor related code.
2025-04-08 18:22:33 +02:00

46 lines
1.0 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#include "Items/ThrowableBase.h"
#include "Characters/Components/ShootingComponent.h"
AThrowableBase::AThrowableBase()
{
PrimaryActorTick.bCanEverTick = true;
RootSceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
SetRootComponent(RootSceneComponent);
Mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
Mesh->SetupAttachment(GetRootComponent());
Mesh->SetSimulatePhysics(true);
}
void AThrowableBase::Interact_Implementation(AExoPlayerCharacter* PlayerCharacter)
{
if (PlayerCharacter->ShootingComponent->PickUpThrow(this))
{
Destroy();
}
}
void AThrowableBase::EffectActivate()
{
if (ThrowableType == ThrowableType::Hit)
{
UE_LOG(LogTemp, Display, TEXT("Throwable Hit"));
}
if (ThrowableType == ThrowableType::Explode)
{
UE_LOG(LogTemp, Display, TEXT("Throwable Explode"));
}
if (ThrowableType == ThrowableType::Area)
{
UE_LOG(LogTemp, Display, TEXT("Throwable Area"));
}
}