public void PickupItem(DroppedItem other)
    {
        CheckCurrentBaseWeapon();
        Debug.Log("Picked up " + other.name);
        if (parts[other.itemID].isBaseWeapon && hasBaseWeapon)
        {
            foreach (Item i in parts)
            {
                if (i.isEnabled)
                {
                    i.DropWeapon();
                }
            }
        }


        if (parts[other.itemID].isEnabled) // if the player already has the item
        {
            other.DestroyItem();
        }
        else
        {
            parts[other.itemID].isEnabled = true;
            parts[other.itemID].GetComponent <SpriteRenderer>().enabled = true;
            other.DestroyItem();
        }


        RenderItems();
    }
Ejemplo n.º 2
0
 public void CancelPlacement(bool notify = true)
 {
     enabled = false;
     skullItem.DestroyItem();
     skullItem.Kill();
     if (notify)
     {
         player.ChatMessage(msg("Help.Placement.3", player.userID));
     }
     Destroy(this);
 }
Ejemplo n.º 3
0
    public void OnDroppedOn(DroppedItem di)
    {
        if (item == null || di.item == null || Interface.CallHook("CanCombineDroppedItem", this, di) != null || item.info.stackable <= 1 || di.item.info != item.info || (di.item.IsBlueprint() && di.item.blueprintTarget != item.blueprintTarget) || (di.item.hasCondition && di.item.condition != di.item.maxCondition) || (item.hasCondition && item.condition != item.maxCondition))
        {
            return;
        }
        if (di.item.info != null && di.item.info.amountType == ItemDefinition.AmountType.Genetics)
        {
            int num  = ((di.item.instanceData != null) ? di.item.instanceData.dataInt : (-1));
            int num2 = ((item.instanceData != null) ? item.instanceData.dataInt : (-1));
            if (num != num2)
            {
                return;
            }
        }
        int num3 = di.item.amount + item.amount;

        if (num3 <= item.info.stackable && num3 != 0)
        {
            di.DestroyItem();
            di.Kill();
            item.amount = num3;
            item.MarkDirty();
            if (GetDespawnDuration() < float.PositiveInfinity)
            {
                Invoke(IdleDestroy, GetDespawnDuration());
            }
            Effect.server.Run("assets/bundled/prefabs/fx/notice/stack.world.fx.prefab", this, 0u, Vector3.zero, Vector3.zero);
        }
    }
Ejemplo n.º 4
0
    public void OnDroppedOn(DroppedItem di)
    {
        if (this.item == null)
        {
            return;
        }
        if (di.item == null)
        {
            return;
        }
        if (Interface.CallHook("CanCombineDroppedItem", this, di) != null)
        {
            return;
        }
        if (this.item.info.stackable <= 1)
        {
            return;
        }
        if (di.item.info != this.item.info)
        {
            return;
        }
        if (di.item.IsBlueprint() && di.item.blueprintTarget != this.item.blueprintTarget)
        {
            return;
        }
        int num = di.item.amount + this.item.amount;

        if (num > this.item.info.stackable)
        {
            return;
        }
        if (num == 0)
        {
            return;
        }
        di.DestroyItem();
        di.Kill(BaseNetworkable.DestroyMode.None);
        this.item.amount = num;
        this.item.MarkDirty();
        if (this.GetDespawnDuration() < Single.PositiveInfinity)
        {
            base.Invoke(new Action(this.IdleDestroy), this.GetDespawnDuration());
        }
        Effect.server.Run("assets/bundled/prefabs/fx/notice/stack.world.fx.prefab", this, 0, Vector3.zero, Vector3.zero, null, false);
    }
Ejemplo n.º 5
0
    public void OnDroppedOn(DroppedItem di)
    {
        if (this.item == null || di.item == null || (Interface.CallHook("CanCombineDroppedItem", (object)this, (object)di) != null || this.item.info.stackable <= 1) || (Object.op_Inequality((Object)di.item.info, (Object)this.item.info) || di.item.IsBlueprint() && di.item.blueprintTarget != this.item.blueprintTarget))
        {
            return;
        }
        int num = di.item.amount + this.item.amount;

        if (num > this.item.info.stackable || num == 0)
        {
            return;
        }
        di.DestroyItem();
        di.Kill(BaseNetworkable.DestroyMode.None);
        this.item.amount = num;
        this.item.MarkDirty();
        if ((double)this.GetDespawnDuration() < double.PositiveInfinity)
        {
            this.Invoke(new Action(this.IdleDestroy), this.GetDespawnDuration());
        }
        Effect.server.Run("assets/bundled/prefabs/fx/notice/stack.world.fx.prefab", (BaseEntity)this, 0U, Vector3.get_zero(), Vector3.get_zero(), (Connection)null, false);
    }
Ejemplo n.º 6
0
        private void Unload()
        {
            if (!ServerMgr.Instance.Restarting)
            {
                SaveData();
            }

            ItemPlacement[] placementComps = UnityEngine.Object.FindObjectsOfType <ItemPlacement>();
            if (placementComps != null)
            {
                foreach (ItemPlacement placement in placementComps)
                {
                    placement.CancelPlacement();
                }
            }

            for (int i = signRegisteredSkulls.Count - 1; i >= 0; i--)
            {
                DroppedItem skullItem = signRegisteredSkulls.ElementAt(i).Value;
                skullItem?.DestroyItem();
                if (skullItem != null && !skullItem.IsDestroyed)
                {
                    skullItem.Kill();
                }
            }

            for (int i = 0; i < spearRegisteredSkulls.Count; i++)
            {
                KeyValuePair <DroppedItem, List <DroppedItem> > kvp = spearRegisteredSkulls.ElementAt(i);

                DroppedItem        spear  = kvp.Key;
                List <DroppedItem> skulls = kvp.Value;

                if (spear == null)
                {
                    continue;
                }

                for (int y = 0; y < skulls.Count; y++)
                {
                    DroppedItem skullItem = skulls[y];
                    if (skullItem != null)
                    {
                        skullItem.DestroyItem();
                        if (skullItem != null && !skullItem.IsDestroyed)
                        {
                            skullItem.Kill();
                        }
                    }
                }

                Pool.FreeList(ref skulls);

                spear.DestroyItem();

                if (!spear.IsDestroyed)
                {
                    spear.Kill();
                }
            }

            configData = null;
            Instance   = null;
        }