private void HandleDeath(GameObject source) { LootCrate.SpawnResourcesOnly(transform); // give influence to village Village toInfluenceVill = Village.GetClosestVillageTo(transform.position); GuildMemberController gmContr = source.GetComponent <GuildMemberController>(); PlayerController pContr; if (gmContr) { gmContr.NPCsGuild.AddInfluenceFor(toInfluenceVill.gameObject, _influenceGivenOnDeath); } else if (pContr = source.GetComponent <PlayerController>()) { pContr.MyGuild.AddInfluenceFor(toInfluenceVill.gameObject, _influenceGivenOnDeath); } Destroy(gameObject); }