haxis/Source/UnrealProject/Abilities/AbilityInfo.cpp

56 lines
1.3 KiB
C++

// Project Lab - NHTV Igad
#include "UnrealProject.h"
#include "AbilityInfo.h"
#include "AbilityState.h"
namespace
{
inline uint32 Hash32(const void* data, uint32 length)
{
const uint32 offset = 2166136261U;
const uint32 prime = 16777619U;
const unsigned char* data_bytes = (const unsigned char*)data;
uint32 value = offset;
for (uint32 next = 0; next < length; ++next)
{
value ^= (uint32)data_bytes[next];
value *= prime;
}
return value;
}
}
UAbilityInfo::UAbilityInfo()
{
name = L"<Designers!: Add Name>";
description = L"<Designers!: Add Description>";
cooldown = 1.0f;
AICastRange = 0.0f;
rotateTowardsPlayer = false;
abilityState = AAbilityState::StaticClass();
FString strName = GetPathName();
m_hash = Hash32(strName.GetCharArray().GetData(), strName.Len() * sizeof(wchar_t));
}
uint32 UAbilityInfo::GetStaticHash() const
{
return m_hash;
}
void AAbilityState::NativeSetCooldown()
{
SetCooldown();
cooldownRate = (currentCooldownDuration > 0.0f) ? (onCooldownTimer / currentCooldownDuration) : 0.0f;
}
void AAbilityState::SetCooldown_Implementation()
{
currentCooldownDuration = info->cooldown;
onCooldownTimer = currentCooldownDuration;
}
bool AAbilityState::IsMaxed() const
{
return power >= 1.0f;
}