예제 #1
0
        public static bool ConsumeRequirement(WIStack itemStack, IWIBase item, GenericWorldItem template, bool requirementsMet)
        {
            if (!requirementsMet)
            {
                return(false);
            }

            bool result = false;

            if (item.Is <LiquidContainer> ())
            {
                //see if the thing inside the liquid container has what we need
                bool foundState                  = false;
                LiquidContainerState state       = null;
                System.Object        stateObject = null;
                if (item.GetStateOf <LiquidContainer> (out stateObject))
                {
                    state      = (LiquidContainerState)stateObject;
                    foundState = state != null;
                }

                if (foundState)
                {
                    //hooray it is a liquid
                    if (!state.IsEmpty)
                    {
                        //and it's not empty so steal one
                        state.Contents.InstanceWeight--;
                        result = true;
                        item.SetStateOf <LiquidContainer> (state);
                    }
                }
            }
            else
            {
                Stacks.Pop.AndToss(itemStack);
                result = true;
            }
            return(result);
        }