# Conflicts: # Content/Legumix/Player/BP_Player.uasset # Source/LegumeMix/Private/Player/LMPlayer.cpp
67 lines
1.7 KiB
C++
67 lines
1.7 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "Player/LMPlayer.h"
|
|
|
|
#include "Camera/CameraComponent.h"
|
|
#include "Weapon/LMAmmo.h"
|
|
#include "Weapon/LMWeaponManager.h"
|
|
|
|
ALMPlayer::ALMPlayer()
|
|
{
|
|
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
|
|
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
|
|
Camera->SetupAttachment(RootComponent);
|
|
Camera->bUsePawnControlRotation = true;
|
|
Camera->SetRelativeLocation(FVector(20, 0, 90));
|
|
|
|
WeaponSkeletalMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Weapon Mesh"));
|
|
WeaponSkeletalMeshComponent->SetupAttachment(Camera);
|
|
}
|
|
|
|
// Called when the game starts or when spawned
|
|
void ALMPlayer::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
|
|
}
|
|
|
|
void ALMPlayer::PickUpAmmo(ALMAmmo* Ammo)
|
|
{
|
|
if (GEngine)
|
|
{
|
|
FString AmmoAmount = FString::Printf(TEXT("Quantité de munition : %i"), Ammo->GetAmmoAmount());
|
|
GEngine->AddOnScreenDebugMessage(1, 30.f, FColor::Red, AmmoAmount);
|
|
}
|
|
}
|
|
|
|
void ALMPlayer::SetWeaponManager(ULMWeaponManager* Manager)
|
|
{
|
|
UE_LOG(LogTemp, Warning, TEXT("Set weapon manager"))
|
|
if (!Manager)
|
|
{
|
|
GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.f, FColor::Red, TEXT("No Weapon Manager was given to the player !"));
|
|
return;
|
|
}
|
|
|
|
WeaponManager = Manager;
|
|
WeaponManager->Initialize(WeaponSkeletalMeshComponent);
|
|
}
|
|
|
|
// Called every frame
|
|
void ALMPlayer::Tick(float DeltaTime)
|
|
{
|
|
Super::Tick(DeltaTime);
|
|
|
|
}
|
|
|
|
// Called to bind functionality to input
|
|
void ALMPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
|
|
{
|
|
Super::SetupPlayerInputComponent(PlayerInputComponent);
|
|
|
|
}
|
|
|