Newer
Older
SkyFrontier-Project-IADE-UE4-3D / Source / SkyFrontier / Private / DamageSystem.cpp
@Nelson Luis Moreira da Costa Nelson Luis Moreira da Costa on 16 Jan 2023 897 bytes Fixed issue that would soft crash the running application
  1. #include "DamageSystem.h"
  2. // Sets default values for this component's properties
  3. UDamageSystem::UDamageSystem()
  4. {
  5. PrimaryComponentTick.bCanEverTick = false;
  6. PrimaryComponentTick.bStartWithTickEnabled = false;
  7. SetIsReplicatedByDefault(true);
  8. ShootingDamage = 20;
  9. MissileDamage = 50;
  10. }
  11. // Called when the game starts
  12. void UDamageSystem::BeginPlay()
  13. {
  14. Super::BeginPlay();
  15. }
  16. float UDamageSystem::GetShootingDamage() const
  17. {
  18. return ShootingDamage;
  19. }
  20. float UDamageSystem::GetMissileDamage() const
  21. {
  22. return MissileDamage;
  23. }
  24. void UDamageSystem::MultiplyDamage(const float Amount)
  25. {
  26. if(Amount >= 0)
  27. {
  28. ShootingDamage *= Amount;
  29. MissileDamage *= Amount;
  30. OnIncreaseDamageEvent.Broadcast(Amount);
  31. }
  32. }
  33. void UDamageSystem::RestoreDamage(const float Amount)
  34. {
  35. if(Amount >= 0)
  36. {
  37. ShootingDamage /= Amount;
  38. MissileDamage /= Amount;
  39. OnIncreaseDamageEvent.Broadcast(Amount);
  40. }
  41. }