public static bool TestContainerRules(Container cn, int SlotIndex)
{
if (SlotIndex<11)
{
return true;
}
if (GameWorldController.instance.playerUW.playerInventory.ObjectInHand=="")
{
return true;
}
//Test the various rules for this slot
ObjectInteraction objInt = GameWorldController.instance.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;
bool CapacityTest=false;
switch (cn.ObjectsAccepted)
{//objects accepted; 0: runes, 1: arrows, 2: scrolls, 3: edibles, 0xFF: any
case 0://runes
TypeTest=(objInt.GetItemType()==ObjectInteraction.RUNE);break;
case 1://Arrows
TypeTest=(objInt.GetItemType()==ObjectInteraction.AMMO);break;
case 2://Scrolls
TypeTest=(
(objInt.GetItemType()==ObjectInteraction.SCROLL)
||
(objInt.GetItemType()==ObjectInteraction.MAGICSCROLL)
||
(objInt.GetItemType()==ObjectInteraction.MAP)
||
(objInt.GetItemType()==ObjectInteraction.BOOK)
);
break;
case 3: //Edibles
TypeTest=((objInt.GetItemType()==ObjectInteraction.FOOD) || (objInt.GetItemType()==ObjectInteraction.POTIONS));break;
default:
TypeTest=true;break;
}
if (TypeTest==true)
{
if (objInt.GetWeight() >= cn.GetFreeCapacity())
{
WeightTest=false;
UWHUD.instance.MessageScroll.Add ("The " + StringController.instance.GetSimpleObjectNameUW(cn.objInt()) + " is too full.");
}
else
{
WeightTest=true;
}
}
else
{//000~001~248~That item does not fit.
UWHUD.instance.MessageScroll.Add (StringController.instance.GetString(1,248));
}
if (WeightTest==true)
{
if (cn.CountItems()<=cn.MaxCapacity())
{
CapacityTest=true;
}
else
{//000~001~248~That item does not fit.
UWHUD.instance.MessageScroll.Add (StringController.instance.GetString(1,248));
}
}
return (TypeTest && WeightTest && CapacityTest);
}