示例#1
0
    /// <summary>
    /// re-caches all of the standard UFPS local player components
    /// </summary>
    private static void RefreshPlayerComponents()
    {
        m_FPCamera        = null;
        m_FPController    = null;
        m_FPInput         = null;
        m_FPDamageHandler = null;
        m_FPWeaponHandler = null;
        m_Inventory       = null;
        m_Respawner       = null;
        m_FPBodyAnimator  = null;
        m_RagdollHandler  = null;
        m_FootFXHandler   = null;

        if (m_FPEventHandler == null)
        {
            return;
        }

        m_FPCamera        = m_FPEventHandler.GetComponentInChildren <vp_FPCamera>();
        m_FPController    = m_FPEventHandler.GetComponentInChildren <vp_FPController>();
        m_FPInput         = m_FPEventHandler.GetComponentInChildren <vp_FPInput>();
        m_FPDamageHandler = m_FPEventHandler.GetComponentInChildren <vp_FPPlayerDamageHandler>();
        m_FPWeaponHandler = m_FPEventHandler.GetComponentInChildren <vp_FPWeaponHandler>();
        m_Inventory       = m_FPEventHandler.GetComponentInChildren <vp_PlayerInventory>();
        m_Respawner       = m_FPEventHandler.GetComponentInChildren <vp_PlayerRespawner>();
        m_FPBodyAnimator  = m_FPEventHandler.GetComponentInChildren <vp_FPBodyAnimator>();
        m_RagdollHandler  = m_FPEventHandler.GetComponentInChildren <vp_RagdollHandler>();
        m_FootFXHandler   = m_FPEventHandler.GetComponentInChildren <vp_PlayerFootFXHandler>();
    }
        /// <summary>
        /// Place our building
        /// </summary>
        public override void PlaceBuilding()
        {
            if (item != null)
            {
                vp_PlayerInventory  pInventory = GetComponentInParent <vp_PlayerInventory>();
                vp_UnitBankInstance instance;

                if (pInventory != null)
                {
                    instance = pInventory.GetUnitBankInstanceOfWeapon(item.weaponInstance);

                    if (instance != null)
                    {
                        instance.TryRemoveUnits(1);

                        if (instance.Count == 0)
                        {
                            pInventory.TryRemoveItem(instance);
                        }
                    }
                }

                PhotonCloudBuilding building = currentBuilding as PhotonCloudBuilding;

                if (building != null)
                {
                    var evnt = building.PackData(entity, true);
                    evnt.SendToServer();
                }

                DestroyCurrentBuilding();
                ResetBuildingInstance();
            }
        }