예제 #1
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);
    }