private void OnCollisionEnter(Collision collision) { if (IsMine) { var entity = collision.gameObject.GetComponent <VitalEntity>(); if (entity) { entity.DamageReceive(Damage, collision.contacts[0].point, Rigidbody.velocity); var damage = new EntityDamage(); damage.amount = Damage; damage.id = entity.Id; outgoings.Enqueue(damage); } var remove = new EntityRemove(); remove.id = Id; outgoings.Enqueue(remove); commander.Destroy(this); //Destroy(gameObject); } }
public void Die() { if (Dead) { return; } State = StateFlags.Dead; Animator.SetBool("Die", true); if (IsMine) { if (OnDie != null) { OnDie(); } var remove = new EntityRemove(); remove.id = Id; outgoings.Enqueue(remove); status.Destroy(this); } }