public void SpawnPlayerEvent(Player player, string playerEventTypeId, Vector3 spawnPos) { PlayerEvent playerEventRef = entityDatabase.GetPlayerEventReference(playerEventTypeId); if (player.resources >= playerEventRef.resourceCost) { PlayerEvent newPlayerEvent = Instantiate(playerEventRef.gameObject, spawnPos, Quaternion.identity).GetComponent <PlayerEvent>(); newPlayerEvent.SetPlayer(player); RegisterPlayerEvent(newPlayerEvent); serverGameManager.DecreaseResources(player, playerEventRef.resourceCost); } }