コード例 #1
0
        public virtual bool AddToReceptacle(WorldItem potentialOccupant)
        {
            if (State.Locked)
            {
                return(false);
            }

            if (mCooldownStartTime + mCooldownInterval > WorldClock.RealTime)
            {
                return(false);
            }

            bool            result     = false;
            ReceptaclePivot emptyPivot = null;

            if (HasRoom(potentialOccupant, out emptyPivot) && IsObjectPermitted(potentialOccupant, emptyPivot.Settings))
            {
                //first we have to move the potential occupant into our group
                WIStack      pivotStack = worlditem.StackContainer.StackList [emptyPivot.State.Index];
                WIStackError error      = WIStackError.None;
                result = Stacks.Push.Item(pivotStack, potentialOccupant, ref error);
            }

            if (result)
            {
                potentialOccupant.OnRemoveFromStack        += Refresh;
                potentialOccupant.OnUnloaded               += Refresh;
                potentialOccupant.OnAddedToPlayerInventory += Refresh;
                OnItemPlacedInReceptacle.SafeInvoke();
                emptyPivot.Refresh();
            }

            return(result);
        }
コード例 #2
0
        protected IEnumerator AddToReceptaclePivotOverTime(WorldItem potentialOccupant, ReceptaclePivot pivotInFocus)
        {
            //remove it from any situation that could cause a c**k-up
            worlditem.Group.AddChildItem(potentialOccupant);
            potentialOccupant.SetMode(WIMode.World);
            //this will put it into the world and un-equip it etc
            //wait for that to happen
            yield return(null);

            WIStack      pivotStack = worlditem.StackContainer.StackList [pivotInFocus.State.Index];
            WIStackError error      = WIStackError.None;

            //do not auto convert to stack item
            if (!Stacks.Push.Item(pivotStack, potentialOccupant, StackPushMode.Manual, ref error))
            {
                Debug.Log("Couldn't push item into group because " + error.ToString());
                yield break;
            }
            //wait again for the worlditem to get situated
            yield return(null);

            potentialOccupant.OnRemoveFromStack += Refresh;
            potentialOccupant.OnModeChange      += Refresh;
            potentialOccupant.tr.parent          = pivotInFocus.tr;
            //this will move it into the recepticle position
            pivotInFocus.Refresh();
            yield return(null);

            OnItemPlacedInReceptacle.SafeInvoke();
            mAddingToReceptaclePivot = false;
        }