Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UCLASS(BlueprintType)
- class UNeed : public UObject
- {
- GENERATED_BODY()
- public:
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- ENeedType NeedType;
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- int MaxValue;
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- int MinValue;
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- int TriggerValue;
- /*'2' = vital, '1' = 'non-vital', '0' = utility*/
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- int Importance;
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- float CurrentValue;
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- float RateOfDecay;
- UPROPERTY(EditAnywhere, BlueprintReadWrite)
- bool Triggered;
- UPROPERTY(BlueprintReadOnly)
- float Utility;
- UFUNCTION(BlueprintCallable)
- UNeed* Setter(ENeedType CnsrtNeedType, int CnsrtMaxValue, int CnsrtMinValue, int CnsrtTriggerValue,
- int CnsrtImportance,
- float CnsrtCurrentValue, float CnsrtRateOfDecay);
- UFUNCTION(BlueprintCallable)
- float DecayNeed();
- UFUNCTION(BlueprintCallable)
- float CalculateUtiliy();
- UFUNCTION(BlueprintCallable)
- void SetCurrentValue(float ValueToSet);
- };
- UNeed* UNeed::Setter(ENeedType CnsrtNeedType, int CnsrtMaxValue, int CnsrtMinValue, int CnsrtTriggerValue,
- int CnsrtImportance, float CnsrtCurrentValue, float CnsrtRateOfDecay)
- {
- NeedType = CnsrtNeedType;
- MaxValue = CnsrtMaxValue;
- MinValue = CnsrtMinValue;
- TriggerValue = CnsrtTriggerValue;
- Importance = CnsrtImportance;
- CurrentValue = CnsrtCurrentValue;
- RateOfDecay = CnsrtRateOfDecay;
- Triggered = false;
- CalculateUtiliy();
- return this;
- }
- float UNeed::DecayNeed()
- {
- CurrentValue = FMath::Clamp(CurrentValue - RateOfDecay, MinValue, MaxValue);
- return CurrentValue;
- }
- float UNeed::CalculateUtiliy()
- {
- Utility = CurrentValue/MaxValue;
- return Utility;
- }
- void UNeed::SetCurrentValue(float ValueToSet)
- {
- CurrentValue = FMath::Clamp(CurrentValue + ValueToSet, MinValue, MaxValue);
- }
Advertisement
Add Comment
Please, Sign In to add comment