void ASCharacter::IncrementHunger() { Hunger = FMath::Clamp(Hunger + IncrementHungerAmount, 0.0f, GetMaxHunger()); if (Hunger > CriticalHungerThreshold) { // Apply damage to self. // TODO: Set DamageType TakeDamage(10.0f, FDamageEvent(), GetController(), this); } }
void ASCharacter::IncrementHunger() { Hunger = FMath::Clamp(Hunger + IncrementHungerAmount, 0.0f, GetMaxHunger()); if (Hunger > CriticalHungerThreshold) { FDamageEvent DmgEvent; DmgEvent.DamageTypeClass = HungerDamageType; // Apply damage to self. TakeDamage(HungerDamagePerInterval, DmgEvent, GetController(), this); } }
void ASCharacter::RestoreCondition(float HealthRestored, float HungerRestored) { // Reduce Hunger, ensure we do not go outside of our bounds Hunger = FMath::Clamp(Hunger - HungerRestored, 0.0f, GetMaxHunger()); // Restore Hitpoints Health = FMath::Clamp(Health + HealthRestored, 0.0f, GetMaxHealth()); ASPlayerController* PC = Cast<ASPlayerController>(Controller); if (PC) { PC->ClientHUDMessage(EHUDMessage::Character_EnergyRestored); } }
void ASCharacter::ConsumeFood(float AmountRestored) { // Reduce Hunger, ensure we do not go outside of our bounds Hunger = FMath::Clamp(Hunger - AmountRestored, 0.0f, GetMaxHunger()); // Restore Hitpoints Health = FMath::Clamp(Health + AmountRestored, 0.0f, GetMaxHealth()); APlayerController* PC = Cast<APlayerController>(Controller); if (PC) { ASHUD* MyHUD = Cast<ASHUD>(PC->GetHUD()); if (MyHUD) { MyHUD->MessageReceived("Food consumed!"); } } }