private void GiveResources(BaseEntity entity, float gatherDamage, float destroyFraction, AttackEntity attackWeapon) { if (!entity.IsValid()) { return; } if (gatherDamage <= 0f) { return; } ItemAmount item = null; int count = this.containedItems.Count; int num = UnityEngine.Random.Range(0, this.containedItems.Count); while (count > 0) { if (num >= this.containedItems.Count) { num = 0; } if (this.containedItems[num].amount <= 0f) { num++; count--; } else { item = this.containedItems[num]; break; } } if (item == null) { return; } this.GiveResourceFromItem(entity, item, gatherDamage, destroyFraction, attackWeapon); this.UpdateVars(); BasePlayer player = entity.ToPlayer(); if (player) { Debug.Assert(attackWeapon.GetItem() != null, string.Concat("Attack Weapon ", attackWeapon, " has no Item")); Debug.Assert(attackWeapon.ownerItemUID != 0, string.Concat("Attack Weapon ", attackWeapon, " ownerItemUID is 0")); Debug.Assert(attackWeapon.GetParentEntity() != null, string.Concat("Attack Weapon ", attackWeapon, " GetParentEntity is null")); Debug.Assert(attackWeapon.GetParentEntity().IsValid(), string.Concat("Attack Weapon ", attackWeapon, " GetParentEntity is not valid")); Debug.Assert(attackWeapon.GetParentEntity().ToPlayer() != null, string.Concat("Attack Weapon ", attackWeapon, " GetParentEntity is not a player")); Debug.Assert(!attackWeapon.GetParentEntity().ToPlayer().IsDead(), string.Concat("Attack Weapon ", attackWeapon, " GetParentEntity is not valid")); BasePlayer ownerPlayer = attackWeapon.GetOwnerPlayer(); Debug.Assert(ownerPlayer != null, string.Concat("Attack Weapon ", attackWeapon, " ownerPlayer is null")); Debug.Assert(ownerPlayer == player, string.Concat("Attack Weapon ", attackWeapon, " ownerPlayer is not player")); if (ownerPlayer != null) { Debug.Assert(ownerPlayer.inventory != null, string.Concat("Attack Weapon ", attackWeapon, " ownerPlayer inventory is null")); Debug.Assert(ownerPlayer.inventory.FindItemUID(attackWeapon.ownerItemUID) != null, string.Concat("Attack Weapon ", attackWeapon, " FindItemUID is null")); } } }
private void GiveResources( BaseEntity entity, float gatherDamage, float destroyFraction, AttackEntity attackWeapon) { if (!entity.IsValid() || (double)gatherDamage <= 0.0) { return; } ItemAmount itemAmt = (ItemAmount)null; int count = this.containedItems.Count; int index = Random.Range(0, this.containedItems.Count); for (; count > 0; --count) { if (index >= this.containedItems.Count) { index = 0; } if ((double)this.containedItems[index].amount > 0.0) { itemAmt = this.containedItems[index]; break; } ++index; } if (itemAmt == null) { return; } this.GiveResourceFromItem(entity, itemAmt, gatherDamage, destroyFraction, attackWeapon); this.UpdateVars(); BasePlayer player = entity.ToPlayer(); if (!Object.op_Implicit((Object)player)) { return; } Debug.Assert(attackWeapon.GetItem() != null, "Attack Weapon " + (object)attackWeapon + " has no Item"); Debug.Assert(attackWeapon.ownerItemUID > 0U, "Attack Weapon " + (object)attackWeapon + " ownerItemUID is 0"); Debug.Assert(Object.op_Inequality((Object)attackWeapon.GetParentEntity(), (Object)null), "Attack Weapon " + (object)attackWeapon + " GetParentEntity is null"); Debug.Assert(attackWeapon.GetParentEntity().IsValid(), "Attack Weapon " + (object)attackWeapon + " GetParentEntity is not valid"); Debug.Assert(Object.op_Inequality((Object)attackWeapon.GetParentEntity().ToPlayer(), (Object)null), "Attack Weapon " + (object)attackWeapon + " GetParentEntity is not a player"); Debug.Assert(!attackWeapon.GetParentEntity().ToPlayer().IsDead(), "Attack Weapon " + (object)attackWeapon + " GetParentEntity is not valid"); BasePlayer ownerPlayer = attackWeapon.GetOwnerPlayer(); Debug.Assert(Object.op_Inequality((Object)ownerPlayer, (Object)null), "Attack Weapon " + (object)attackWeapon + " ownerPlayer is null"); Debug.Assert(Object.op_Equality((Object)ownerPlayer, (Object)player), "Attack Weapon " + (object)attackWeapon + " ownerPlayer is not player"); if (!Object.op_Inequality((Object)ownerPlayer, (Object)null)) { return; } Debug.Assert(Object.op_Inequality((Object)ownerPlayer.inventory, (Object)null), "Attack Weapon " + (object)attackWeapon + " ownerPlayer inventory is null"); Debug.Assert(ownerPlayer.inventory.FindItemUID(attackWeapon.ownerItemUID) != null, "Attack Weapon " + (object)attackWeapon + " FindItemUID is null"); }