Compare commits

...

3 Commits

4 changed files with 25 additions and 0 deletions
@@ -1295,6 +1295,7 @@ polygon = PackedVector2Array(247.227, 43.5123, 44.7822, 43.5123, -87.2178, 45.12
[node name="EnterHouseInteraction" parent="YSorted/Farm visuals/Static" instance=ExtResource("27_klb81")]
position = Vector2(5834, 2354)
scale = Vector2(2.425, 2.425)
_id = 0
metadata/SaveID = "5a93071f-c1ab-4b4b-b74e-a6324d44ddf8"
[node name="DoorSprite" type="Sprite2D" parent="YSorted/Farm visuals/Static/EnterHouseInteraction"]
@@ -190,6 +190,7 @@ _label = NodePath("Label")
_current = NodePath("Current")
[node name="Label" type="Label" parent="StateMachineDebugger"]
visible = false
offset_left = -982.0
offset_top = -497.0
offset_right = -893.0
@@ -197,6 +198,7 @@ offset_bottom = -474.0
text = "Hello world"
[node name="Current" type="Label" parent="StateMachineDebugger"]
visible = false
offset_left = 705.0
offset_top = -495.0
offset_right = 794.0
@@ -307,6 +307,11 @@ public partial class FightHappening : Node
HappeningData.enemyFighterFormation.SetFighterAtPosition(emptySlotIndex, fighter);
HappeningData.fighterTurn.AddAsLast(fighter);
}
if (GD.RandRange(0, 2) != 0) // 2/3 chance for vesna to start
{
HappeningData.fighterTurn.SpinBack();
}
}
private void ExecuteNextFighter()
@@ -99,6 +99,23 @@ public class FighterTurn : IEnumerable<FightWorld.Fighter>
return false;
}
/// <summary>
/// Sets the current one back
/// This is an expensive operation, because the entire data structure needs to be circled
/// </summary>
public void SpinBack()
{
if (_currentNode == null) return;
var node = _currentNode;
while (node.next != _currentNode)
{
node = node.next;
}
_currentNode = node;
}
public IEnumerator<FightWorld.Fighter> GetEnumerator()
{
if (_currentNode == null) return Enumerable.Empty<FightWorld.Fighter>().GetEnumerator();