//Call this when an object wants to be destroyed public bool OnObjectDestroy(GameObject gameobject) { bool permissionToDestroy = false; //cost to destroy an object is 45% of the matter fuel required to create it int matterFuelCost = Mathf.RoundToInt(0.45f * BuildMatterFuel(gameobject)); //check to see if player can afford to destroy object, checks matter fuel only [2] if (matterFuelCost <= currentFuelLevels[2]) { //builds recipe for item creation, uses 100% of the recipe value fuelChange = new int[] { BuildAestheticFuel(gameobject), BuildPhysicsFuel(gameobject), BuildMatterFuel(gameobject), BuildTransformFuel(gameobject) }; //add item as an Inventory Master Item, including its fuel recipe lootmanger.CreateItem(gameobject, fuelChange); //lower the recipe by 10%. The remaining 90% is considered profit for harvesting this item fuelChange = new int[] { Mathf.RoundToInt(0.9f * fuelChange[0]), Mathf.RoundToInt(0.9f * fuelChange[1]), Mathf.RoundToInt(0.9f * fuelChange[2] - matterFuelCost), Mathf.RoundToInt(0.9f * fuelChange[3]) }; update = true; permissionToDestroy = true; } else { NotEnoughFuel(); } return(permissionToDestroy); }