コード例 #1
0
    /// <summary>
    /// Sits us down at a slot. Doesn't matter how far the unit is from the slot.
    /// </summary>
    public bool SitDown(CItem.CUsageSlot Slot)
    {
        mCollide            = false;
        mSittingEntityID    = Slot.mItem.mID;
        mSittingUsageSlotID = Slot.mSlotID;
        mPosition           = Slot.mPosition;
        mRotation           = Slot.mRotation;

        return(true);
    }
コード例 #2
0
    /// <summary>
    /// Drive locomotion to sit at a usage slot.
    /// </summary>
    public bool SitAt(CItem.CUsageSlot TargetSlot, int EntryPointID)
    {
        if (mSittingEntityID == TargetSlot.mItem.mID && mSittingUsageSlotID == TargetSlot.mSlotID)
        {
            return(true);
        }

        if (mSittingEntityID != 0 && mSittingEntityID != TargetSlot.mItem.mID)
        {
            // We are sitting somewhere, just not the target.
            if (!StandUp())
            {
                // Couldn't stand up! Maybe blocked.
            }
        }

        // Do we assume there is an acceptable path to this item when sit at is called?

        if (WalkTo(TargetSlot.mEntryPoints[EntryPointID].mPosition) == 1)
        {
            if (SitDown(TargetSlot))
            {
                return(true);
            }
        }



        /*
         *      if (!mSitting)
         *      {
         *      }
         *      else
         *      {
         *              if (mSittingTimer < 20)
         *              {
         ++mSittingTimer;
         *
         *                      if (mSittingTimer == 20)
         *                      {
         *                              mPosition = mUsageSlot.mPosition;
         *                              mRotation = mUsageSlot.mRotation;
         *                      }
         *              }
         *              else
         *              {
         *                      return true;
         *              }
         *      }
         * }
         */
        return(false);
    }
コード例 #3
0
    /// <summary>
    /// Stand up from current sitting item. Move to closest best position.
    /// If the unit can't stand up then return false.
    /// </summary>
    public bool StandUp()
    {
        if (mSittingEntityID == 0)
        {
            return(true);
        }

        CItem sittingItem = mWorld.GetEntity <CItem>(mSittingEntityID);

        if (sittingItem == null)
        {
            Debug.LogError("We're sitting on nothing?");
        }
        else
        {
            CItem.CUsageSlot slot = sittingItem.GetUsageSlot(mSittingUsageSlotID);

            if (slot == null)
            {
                Debug.LogError("We're sitting on something with no slot?");
            }
            else
            {
                // TODO: Exit at an entry point for this slot, not at slot position
                // Check if we can stand up at all. Iterate entry points, and find free one
                mPosition           = slot.mPosition;
                mRotation           = slot.mRotation;
                mCollide            = true;
                mSittingEntityID    = 0;
                mSittingUsageSlotID = -1;
                return(true);
            }
        }

        return(false);
    }