Guest User

Untitled

a guest
Dec 16th, 2017
409
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using TheForest.Utils;
  3. using UnityEngine;
  4.  
  5. [global::DoNotSerializePublic]
  6. [Serializable]
  7. public class CaloriesSystemData
  8. {
  9.     [Header("Calories")]
  10.     public float JumpingCaloriesPerSecond = 0.5f;
  11.  
  12.     public float FightActionCalories = 3.5f;
  13.  
  14.     public float StationnaryCaloriesPerSecond = 0.03f;
  15.  
  16.     public float WalkingCaloriesPerSecond = 0.25f;
  17.  
  18.     public float RunningCaloriesPerSecond = 0.5f;
  19.  
  20.     public float SwimmingCaloriesPerSecond = 1.5f;
  21.  
  22.     public float CarryLogCaloriesPerSecond = 1f;
  23.  
  24.     [Header("Weight")]
  25.     public float WeightGainPerExcessCalory = 0.0005f;
  26.  
  27.     public float WeightLossPerMissingCalory = 0.00015f;
  28.  
  29.     public float StrengthLossPerMissingCalory = 0.0001f;
  30.  
  31.     [Header("Strength")]
  32.     public float StrengthGainPerEatenCalory = 0.001f;
  33.  
  34.     public float FightActionStrength = 0.001f;
  35.  
  36.     [global::SerializeThis, Header("Runtime data")]
  37.     public float CurrentCaloriesBurntCount;
  38.  
  39.     [global::SerializeThis]
  40.     public float CurrentCaloriesEatenCount;
  41.  
  42.     private int NextResolutionTime;
  43.  
  44.     public void Initialize()
  45.     {
  46.         if (TheForest.Utils.LocalPlayer.Stats.DaySurvived < 0.01f)
  47.         {
  48.         }
  49.         this.NextResolutionTime = this.GetNextResolutionTime();
  50.     }
  51.  
  52.     public void Refresh()
  53.     {
  54.         if (Time.timeScale > 0f)
  55.         {
  56.             if (TheForest.Utils.LocalPlayer.FpCharacter.jumping && !TheForest.Utils.LocalPlayer.FpCharacter.Sitting)
  57.             {
  58.                 this.CaloriesBurntChange(this.JumpingCaloriesPerSecond * Time.deltaTime);
  59.             }
  60.             if (TheForest.Utils.LocalPlayer.FpCharacter.swimming && TheForest.Utils.LocalPlayer.Stats.Stamina > 0f && TheForest.Utils.LocalPlayer.Rigidbody.velocity.sqrMagnitude > 1f)
  61.             {
  62.                 this.CaloriesBurntChange((this.SwimmingCaloriesPerSecond + ((!TheForest.Utils.LocalPlayer.FpCharacter.running) ? 0f : this.RunningCaloriesPerSecond)) * Time.deltaTime);
  63.             }
  64.             else if (TheForest.Utils.LocalPlayer.FpCharacter.running && TheForest.Utils.LocalPlayer.Stats.Stamina > 0f && TheForest.Utils.LocalPlayer.Rigidbody.velocity.sqrMagnitude > 1f)
  65.             {
  66.                 this.CaloriesBurntChange((this.RunningCaloriesPerSecond + (float)TheForest.Utils.LocalPlayer.Inventory.Logs.Amount * 1.5f * this.CarryLogCaloriesPerSecond) * Time.deltaTime);
  67.             }
  68.             else if (TheForest.Utils.LocalPlayer.FpCharacter.Grounded && TheForest.Utils.LocalPlayer.Rigidbody.velocity.sqrMagnitude > 0.3f)
  69.             {
  70.                 this.CaloriesBurntChange((this.WalkingCaloriesPerSecond + (float)TheForest.Utils.LocalPlayer.Inventory.Logs.Amount * this.CarryLogCaloriesPerSecond) * Time.deltaTime);
  71.             }
  72.             else if (TheForest.Utils.LocalPlayer.FpCharacter.Grounded)
  73.             {
  74.                 this.CaloriesBurntChange(this.StationnaryCaloriesPerSecond * Time.deltaTime);
  75.             }
  76.             if (this.NextResolutionTime == -1)
  77.             {
  78.                 this.NextResolutionTime = this.GetNextResolutionTime();
  79.             }
  80.             else if (global::FMOD_StudioEventEmitter.HoursSinceMidnight > (float)this.NextResolutionTime)
  81.             {
  82.                 this.NextResolutionTime = this.GetNextResolutionTime();
  83.                 this.Resolve();
  84.             }
  85.         }
  86.     }
  87.  
  88.     public int GetRawExcessCalories()
  89.     {
  90.         return Mathf.RoundToInt(this.CurrentCaloriesEatenCount - this.CurrentCaloriesBurntCount);
  91.     }
  92.  
  93.     public int GetExcessCaloriesFinal()
  94.     {
  95.         return this.GetRawExcessCalories();
  96.     }
  97.  
  98.     public int GetStrengthTrend()
  99.     {
  100.         return this.GetRawExcessCalories();
  101.     }
  102.  
  103.     public int GetWeightTrend()
  104.     {
  105.         return this.GetExcessCaloriesFinal();
  106.     }
  107.  
  108.     public void OnFighting()
  109.     {
  110.         this.CaloriesBurntChange(this.FightActionCalories);
  111.         this.StrengthChange(this.FightActionStrength);
  112.     }
  113.  
  114.     public void OnAteFood(int calories)
  115.     {
  116.         if (this.GetRawExcessCalories() <= 0)
  117.         {
  118.             this.StrengthChange((float)calories * this.StrengthGainPerEatenCalory);
  119.         }
  120.         this.CaloriesEatenChange((float)calories);
  121.     }
  122.  
  123.     public void OnAttacked()
  124.     {
  125.         if ((TheForest.Utils.LocalPlayer.ScriptSetup.treeHit.atStump || TheForest.Utils.LocalPlayer.ScriptSetup.treeHit.atTree) && (TheForest.Utils.LocalPlayer.Animator.GetBool("axeHeld") || TheForest.Utils.LocalPlayer.Animator.GetBool("chainSawHeld")))
  126.         {
  127.             this.CaloriesBurntChange(1f);
  128.         }
  129.     }
  130.  
  131.     private void CaloriesEatenChange(float value)
  132.     {
  133.         this.CurrentCaloriesEatenCount += value;
  134.     }
  135.  
  136.     private void CaloriesBurntChange(float value)
  137.     {
  138.         this.CurrentCaloriesBurntCount += value;
  139.     }
  140.  
  141.     private void WeightChange(float value)
  142.     {
  143.         TheForest.Utils.LocalPlayer.Stats.PhysicalStrength.WeightChange(value);
  144.     }
  145.  
  146.     private void StrengthChange(float value)
  147.     {
  148.         TheForest.Utils.LocalPlayer.Stats.PhysicalStrength.StrengthChange(value);
  149.     }
  150.  
  151.     public float TimeToNextResolution()
  152.     {
  153.         if (global::FMOD_StudioEventEmitter.HoursSinceMidnight < 21f)
  154.         {
  155.             return (float)this.NextResolutionTime - global::FMOD_StudioEventEmitter.HoursSinceMidnight;
  156.         }
  157.         return 24f - global::FMOD_StudioEventEmitter.HoursSinceMidnight + 8f;
  158.     }
  159.  
  160.     private int GetNextResolutionTime()
  161.     {
  162.         if (global::FMOD_StudioEventEmitter.HoursSinceMidnight < 8f)
  163.         {
  164.             return 8;
  165.         }
  166.         if (global::FMOD_StudioEventEmitter.HoursSinceMidnight < 13f)
  167.         {
  168.             return 13;
  169.         }
  170.         if (global::FMOD_StudioEventEmitter.HoursSinceMidnight < 21f)
  171.         {
  172.             return 21;
  173.         }
  174.         return -1;
  175.     }
  176.  
  177.     private void Resolve()
  178.     {
  179.         int excessCaloriesFinal = this.GetExcessCaloriesFinal();
  180.         if (excessCaloriesFinal > 0)
  181.         {
  182.             this.WeightChange((float)excessCaloriesFinal * this.WeightGainPerExcessCalory);
  183.         }
  184.         else
  185.         {
  186.             this.WeightChange((float)excessCaloriesFinal * this.WeightLossPerMissingCalory);
  187.             this.StrengthChange((float)excessCaloriesFinal * this.StrengthLossPerMissingCalory);
  188.         }
  189.         this.CurrentCaloriesBurntCount = 0f;
  190.         this.CurrentCaloriesEatenCount = 0f;
  191.     }
  192. }
RAW Paste Data