8170b700b2
Features: Sacrifice-Node, Maintain-Node, Options for screen type, lightcolor and soundvolume, tied in sound effects, game pause when menu is open, visibly open up gate when opening it.
61 lines
1.5 KiB
C#
61 lines
1.5 KiB
C#
using Godot;
|
|
|
|
public class HarvestNode : ProgramNode
|
|
{
|
|
public HarvestNode()
|
|
{
|
|
DisplayText = "Harvest";
|
|
}
|
|
public override NodeResult Execute(Robot robot, double delta)
|
|
{
|
|
Vector3I mapIndex = Pathfinding.GetClosestStartPoint(robot.Position);
|
|
Tile tile = GameData.map[mapIndex.Y].tiles[mapIndex.X, mapIndex.Z];
|
|
|
|
if (!tile.containsResource)
|
|
{
|
|
lastExecutionMessage = "No resource on this tile";
|
|
return NodeResult.FAILURE;
|
|
}
|
|
|
|
if (!tile.resource.CanExtract())
|
|
{
|
|
lastExecutionMessage = "Resource is depleted and not endless or you haven't unlocked it yet";
|
|
return NodeResult.SUCCESS;
|
|
}
|
|
|
|
if (tile.resource.Extract(delta))
|
|
{
|
|
SoundManager.PlayMining();
|
|
if (!GameData.inventory.AddItem(new Item {data = tile.resource.item}, 1))
|
|
{
|
|
lastExecutionMessage = "Not enough space";
|
|
return NodeResult.FAILURE;
|
|
}
|
|
else
|
|
{
|
|
return NodeResult.SUCCESS;
|
|
}
|
|
}
|
|
return NodeResult.RUNNING;
|
|
}
|
|
|
|
public override void ReadParameters(NodeDisplay display)
|
|
{
|
|
}
|
|
|
|
public override ProgramNode Duplicate()
|
|
{
|
|
HarvestNode duplicate = new HarvestNode();
|
|
return duplicate;
|
|
}
|
|
|
|
public override void Setup(NodeDisplay display)
|
|
{
|
|
}
|
|
|
|
public override string Save()
|
|
{
|
|
return $"Name: {DisplayText}";
|
|
}
|
|
}
|