public void SubmitRecipe(int recipe_id)
    {
        if (overallData.gameData.isCrafting)
        {
            Debug.LogError("ALREADY CRAFTING!");
            return;
        }
        Debug.Log("Recipe Received");
        recipeData rD = CLD.GetRecipeByID(recipe_id);
        int        catToRemove = 0, itemToRemove = 0;

        changeMoney(rD.cost * -1);
        for (int i = 0; i < rD.cats.Count; i++)
        {
            if (i == 0 || rD.cats[i - 1] == rD.cats[i])
            {
                catToRemove++;
            }
            else
            {
                CatControl(rD.cats[i - 1], -catToRemove, CatControlType.count);
                catToRemove = 1;
            }

            if (i == rD.cats.Count - 1)
            {
                CatControl(rD.cats[i], -catToRemove, CatControlType.count);
            }
        }
        Debug.Log("Cat Removed");
        for (int i = 0; i < rD.items.Count; i++)
        {
            if (i == 0 || rD.items[i - 1] == rD.items[i])
            {
                itemToRemove++;
            }
            else
            {
                ItemControl(rD.items[i - 1], -itemToRemove);
                itemToRemove = 1;
            }
            if (i == rD.items.Count - 1)
            {
                ItemControl(rD.items[i], -itemToRemove);
            }
        }
        Debug.Log("Item Removed");
        overallData.gameData.isCrafting = true;
        overallData.gameData.craftID    = recipe_id;
        overallData.gameData.craftETC   = ConvertToUnixTimestamp(System.DateTime.Now) + CLD.GetRecipeTime(recipe_id);
        EventNotifier.Invoke("Crafting Start!");
        StartCoroutine(StartCraftingClock());
        OnCatDataChaged.Invoke();
        OnItemDataChanged.Invoke();
    }
    //-----------
    // METHODS
    //-----------

    private void OnGameInitializehandler()      // invoke every data event
    {
        StopCoroutine("StartCraftingClock");
        OnCatDataChaged.Invoke();
        OnMoneyChanged.Invoke();
        OnItemDataChanged.Invoke();
        OnGroupDataChanged.Invoke();
        if (overallData.gameData.isCrafting)
        {
            StartCoroutine(StartCraftingClock());
        }
        foreach (exploreGroups eG in overallData.gameData.exploreGroups)
        {
            StartCoroutine(StartExploreClock(eG));
        }
    }
    void CraftingEnded()
    {
        overallData.gameData.isCrafting = false;
        Ientity entity = CLD.GetEntityByRecipeID(overallData.gameData.craftID);

        if (entity.GetType() == typeof(catData))
        {
            Debug.Log("Added Cat:" + ((catData)entity).name + "  ID:" + ((catData)entity).id);
            CatControl(((catData)entity).id, 1, CatControlType.count);
            EventNotifier.Invoke("Crafted New Cat: " + ((catData)entity).name);
            OnCatDataChaged.Invoke();
        }
        else
        {
            ItemControl(((itemData)entity).id, 1);
            EventNotifier.Invoke("Crafted New Item: " + ((itemData)entity).name);
            OnItemDataChanged.Invoke();
        }
        OnCraftingEnded.Invoke();
    }
    public bool CatControl(int id, int amount, CatControlType type)
    {
        int  current = 0;
        bool success = false, found = false;

        foreach (cat cat in overallData.gameData.ownedCats)
        {
            if (cat.id == id)
            {
                found = true;
                if (type == CatControlType.count)
                {
                    int tmp = cat.count;
                    tmp += amount;
                    if (tmp < 0)
                    {
                        Debug.LogError("Removed too much cats! must be exact 0 to remove cat type");
                        success = false;
                        break;
                    }
                    else if (tmp == 0)
                    {
                        Debug.Log("Removing Cat Type");
                        overallData.gameData.ownedCats.RemoveAt(current);
                        current--;
                        success = true;
                        break;
                    }
                    cat.count     += amount;
                    cat.avaliable += amount;
                    success        = true;
                    break;
                }
                else
                {
                    int tmp = cat.avaliable;
                    tmp += amount;
                    if (tmp < 0)
                    {
                        Debug.LogError("Not Enough Cats to occupy!(<0)");
                        success = false;
                        break;
                    }
                    else if (tmp > cat.count)
                    {
                        Debug.LogError("Not Enough Cats to occupy!(>cat count)");
                        success = false;
                        break;
                    }
                    else
                    {
                        cat.avaliable = tmp;
                        success       = true;
                        break;
                    }
                }
            }
            current++;
        }
        if (!found && amount > 0)
        {
            if (type == CatControlType.avaliable)
            {
                Debug.LogError("Cat Not Found!");
                success = false;
            }
            else
            {
                Debug.Log("Cat not found, adding cat");

                for (int i = 0; i < overallData.gameData.ownedCats.Count; i++)
                {
                    if (overallData.gameData.ownedCats[i].id > id)
                    {
                        Debug.Log("Inserting cat to " + i);
                        overallData.gameData.ownedCats.Insert(i, new cat(id, amount, amount));
                        success = true;
                        break;
                    }
                }
                if (!success)
                {
                    Debug.Log("Adding cat to the end of the list");
                    overallData.gameData.ownedCats.Add(new cat(id, amount, amount));
                    success = true;
                }
            }
        }
        if (success)
        {
            OnCatDataChaged.Invoke();
        }
        else
        {
            Debug.LogError("U DON FKED UP ID:" + id + " AMOUNT:" + amount + " TYPE:" + type);
        }
        return(success);
    }