Container.GetFreeCapacity C# (CSharp) Method

GetFreeCapacity() public method

public GetFreeCapacity ( ) : float
return float
    public float GetFreeCapacity()
    {
        if (this.gameObject.name==GameWorldController.instance.playerUW.name)
        {
            return 999;
        }
        return GetCapacity() - GetWeight() - GetBaseWeight();
    }

Usage Example

    public static bool TestContainerRules(Container cn, int SlotIndex)
    {
        if (SlotIndex < 11)
        {
            return(true);
        }
        //Test the various rules for this slot
        ObjectInteraction objInt = playerUW.playerInventory.GetGameObjectInHand().GetComponent <ObjectInteraction>();
        //If in a non player container check that the object in hand can be added to it.
        bool TypeTest = false;
        //If in a non player container check that the container has the weight capacity to accept it.
        bool WeightTest = false;

//		Container curContainer = this;
        switch (cn.ObjectsAccepted)
        {        //objects accepted; 0: runes, 1: arrows, 2: scrolls, 3: edibles, 0xFF: any
        case 0:  //runes
            TypeTest = (objInt.ItemType == ObjectInteraction.RUNE); break;

        case 1:        //Arrows
            TypeTest = (objInt.ItemType == ObjectInteraction.AMMO); break;

        case 2:        //Scrolls
            TypeTest = (
                (objInt.ItemType == ObjectInteraction.SCROLL)
                ||
                (objInt.ItemType == ObjectInteraction.MAGICSCROLL)
                ||
                (objInt.ItemType == ObjectInteraction.MAP)
                );
            break;

        case 3:         //Edibles
            TypeTest = (objInt.ItemType == ObjectInteraction.FOOD); break;

        default:
            TypeTest = true; break;
        }



        if (TypeTest == true)
        {
            if (objInt.GetWeight() >= cn.GetFreeCapacity())
            {
                WeightTest = false;
                playerUW.playerHud.MessageScroll.Add("The " + playerUW.StringControl.GetSimpleObjectNameUW(cn.objInt) + " is too full.");
            }
            else
            {
                WeightTest = true;
            }
        }
        else
        {        //000~001~248~That item does not fit.
            playerUW.playerHud.MessageScroll.Add(playerUW.StringControl.GetString(1, 248));
        }
        return(TypeTest && WeightTest);
    }
All Usage Examples Of Container::GetFreeCapacity