Added increase to robotcount when completing research, added value modifiers for robot types.
This commit is contained in:
@@ -11,7 +11,6 @@ public partial class Robot : Node3D
|
||||
private const float CooldownTarget = 35f;
|
||||
private const float MaintenanceLossPerSecond = 0.04f;
|
||||
|
||||
private List<ProgramNode> nodes = new List<ProgramNode>();
|
||||
private bool isExecuting = false;
|
||||
private ProgramNode currentNode;
|
||||
|
||||
@@ -21,6 +20,12 @@ public partial class Robot : Node3D
|
||||
public float maintenance = 100f;
|
||||
public bool isCoolingDown = false;
|
||||
public bool isBroken = false;
|
||||
public string robotType = "iron_robot";
|
||||
|
||||
private RobotTypeStats TypeStats =>
|
||||
GameData.robotStats.RobotTypes.TryGetValue(robotType, out RobotTypeStats stats)
|
||||
? stats
|
||||
: GameData.robotStats.RobotTypes["stone_robot"];
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
@@ -33,14 +38,16 @@ public partial class Robot : Node3D
|
||||
case NodeResult.SUCCESS:
|
||||
currentNode = currentNode.nextNode;
|
||||
if (currentNode == null)
|
||||
{
|
||||
{
|
||||
isExecuting = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case NodeResult.FAILURE:
|
||||
isExecuting = false;
|
||||
currentMessage = "(FAILED)" + currentNode.lastExecutionMessage;
|
||||
break;
|
||||
|
||||
case NodeResult.RUNNING:
|
||||
currentMessage = "";
|
||||
break;
|
||||
@@ -49,26 +56,32 @@ public partial class Robot : Node3D
|
||||
}
|
||||
else if (currentMessage.Length <= 0)
|
||||
{
|
||||
CoolDown(delta, GameData.robotStats.GetCoolingRate(IdleHeatLossPerSecond));
|
||||
CoolDown(
|
||||
delta,
|
||||
GameData.robotStats.GetCoolingRate(IdleHeatLossPerSecond)
|
||||
* TypeStats.CoolingMultiplier
|
||||
);
|
||||
|
||||
currentMessage = "No script executing";
|
||||
}
|
||||
|
||||
Visible = Math.Round(Math.Abs(Position.Y / GameData.tileHeight), 0) == GameData.visibleLayer;
|
||||
|
||||
}
|
||||
|
||||
public void SetupExecution(List<ProgramNode> nodes)
|
||||
{
|
||||
if (nodes.Count <= 0) return;
|
||||
|
||||
this.nodes = new List<ProgramNode>(nodes);
|
||||
isExecuting = true;
|
||||
currentNode = nodes[0];
|
||||
currentMessage = "";
|
||||
}
|
||||
|
||||
public float GetMovementSpeed()
|
||||
{
|
||||
return GameData.robotStats.GetMovementSpeed(GameData.robotSpeed) * GetWorkEfficiency();
|
||||
return GameData.robotStats.GetMovementSpeed(GameData.robotSpeed)
|
||||
* TypeStats.SpeedMultiplier
|
||||
* GetWorkEfficiency();
|
||||
}
|
||||
|
||||
public float GetWorkEfficiency()
|
||||
@@ -76,8 +89,17 @@ public partial class Robot : Node3D
|
||||
if (isBroken) return 0f;
|
||||
if (maintenance >= 50f) return 1f;
|
||||
|
||||
float minimumEfficiency = GameData.robotStats.GetMinimumEfficiency();
|
||||
return Math.Clamp(minimumEfficiency + maintenance / 100f, minimumEfficiency, 1f);
|
||||
float minimumEfficiency =
|
||||
GameData.robotStats.GetMinimumEfficiency()
|
||||
+ TypeStats.MinimumEfficiencyBonus;
|
||||
|
||||
minimumEfficiency = Math.Clamp(minimumEfficiency, 0f, 1f);
|
||||
|
||||
return Math.Clamp(
|
||||
minimumEfficiency + maintenance / 100f,
|
||||
minimumEfficiency,
|
||||
1f
|
||||
);
|
||||
}
|
||||
|
||||
public void Maintain()
|
||||
@@ -103,19 +125,42 @@ public partial class Robot : Node3D
|
||||
|
||||
if (isCoolingDown)
|
||||
{
|
||||
CoolDown(delta, GameData.robotStats.GetCoolingRate(ActiveHeatLossPerSecond));
|
||||
CoolDown(
|
||||
delta,
|
||||
GameData.robotStats.GetCoolingRate(ActiveHeatLossPerSecond)
|
||||
* TypeStats.CoolingMultiplier
|
||||
);
|
||||
|
||||
currentMessage = $"Cooling down ({heat:0}%)";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GameData.survival.TryConsumeEnergy(GameData.robotStats.GetEnergyUse(EnergyUsePerSecond) * (float)delta))
|
||||
float energyUse =
|
||||
GameData.robotStats.GetEnergyUse(EnergyUsePerSecond)
|
||||
* TypeStats.EnergyUseMultiplier
|
||||
* (float)delta;
|
||||
|
||||
if (!GameData.survival.TryConsumeEnergy(energyUse))
|
||||
{
|
||||
currentMessage = "Not enough energy";
|
||||
return false;
|
||||
}
|
||||
|
||||
heat = Math.Clamp(heat + GameData.robotStats.GetHeatGain(HeatGainPerSecond) * (float)delta, 0f, 100f);
|
||||
maintenance = Math.Clamp(maintenance - GameData.robotStats.GetMaintenanceLoss(MaintenanceLossPerSecond) * (float)delta, 0f, 100f);
|
||||
heat = Math.Clamp(
|
||||
heat + GameData.robotStats.GetHeatGain(HeatGainPerSecond)
|
||||
* TypeStats.HeatGainMultiplier
|
||||
* (float)delta,
|
||||
0f,
|
||||
100f
|
||||
);
|
||||
|
||||
maintenance = Math.Clamp(
|
||||
maintenance - GameData.robotStats.GetMaintenanceLoss(MaintenanceLossPerSecond)
|
||||
* TypeStats.MaintenanceLossMultiplier
|
||||
* (float)delta,
|
||||
0f,
|
||||
100f
|
||||
);
|
||||
|
||||
if (heat >= 100f)
|
||||
{
|
||||
@@ -136,10 +181,15 @@ public partial class Robot : Node3D
|
||||
|
||||
private void CoolDown(double delta, float heatLossPerSecond)
|
||||
{
|
||||
heat = Math.Clamp(heat - heatLossPerSecond * (float)delta, 0f, 100f);
|
||||
heat = Math.Clamp(
|
||||
heat - heatLossPerSecond * (float)delta,
|
||||
0f,
|
||||
100f
|
||||
);
|
||||
|
||||
if (heat <= CooldownTarget)
|
||||
{
|
||||
isCoolingDown = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user