Exemplo n.º 1
0
        private object OnItemPickup(Item item, BasePlayer player)
        {
            if (item != null && player != null)
            {
                ItemPlacement placement = player.GetComponent <ItemPlacement>();
                if (placement != null)
                {
                    return(false);
                }
                else
                {
                    DroppedItem droppedItem = item.GetWorldEntity()?.GetComponent <DroppedItem>();

                    if (droppedItem == null)
                    {
                        return(null);
                    }

                    List <DroppedItem> skulls;

                    if (spearRegisteredSkulls.TryGetValue(droppedItem, out skulls))
                    {
                        if (skulls?.Count == 0)
                        {
                            if (!CanRemove(player, "Error.NoBuildingAuthSpear"))
                            {
                                return(false);
                            }

                            Pool.FreeList(ref skulls);

                            spearRegisteredSkulls.Remove(droppedItem);
                        }
                        else
                        {
                            SendReply(player, msg("Error.SkullsOnSpear", player.userID));
                            return(false);
                        }
                    }

                    if (droppedItem.item.info.itemid == SKULL_ITEM_ID)
                    {
                        Signage signage = droppedItem.GetComponentInParent <Signage>();

                        if (signage != null && signRegisteredSkulls.ContainsKey(signage))
                        {
                            if (!CanRemove(player, "Error.NoBuildingAuthSkull"))
                            {
                                return(false);
                            }

                            signRegisteredSkulls.Remove(signage);

                            if (signage.HasFlag(BaseEntity.Flags.Locked))
                            {
                                signage.SetFlag(BaseEntity.Flags.Locked, false);
                            }

                            UpdateSignImage(signage, "", true);
                        }
                        else
                        {
                            if (droppedItem.HasParent())
                            {
                                DroppedItem spear = droppedItem.GetParentEntity().GetComponent <DroppedItem>();
                                if (spear == null)
                                {
                                    return(null);
                                }

                                if (spearRegisteredSkulls.TryGetValue(spear, out skulls) && skulls.Contains(droppedItem))
                                {
                                    if (!CanRemove(player, "Error.NoBuildingAuthSkull"))
                                    {
                                        return(false);
                                    }

                                    spearRegisteredSkulls[spear].Remove(droppedItem);
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }