39 lines
1.0 KiB
C++
39 lines
1.0 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "CombatComponent.h"
|
|
|
|
#include "Blaster/Character/BlasterCharacter.h"
|
|
#include "Blaster/Weapon/Weapon.h"
|
|
#include "Engine/SkeletalMeshSocket.h"
|
|
|
|
UCombatComponent::UCombatComponent()
|
|
{
|
|
PrimaryComponentTick.bCanEverTick = false;
|
|
}
|
|
|
|
void UCombatComponent::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
}
|
|
|
|
void UCombatComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
|
{
|
|
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
|
|
|
}
|
|
|
|
void UCombatComponent::EquipWeapon(AWeapon* WeaponToEquip)
|
|
{
|
|
if (Character == nullptr || WeaponToEquip == nullptr) return;
|
|
|
|
EquippedWeapon = WeaponToEquip;
|
|
EquippedWeapon->SetWeaponState(EWeaponState::EWS_Equipped);
|
|
const USkeletalMeshSocket* HandSocket = Character->GetMesh()->GetSocketByName(FName("RightHandSocket"));
|
|
if (HandSocket)
|
|
{
|
|
HandSocket->AttachActor(EquippedWeapon, Character->GetMesh());
|
|
}
|
|
EquippedWeapon->SetOwner(Character);
|
|
}
|