public void OnAfterDeserialize() { // Clear our runtime lists _weapons.Clear(); _ammo.Clear(); _foods.Clear(); // Clone inspector lists into runtime lists foreach (InventoryWeaponMountInfo info in _weaponMounts) { InventoryWeaponMountInfo clone = new InventoryWeaponMountInfo { Weapon = info.Weapon }; _weapons.Add(clone); } foreach (InventoryAmmoMountInfo info in _ammoMounts) { InventoryAmmoMountInfo clone = new InventoryAmmoMountInfo { Ammo = info.Ammo }; _ammo.Add(clone); } foreach (InventoryFoodMountInfo info in _foodMounts) { InventoryFoodMountInfo clone = new InventoryFoodMountInfo { Item = info.Item }; _foods.Add(clone); } }
public override CollectableItem DropFoodItem(int mountIndex) { if (mountIndex < 0 || mountIndex >= _foods.Count) { return(null); } InventoryFoodMountInfo itemMount = _foods[mountIndex]; if (itemMount == null || itemMount.Item == null) { return(null); } Vector3 position = _playerPosition != null ? _playerPosition.value : Vector3.zero; position += _playerDirection != null ? _playerDirection.value : Vector3.zero; var droppedItem = itemMount.Item.Drop(position); OnItemDropped.Invoke(itemMount.Item); _foods[mountIndex].Item = null; return(droppedItem); }