Exemple #1
0
    public void Impact()
    {
        OnPreDamage();

        OnDamageEvent();
        OnImpact.Invoke();
    }
    public void OnCollisionEnter(Collision collision)
    {
        ContactPoint contactPoint = collision.contacts[0];

        if (contactPoint.otherCollider.CompareTag("Player"))
        {
            LastImpactType      = ImpactType.Finger;
            LastOtherCollider   = contactPoint.otherCollider;
            LastImpactIntensity = collision.relativeVelocity.magnitude;
            // Finger impacts get set to 1 regardless of actual intensity
            FingerImpactIntensity += Mathf.Max(LastImpactIntensity, minFingerImpactIntensity);
            OnImpact?.Invoke(this, contactPoint.point);
        }
        else if (contactPoint.otherCollider.CompareTag("VolumeBlock"))
        {
            float impactVelocity = collision.relativeVelocity.magnitude;
            if (impactVelocity < minCollisionVelocity)
            {
                return;
            }

            impactVelocity        = Mathf.Max(impactVelocity, minChunkImpactIntensity);
            LastImpactType        = ImpactType.OtherBlock;
            LastOtherCollider     = contactPoint.otherCollider;
            LastImpactIntensity   = impactVelocity;
            ChunkImpactIntensity += impactVelocity;
            OnImpact?.Invoke(this, contactPoint.point);
        }
    }
Exemple #3
0
 public virtual void OnCollisionEnter(Collision col)
 {
     if (OnImpact != null)
     {
         OnImpact.Invoke(col);
     }
     GameObject.Destroy(gameObject);
 }
Exemple #4
0
    private void OnCollisionEnter(Collision collision)
    {
        // Let's not hit ourselves
        if (collision.collider.transform.root == transform.root)
        {
            return;
        }

        if (collision.relativeVelocity.sqrMagnitude > sqrVelocityThreshold)
        {
            OnImpact?.Invoke();

            AudioManager.PlaySoundNonSpatial(null);
        }
    }
Exemple #5
0
        public override void OnFallToGround(double motionY)
        {
            IPlayer player = World.PlayerByUid(PlayerUID);

            if (player?.WorldData?.CurrentGameMode != EnumGameMode.Spectator)
            {
                EntityPos     pos          = SidedPos;
                int           blockIdUnder = BlockUnderPlayer(pos);
                AssetLocation soundwalk    = World.Blocks[blockIdUnder].GetSounds(Api.World.BlockAccessor, new BlockPos((int)pos.X, (int)(pos.Y - 0.1f), (int)pos.Z))?.Walk;
                if (soundwalk != null && !Swimming)
                {
                    World.PlaySoundAt(soundwalk, this, player, true, 12, 1.5f);
                }

                OnImpact?.Invoke(motionY);
            }

            base.OnFallToGround(motionY);
        }
Exemple #6
0
    private void OnTriggerEnter(Collider other)
    {
        if (_hasDealtDamage)
        {
            return;
        }

        var collisionManager = ManagerLocator.TryGet <HitManager>();

        collisionManager?.ReportHit(other.gameObject, transform.position, damage);

        _hasDealtDamage = true;

        OnImpact?.Invoke();

        if (destroySelfOnImpact)
        {
            Destroy(gameObject);
        }
    }
Exemple #7
0
 public void OnCollisionEnter(Collision collision)
 {
     OnImpact?.Invoke();
 }
Exemple #8
0
 private void Impact()
 {
     OnImpact?.Invoke();
 }
Exemple #9
0
 public void Impact()
 {
     OnImpact?.Invoke();
 }
Exemple #10
0
 public void TriggerImpact(Collision collision)
 {
     OnImpact?.Invoke(collision);
 }
Exemple #11
0
 public virtual void OnHit()
 {
     OnImpact?.Invoke(this);
 }