void PickupLog(Player player, Guid logID) { lock (this) { if (!this.CanHarvest) { player.SendTemporaryErrorLoc("Log is not ready for harvest. Remove all branches first."); } TrunkPiece trunk; trunk = this.trunkPieces.FirstOrDefault(p => p.ID == logID); if (trunk != null && trunk.Collected == false) { // check log size, if its too big, it can't be picked up if (!this.CanPickup(trunk)) { player.SendTemporaryErrorLoc("Log is too large to pick up, slice into smaller pieces first."); return; } var resourceType = this.Species.ResourceItem; var resource = Item.Get(resourceType); int baseCount = this.GetBasePickupSize(trunk); var yield = resource.Yield; int bonusItems = yield != null?yield.GetCurrentValueInt(player.User) : 0; int numItems = baseCount + bonusItems; var destroyLog = true; if (numItems > 0) { var carried = player.User.Inventory.Carried; if (!carried.IsEmpty) { // If we're carrying the same type, we may be able to carry this too. if (carried.Stacks.First().Item.Type == resourceType.Type) { var currentCarried = carried.Stacks.First().Quantity; var maxCarry = resource.MaxStackSize; if (currentCarried + numItems > maxCarry) { var s = FormattableStringFactory.Create("You can't carry {0:n0} more {1:items} ({2} max).", numItems, resource.UILink(numItems != 1 ? ItemLinkType.ShowPlural : 0), maxCarry); player.SendTemporaryError(s); return; } } else { var s = FormattableStringFactory.Create("You are already carrying {0:items} and cannot pick up {1:items}.", carried.Stacks.First().Item.UILink(ItemLinkType.ShowPlural), resource.UILink(ItemLinkType.ShowPlural)); player.SendTemporaryError(s); return; } } if (!player.User.Inventory.TryAddItems(this.Species.ResourceItem.Type, numItems, player.User)) { destroyLog = false; } } if (destroyLog) { trunk.Collected = true; this.RPC("DestroyLog", logID); ActionManager.ActionPerformed(new HarvestGameAction() { HarvestedSpecies = this.Species, HarvestedStacks = (new ItemStack(Item.Get(this.Species.ResourceItem.Type), numItems)).SingleItemAsEnumerable(), TargetObj = this, TargetPos = this.Position.Round, User = player.User, OrganismDestroyed = !this.Ripe }); } this.Save(); this.CheckDestroy(); } } }