//a method that destroys a faction entity locally public virtual void DestroyFactionEntityLocal(bool upgrade) { gameMgr.SelectionMgr.Selected.Remove(factionEntity); //deselect the faction entity if it was selected //faction entity death: isDead = true; CurrHealth = 0; //remove the minimap icon: factionEntity.GetSelection().DisableMinimapIcon(); //If this is no upgrade if (upgrade == false) { factionEntity.Disable(true); CustomEvents.OnFactionEntityDead(factionEntity); //call the custom events if (destructionEffect != null) //do not show desctruction effect if it's not even assigned { //get the destruction effect from the pool EffectObj newDestructionEffect = gameMgr.EffectPool.SpawnEffectObj(destructionEffect, transform.position, Quaternion.identity); //destruction sound effect if (destructionAudio != null) { //Check if the destruction effect object has an audio source: if (newDestructionEffect.GetComponent <AudioSource>() != null) { AudioManager.Play(newDestructionEffect.GetComponent <AudioSource>(), destructionAudio, false); //play the destruction audio } else { Debug.LogError("A destruction audio clip has been assigned but the destruction effect object doesn't have an audio source!"); } } } } //Destroy the faction entity's object: if (destroyObject == true) //only if object destruction is allowed { Destroy(gameObject, !upgrade ? destroyObjectTime : 0.0f); IsDestroyed = true; } }