Beispiel #1
0
    public void Drop(InventoryItemData item, string prefab)
    {
        if (Hands)
        {
            // Drop the current item.
            Player.Local.Holding.Item.RequestDataUpdate();
            if (Player.Local.Holding.Item.Data != null)
            {
                Player.Local.Holding.Item.Data.Update("Quick Slot", 0);
            }

            Player.Local.Holding.CmdDrop(true, false, Player.Local.gameObject, Player.Local.Holding.Item.Data.Serialize());
        }
        else
        {
            // Remove from slot and drop on ground.
            BodyGear g = Player.Local.GearMap[Slot];

            if (g.GetGearItem() == null)
            {
                Debug.LogError("Cannot drop, looks like the UI and world are desynced!");
                return;
            }

            g.GetGearItem().Item.RequestDataUpdate();
            ItemData data = g.GetGearItem().Item.Data;
            Player.Local.NetUtils.CmdDropGear(Slot, data.Serialize());
        }
    }
 public void Update()
 {
     if (HeadGear.GetGearItem() != null)
     {
         Renderer.maskInteraction = HeadGear.GetGearItem().HidesHair ? SpriteMaskInteraction.VisibleInsideMask : SpriteMaskInteraction.None;
     }
     else
     {
         Renderer.maskInteraction = SpriteMaskInteraction.None;
     }
 }
    public void CmdDropGear(string slot, string data)
    {
        BodyGear g = GetPlayer().GearMap[slot];

        if (g.GetGearItem() != null)
        {
            Item old = g.GetGearItem().Item;
            g.SetItem(GetPlayer().gameObject, null, null, false);

            Item instance = Item.NewInstance(old.Prefab, GetPlayer().transform.position, ItemData.TryDeserialize(data));

            NetworkServer.Spawn(instance.gameObject);
        }
    }
Beispiel #4
0
    public GearSaveData(BodyGear gearSlot)
    {
        Slot = gearSlot.Name;
        GearItem item = gearSlot.GetGearItem();

        if (item != null)
        {
            Prefab = item.Item.Prefab;
            item.Item.RequestDataUpdate();
            Data = item.Item.Data;
        }
        else
        {
            Prefab = null;
            Data   = null;
        }
    }