OLS/Source/ols/Private/Characters/OLSCharacter.cpp

84 lines
2.2 KiB
C++
Raw Normal View History

2024-09-22 21:11:19 +00:00
// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
#include "Characters/OLSCharacter.h"
#include "Characters/Components/OLSCharacterMovementComponent.h"
#include "Components/OLSLocomotionComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "GameFramework/PawnMovementComponent.h"
// Sets default values
AOLSCharacter::AOLSCharacter(const FObjectInitializer& objectInitializer) : Super(
objectInitializer.SetDefaultSubobjectClass<UOLSCharacterMovementComponent>(
CharacterMovementComponentName))
{
PrimaryActorTick.bCanEverTick = false;
PrimaryActorTick.bStartWithTickEnabled = false;
NetCullDistanceSquared = 900000000.0f;
LocomotionComponent = CreateDefaultSubobject<UOLSLocomotionComponent>(TEXT("Locomotion Component"));
}
// Called when the game starts or when spawned
void AOLSCharacter::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AOLSCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AOLSCharacter::SetupPlayerInputComponent(UInputComponent* playerInputComponent)
{
Super::SetupPlayerInputComponent(playerInputComponent);
}
UPawnMovementComponent* AOLSCharacter::GetMovementComponent() const
{
return Cast<UPawnMovementComponent>(GetCharacterMovement());
}
UOLSLocomotionComponent* AOLSCharacter::GetLocomotionComponent() const
{
return LocomotionComponent;
}
float AOLSCharacter::GetMaxAcceleration() const
{
return GetCharacterMovement()->GetMaxAcceleration();
}
FVector AOLSCharacter::GetCurrentAcceleration() const
{
return GetCharacterMovement()->GetCurrentAcceleration();
}
EMovementMode AOLSCharacter::GetMovementMode() const
{
return GetCharacterMovement()->MovementMode;
}
void AOLSCharacter::SetMaxWalkSpeed(const float newMaxWalkSpeed)
{
GetCharacterMovement()->MaxWalkSpeed = newMaxWalkSpeed;
}
2024-10-23 22:41:23 +00:00
bool AOLSCharacter::IsOrientRotationToMovement() const
{
return GetCharacterMovement()->bOrientRotationToMovement;
}
2024-09-22 21:11:19 +00:00
UAnimInstance* AOLSCharacter::GetAnimInstance() const
{
return (GetMesh() ? GetMesh()->GetAnimInstance() : nullptr);
}