Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. namespace BasicItems.Items.Weapons.Guns
  2. {
  3.     public class MarksmanRifle00_AmmoLoaded : ModPlayer
  4.     {
  5.         private int _AmmoLoaded;
  6.         public virtual int AmmoLoaded
  7.         {
  8.             get { return _AmmoLoaded; }
  9.             set
  10.             {
  11.                 _AmmoLoaded = (value < 0 ? 0 : value) > AmmoCapacity ? AmmoCapacity : value;
  12.             }
  13.         }
  14.  
  15.         public static readonly int loadTimePerRoundTicks = (int)(.7f * 60f); //To be replaced with Flags config data
  16.  
  17.         public int TimeToNextLoad;
  18.  
  19.         public static readonly int AmmoCapacity = 15;   //To be replaced with Flags config data
  20.  
  21.         public virtual bool IsFullyLoaded {
  22.             get { return (AmmoLoaded >= AmmoCapacity); }
  23.         }
  24.  
  25.         public virtual bool LoadNextRound {
  26.             get { return (TimeToNextLoad <= 0); }
  27.         }
  28.  
  29.         public virtual bool HasAmmo {
  30.             get { return AmmoLoaded > 0; }
  31.         }
  32.  
  33.         public override void Initialize()
  34.         {
  35.             AmmoLoaded = AmmoCapacity;
  36.             TimeToNextLoad = loadTimePerRoundTicks;
  37.         }
  38.  
  39.         public override void PreUpdate()
  40.         {
  41.             if (!IsFullyLoaded)
  42.             {
  43.                 if (LoadNextRound)
  44.                 {
  45.                     TimeToNextLoad = loadTimePerRoundTicks;
  46.                     AmmoLoaded++;
  47.                 }
  48.                 else
  49.                 {
  50.                     TimeToNextLoad--;
  51.                 }
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement