コード例 #1
0
        public void HandleCollision(BaseController otherController, int hitLocation, int hitmaterial, Vector3?positionOverride)
        {
            //Debug.Log($"{name} hit {otherController?.name}");

            if (gameObject == null)
            {
                return; //don't double it up
            }
            if (otherController != null)
            {
                if (otherController == HitInfo.Originator) //no friendly fire for now
                {
                    return;
                }

                if (positionOverride == null)
                {
                    HitInfo.HitCoords = transform.position;
                }
                else
                {
                    HitInfo.HitCoords = positionOverride;
                }

                if (hitLocation > 0)
                {
                    HitInfo.HitLocation = hitLocation;
                }

                if (otherController is ITakeDamage itd)
                {
                    itd.TakeDamage(HitInfo);

                    if (FiredByPlayer)
                    {
                        QdmsMessageBus.Instance.PushBroadcast(new QdmsFlagMessage("PlayerHitTarget"));
                    }
                }
            }

            if (HitInfo.HitCoords == null)
            {
                HitInfo.HitCoords = transform.position;
            }

            if (hitmaterial > 0)
            {
                HitInfo.HitMaterial = hitmaterial;
            }

            HitPuffScript.SpawnHitPuff(HitInfo);

            Destroy(this.gameObject);
        }
コード例 #2
0
        private void HandleHit(BaseController otherController, IHitboxComponent hitbox, int hitLocation, int hitmaterial, Vector3?positionOverride, float damageMultiplier, bool allDamageIsPierce)
        {
            //Debug.Log($"HandleHit called ({otherController})");

            if (gameObject == null)
            {
                return; //don't double it up
            }
            if (HitInfo.HitFlags.HasFlag(BuiltinHitFlags.IgnoreHitLocation))
            {
                if (!(hitbox != null && hitbox.AlwaysApplyMultiplier))
                {
                    damageMultiplier = 1;
                }
            }

            if (otherController != null)
            {
                if (otherController == HitInfo.Originator) //no friendly fire for now
                {
                    return;
                }

                if (positionOverride == null)
                {
                    HitInfo.HitCoords = transform.position;
                }
                else
                {
                    HitInfo.HitCoords = positionOverride;
                }

                HitInfo.Damage       *= damageMultiplier;
                HitInfo.DamagePierce *= damageMultiplier;

                if (allDamageIsPierce)
                {
                    HitInfo.DamagePierce += HitInfo.Damage;
                    HitInfo.Damage        = 0;
                }

                if (hitLocation > 0)
                {
                    HitInfo.HitLocation = hitLocation;
                }

                if (otherController is ITakeDamage itd)
                {
                    itd.TakeDamage(HitInfo);

                    if (FiredByPlayer)
                    {
                        QdmsMessageBus.Instance.PushBroadcast(new QdmsFlagMessage("PlayerHitTarget"));
                    }
                }
            }

            if (HitInfo.HitCoords == null)
            {
                if (positionOverride == null)
                {
                    HitInfo.HitCoords = transform.position;
                }
                else
                {
                    HitInfo.HitCoords = positionOverride;
                }
                //Debug.Log($"HitCoords set to {HitInfo.HitCoords}");
            }

            if (hitmaterial > 0)
            {
                HitInfo.HitMaterial = hitmaterial;
            }

            if (!string.IsNullOrEmpty(HitPuffOverride))
            {
                HitPuffScript.SpawnHitPuff(HitPuffOverride, HitInfo.HitCoords.Value, HitInfo.HitMaterial);
            }
            else
            {
                HitPuffScript.SpawnHitPuff(HitInfo);
            }

            if (HitSpecial != null)
            {
                HitSpecial.Invoke(new ActionInvokerData()
                {
                    Activator = HitInfo.Originator
                });
            }

            Destroy(this.gameObject);
        }