internal void RemoveAmmo() { MyTuple <Weapon, MyTuple <MyInventory, int>[]> weaponAmmoToPull; while (AmmoToRemoveQueue.TryDequeue(out weaponAmmoToPull)) { var weapon = weaponAmmoToPull.Item1; if (!weapon.Comp.InventoryInited) { continue; } var inventoriesToAddTo = weaponAmmoToPull.Item2; var def = weapon.ActiveAmmoDef.AmmoDefinitionId; var magItem = weapon.ActiveAmmoDef.AmmoDef.Const.AmmoItem; weapon.Comp.IgnoreInvChange = true; weapon.ActiveAmmoDef = weapon.System.WeaponAmmoTypes[weapon.Set.AmmoTypeId]; for (int i = 0; i < inventoriesToAddTo.Length; i++) { var amt = inventoriesToAddTo[i].Item2; weapon.Comp.BlockInventory.RemoveItemsOfType(amt, def); inventoriesToAddTo[i].Item1.Add(magItem, amt); } WepUi.SetDps(weapon.Comp, weapon.Comp.Set.Value.DpsModifier, false, true); weapon.State.Sync.Reloading = false; ComputeStorage(weapon); weapon.Comp.IgnoreInvChange = false; } }
public void Sync(WeaponComponent comp, CompSettingsValues syncFrom) { Guidance = syncFrom.Guidance; Modes = syncFrom.Modes; Range = syncFrom.Range; foreach (var w in comp.Platform.Weapons) { w.UpdateWeaponRange(); } Overrides.Sync(syncFrom.Overrides); if (Overload != syncFrom.Overload || RofModifier != syncFrom.RofModifier || DpsModifier != syncFrom.DpsModifier) { Overload = syncFrom.Overload; RofModifier = syncFrom.RofModifier; WepUi.SetDps(comp, syncFrom.DpsModifier, true); } }