Beispiel #1
0
 public bool TryEquip(Item item)
 {
     if (Wearables.IsItemWearableFor(this, item) && Item != null)
     {
         Inventory.Items.Single(itemInInventory => itemInInventory == item).IsEquiped = true;
         Item = item;
         return(true);
     }
     else
     {
         //TODO: Notify error
         return(false);
     }
 }
Beispiel #2
0
        public bool IsWearing(WearableType typeOfWearable, BodyPartType onBodyPart, BodyOrientation orientation, string articlePrefabName)
        {
            bool             upperBody = true;
            int              index     = Wearables.GetWearableIndex(onBodyPart, orientation, ref upperBody);
            WIStackContainer container = null;

            if (upperBody)
            {
                container = State.UpperBodyContainer;
            }
            else
            {
                container = State.LowerBodyContainer;
            }
            WIStack stack = container.StackList[index];
            IWIBase wearableItem;

            if (stack.HasTopItem)
            {
                wearableItem = stack.TopItem;
                if (Wearable.CanWear(typeOfWearable, onBodyPart, orientation, wearableItem))
                {
                    //has top item and we can wear that item, so yes we are wearing it
                    if (!string.IsNullOrEmpty(articlePrefabName))
                    {
                        if (string.Equals(wearableItem.PrefabName, articlePrefabName))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        // no need to check for article
                        return(true);
                    }
                }
            }
            return(false);
        }