Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangingAttachmentsEventArgs"/> class.
 /// </summary>
 /// <param name="item"><inheritdoc cref="ChangingAttributesEventArgs.OldItem"/></param>
 /// <param name="newSight"><inheritdoc cref="ChangingAttributesEventArgs.NewSight"/></param>
 /// <param name="newBarrel"><inheritdoc cref="ChangingAttributesEventArgs.NewBarrel"/></param>
 /// <param name="newOther"><inheritdoc cref="ChangingAttributesEventArgs.NewOther"/></param>
 /// <param name="isAllowed"><inheritdoc cref="ChangingAttributesEventArgs.IsAllowed"/></param>
 public ChangingAttachmentsEventArgs(Inventory.SyncItemInfo item, SightType newSight, BarrelType newBarrel, OtherType newOther, bool isAllowed = true)
     : base(item, item, isAllowed)
 {
     NewSight  = newSight;
     NewBarrel = newBarrel;
     NewOther  = newOther;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangingAttachmentsEventArgs"/> class.
 /// </summary>
 /// <param name="item"><inheritdoc cref="ChangingAttributesEventArgs.OldItem"/></param>
 /// <param name="newSight"><inheritdoc cref="NewSight"/></param>
 /// <param name="newBarrel"><inheritdoc cref="NewBarrel"/></param>
 /// <param name="newOther"><inheritdoc cref="NewOther"/></param>
 /// <param name="isAllowed"><inheritdoc cref="ChangingAttributesEventArgs.IsAllowed"/></param>
 public ChangingAttachmentsEventArgs(Firearm item, SightType newSight, BarrelType newBarrel, OtherType newOther, bool isAllowed = true)
     : base(item, item, isAllowed)
 {
     NewSight  = newSight;
     NewBarrel = newBarrel;
     NewOther  = newOther;
     OldItem   = (API.Features.Items.Firearm)Item.Get(item);
 }
Exemple #3
0
 public void UpdateGun(BaseGunDefinition newGun)
 {
     if (newGun == null)
     {
         throw new Exception("Gun is null. Good luck you f*****g idiot");
     }
     currentGun       = newGun;
     usingAds         = false;
     continuousFire   = 0;
     rateOfFire       = 1.0f / currentGun.firingRate;
     doingAction      = false;
     currentShootMode = currentGun.defaultShootMode;
     currentSightMode = SightType.Normal;
     currentAcc       = currentGun.maxAccuracy;
 }
Exemple #4
0
    private IEnumerator Scoping(float timer)
    {
        if (currentSightMode == SightType.Ads)
        {
            currentSightMode = SightType.Normal;
        }
        else
        {
            currentSightMode = SightType.Ads;
        }
        doingAction = true;
        isScoping   = true;
        actionTime  = timer;
        SetSlider(timer);
        yield return(new WaitForSeconds(timer));

        doingAction = false;


        isScoping   = false;
        doingAction = false;
        Debug.Log($"Current shoot mode = { currentSightMode} at {Time.time} ");
    }
Exemple #5
0
 void SwitchSight(SightType type)
 {
     sightDic[currentSight].SetActive(false);
     currentSight = type;
     sightDic[currentSight].SetActive(true);
 }
Exemple #6
0
        /// <summary>
        /// Sets sight modification of the weapon.
        /// </summary>
        /// <param name="player">The player instance.</param>
        /// <param name="weapon">The weapon with attachment.</param>
        /// <param name="type">Type of the sight.</param>
        public static void SetSight(this Player player, Inventory.SyncItemInfo weapon, SightType type)
        {
            WeaponManager weaponManager = player.ReferenceHub.weaponManager;

            if (weapon.id.IsWeapon())
            {
                WeaponManager.Weapon wep = weaponManager.weapons.FirstOrDefault(wp => wp.inventoryID == weapon.id);
                if (wep != null)
                {
                    string name = type.ToString("g").SplitCamelCase();

                    int weaponMod = wep.mod_sights.Select((s, i) => new { s, i }).Where(e => e.s.name == name).Select(e => e.i).FirstOrDefault();
                    int weaponId  = player.Inventory.items.FindIndex(s => s == weapon);
                    weapon.modSight = weaponMod;
                    if (weaponId > -1)
                    {
                        player.Inventory.items[weaponId] = weapon;
                    }
                }
            }
        }