private void SpawnRegrow()
        {
            CraftData data = craftable.GetData();

            if (data != null && !string.IsNullOrEmpty(unique_id.unique_id) && !PlayerData.Get().HasWorldRegrowth(unique_id.unique_id))
            {
                int nb = Craftable.CountObjectInRadius(data, transform.position, range);
                if (nb < max)
                {
                    //Find position
                    Vector3 position = FindPosition();
                    if (IsPositionValid(position))
                    {
                        Quaternion rotation = transform.rotation;
                        float      scale    = 1f;
                        if (random_rotation)
                        {
                            rotation = Quaternion.Euler(rotation.eulerAngles.x, Random.Range(0f, 360f), 0f);
                        }
                        if (random_scale)
                        {
                            scale = Random.Range(0.75f, 1.25f);
                        }

                        CreateRegrowthData(unique_id.unique_id, data, SceneNav.GetCurrentScene(), position, rotation, scale, duration, probability);
                    }
                }
            }
        }
        //--- Static functions for easy access

        public static Craftable GetNearest(Vector3 pos, float range = 999f)
        {
            Craftable nearest  = null;
            float     min_dist = range;

            foreach (Craftable item in craftable_list)
            {
                float dist = (item.transform.position - pos).magnitude;
                if (dist < min_dist)
                {
                    min_dist = dist;
                    nearest  = item;
                }
            }
            return(nearest);
        }
        //Spawn the prefab from existin regrowth data, after its timer reaches the duration
        public static GameObject SpawnRegrowth(WorldRegrowthData data)
        {
            CraftData craftable = CraftData.Get(data.data_id);

            if (craftable != null && data.scene == SceneNav.GetCurrentScene())
            {
                if (Random.value < data.probability)
                {
                    GameObject nobj = Craftable.Create(craftable, data.pos);
                    nobj.transform.rotation   = data.rot;
                    nobj.transform.localScale = nobj.transform.localScale * data.scale;
                    return(nobj);
                }
            }
            return(null);
        }
        private Item item;             //Can be null

        private void Awake()
        {
            unique_id = GetComponent <UniqueID>();
            craftable = GetComponent <Craftable>();
            destruct  = GetComponent <Destructible>();
            item      = GetComponent <Item>();

            if (type == WorldRegrowthType.OnDeath)
            {
                if (destruct != null)
                {
                    destruct.onDeath += SpawnRegrow;
                }
                if (item != null)
                {
                    item.onDestroy += SpawnRegrow;
                }
            }
        }
 public static GameObject Create(CraftData data, Vector3 pos, PlayerCharacter owner = null)
 {
     return(Craftable.Create(data, pos, owner));
 }
 //Return all scenes objects with this data
 public static List <GameObject> GetAllObjectsOf(CraftData data)
 {
     return(Craftable.GetAllObjectsOf(data));
 }
 public static int CountSceneObjects(CraftData data, Vector3 pos, float range)
 {
     return(Craftable.CountSceneObjects(data, pos, range));
 }
 //Count objects of type in scene
 public static int CountSceneObjects(CraftData data)
 {
     return(Craftable.CountSceneObjects(data)); //All objects in scene
 }