示例#1
0
        protected virtual bool MainTakeDamage(DamageData hData)
        {
            if (!m_hActorControler.TryGetActorData(out ActorData hActorData) ||
                !m_hBaseActorStatus.TryGetStatusData(out ActorStatus hStatusData))
            {
                return(false);
            }

            // Ignore damage during IFrame.
            if (FlagUtility.HasFlagUnsafe(hActorData.m_eStateFlag, ActorStateFlag.IFrame) &&
                !FlagUtility.HasFlagUnsafe(hData.m_ePenetrateType, DamagePenetrateFlag.IFrame))
            {
                return(false);
            }

            int nDamage = hData.m_nDamage;

            if (nDamage <= 0 || hStatusData == null)
            {
                //StartDamageBehaviour(hData.m_arrBehaviour);
                return(false);
            }



            m_hActorControler.InterruptAllBehaviour();

            var nCurrentHp = hStatusData.m_nCurrentHp;

            nCurrentHp -= nDamage;
            if (nCurrentHp < 0)
            {
                nCurrentHp = 0;
            }

            hStatusData.m_nCurrentHp = nCurrentHp;

            if (nCurrentHp == 0)
            {
                Dead(hData);
            }
            else
            {
                //RunAllTakeDamageEvent(hData);
                m_hDamageableEvent.Run(DamageableEvent.TakeDamage, hData);
                //StartDamageBehaviour(hData.m_arrBehaviour);
            }

            return(true);
        }