Files
RuinAdventurer/Scripts/Crafting/GameResource.cs
T

32 lines
743 B
C#

using Godot;
public class GameResource : Ingredient
{
int maxAmount;
bool isEndless;
float extractionSpeed;
double timeSinceLastExtraction;
public GameResource(string name)
{
this.name = name;
maxAmount = GameData.rand.Next(1000, 10000);
currentAmount = maxAmount;
isEndless = false;
extractionSpeed = 1f;
}
public bool Extract(double delta)
{
timeSinceLastExtraction += delta;
if (timeSinceLastExtraction < extractionSpeed) return false;
timeSinceLastExtraction = 0;
if(isEndless) return true;
if (currentAmount > 0)
{
currentAmount--;
return true;
}
return false;
}
}