public void SwitchBag(int index) { if (SwitchBagByReservedType(index)) { return; } var tarBag = FindWeaponBagDataBySlot(index); if (tarBag == null) { return; } var removedSlotList = new Byte[(int)EWeaponSlotType.Length]; DestroyWeapon(EWeaponSlotType.ThrowingWeapon, 0); RefreshWeaponAppearance(EWeaponSlotType.ThrowingWeapon); GrenadeHandler.ClearCache(); foreach (var weapon in tarBag.weaponList) { var slot = PlayerWeaponBagData.Index2Slot(weapon.Index); var weaponAllConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weapon.WeaponTplId); if (slot != EWeaponSlotType.ThrowingWeapon && slot != EWeaponSlotType.TacticWeapon) { var orient = WeaponUtil.CreateScan(weapon); orient.Bullet = weaponAllConfig.PropertyCfg.Bullet; orient.ReservedBullet = weaponAllConfig.PropertyCfg.Bulletmax; if (orient.Magazine > 0) { orient.Bullet += SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(orient.Magazine).Bullet; } ReplaceWeaponToSlot(slot, 0, orient); } else if (slot == EWeaponSlotType.ThrowingWeapon) { GrenadeHandler.AddCache(weapon.WeaponTplId); } removedSlotList[(int)slot] = 1; } removedSlotList[(int)EWeaponSlotType.TacticWeapon] = 1; removedSlotList[(int)EWeaponSlotType.ThrowingWeapon] = 1; for (int i = 1; i < removedSlotList.Length; i++) { if (removedSlotList[i] == 0) { DestroyWeapon((EWeaponSlotType)i, 0); } } EWeaponSlotType newSlot = PollGetLastSlotType(); TryHoldGrenade(true, false); TryArmWeaponImmediately(newSlot); }
public bool SwitchBagByReservedType(int index) { if (null == RelatedServerUpdate.ReservedWeaponSubType || RelatedServerUpdate.ReservedWeaponSubType.Count == 0) { return(false); } var tarBag = FindWeaponBagDataBySlot(index); if (tarBag == null) { return(true); } DestroyWeapon(EWeaponSlotType.ThrowingWeapon, 0); RefreshWeaponAppearance(EWeaponSlotType.ThrowingWeapon); GrenadeHandler.ClearCache(); RelatedGamePlay.ArmorLv = RelatedGamePlay.CurArmor = RelatedGamePlay.MaxArmor = 0; RelatedGamePlay.HelmetLv = RelatedGamePlay.CurHelmet = RelatedGamePlay.MaxHelmet = 0; var removedSlotList = new Byte[(int)EWeaponSlotType.Length]; foreach (var weapon in tarBag.weaponList) { bool needReserved = false; var weaponAllConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weapon.WeaponTplId); if (weaponAllConfig.NewWeaponCfg.Type == (int)EWeaponType_Config.ThrowWeapon) { needReserved = RelatedServerUpdate.ReservedWeaponSubType.Contains((int)EWeaponSubType.Throw); } else { needReserved = RelatedServerUpdate.ReservedWeaponSubType.Contains(weaponAllConfig.NewWeaponCfg.SubType); } if (!needReserved) { continue; } if (weaponAllConfig.NewWeaponCfg.Type == (int)EWeaponType_Config.Armor) { RelatedGamePlay.ArmorLv = weaponAllConfig.NewWeaponCfg.Id; RelatedGamePlay.MaxArmor = RelatedGamePlay.CurArmor = weaponAllConfig.NewWeaponCfg.Durable; continue; } if (weaponAllConfig.NewWeaponCfg.Type == (int)EWeaponType_Config.Helmet) { RelatedGamePlay.HelmetLv = weaponAllConfig.NewWeaponCfg.Id; RelatedGamePlay.MaxHelmet = RelatedGamePlay.CurHelmet = weaponAllConfig.NewWeaponCfg.Durable; continue; } var slot = PlayerWeaponBagData.Index2Slot(weapon.Index); if (slot != EWeaponSlotType.ThrowingWeapon && slot != EWeaponSlotType.TacticWeapon) { var orient = WeaponUtil.CreateScan(weapon); orient.Bullet = weaponAllConfig.PropertyCfg.Bullet; orient.ReservedBullet = weaponAllConfig.PropertyCfg.Bulletmax; if (orient.Magazine > 0) { orient.Bullet += SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(orient.Magazine) .Bullet; } ReplaceWeaponToSlot(slot, 0, orient); } else if (slot == EWeaponSlotType.ThrowingWeapon) { GrenadeHandler.AddCache(weapon.WeaponTplId); } removedSlotList[(int)slot] = 1; } for (int i = 1; i < removedSlotList.Length; i++) { if (removedSlotList[i] == 0) { DestroyWeapon((EWeaponSlotType)i, 0); } } EWeaponSlotType newSlot = PollGetLastSlotType(); TryHoldGrenade(true, false); TryArmWeaponImmediately(newSlot); return(true); }