🚧 made preplaced fields show plants
This commit is contained in:
@@ -80,17 +80,17 @@ _itemResourcesToListenFor = Array[Object]([ExtResource("15_i4qwg"), ExtResource(
|
|||||||
script = ExtResource("14_w08sx")
|
script = ExtResource("14_w08sx")
|
||||||
_itemResourcesToListenFor = Array[Object]([ExtResource("17_1mi0u")])
|
_itemResourcesToListenFor = Array[Object]([ExtResource("17_1mi0u")])
|
||||||
|
|
||||||
[node name="FieldCreationBlocker" type="Area2D" parent="."]
|
[node name="CursorOnFieldCollider" type="Area2D" parent="."]
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="FieldCreationBlocker"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="CursorOnFieldCollider"]
|
||||||
shape = SubResource("RectangleShape2D_57jmp")
|
shape = SubResource("RectangleShape2D_57jmp")
|
||||||
|
|
||||||
[node name="CursorOnFieldSetter" type="Node" parent="FieldCreationBlocker"]
|
[node name="CursorOnFieldSetter" type="Node" parent="CursorOnFieldCollider"]
|
||||||
script = ExtResource("19_lgya6")
|
script = ExtResource("19_lgya6")
|
||||||
_variableResource = ExtResource("20_lgya6")
|
_variableResource = ExtResource("20_lgya6")
|
||||||
_payloadToSet = true
|
_payloadToSet = true
|
||||||
|
|
||||||
[node name="CursorNotOnFieldSetter" type="Node" parent="FieldCreationBlocker"]
|
[node name="CursorNotOnFieldSetter" type="Node" parent="CursorOnFieldCollider"]
|
||||||
script = ExtResource("19_lgya6")
|
script = ExtResource("19_lgya6")
|
||||||
_variableResource = ExtResource("20_lgya6")
|
_variableResource = ExtResource("20_lgya6")
|
||||||
_payloadToSet = false
|
_payloadToSet = false
|
||||||
@@ -99,5 +99,5 @@ _payloadToSet = false
|
|||||||
[connection signal="Interacted" from="InteractionArea" to="FieldBehaviour" method="Farm"]
|
[connection signal="Interacted" from="InteractionArea" to="FieldBehaviour" method="Farm"]
|
||||||
[connection signal="ItemInstanceActivated" from="InventoryListener Seeds" to="FieldBehaviour" method="ActivatedSeedInInventory"]
|
[connection signal="ItemInstanceActivated" from="InventoryListener Seeds" to="FieldBehaviour" method="ActivatedSeedInInventory"]
|
||||||
[connection signal="ItemInstanceActivated" from="InventoryListener watering can" to="FieldBehaviour" method="ActivateWateringCanInInventory"]
|
[connection signal="ItemInstanceActivated" from="InventoryListener watering can" to="FieldBehaviour" method="ActivateWateringCanInInventory"]
|
||||||
[connection signal="mouse_entered" from="FieldCreationBlocker" to="FieldCreationBlocker/CursorOnFieldSetter" method="Set"]
|
[connection signal="mouse_entered" from="CursorOnFieldCollider" to="CursorOnFieldCollider/CursorOnFieldSetter" method="Set"]
|
||||||
[connection signal="mouse_exited" from="FieldCreationBlocker" to="FieldCreationBlocker/CursorNotOnFieldSetter" method="Set"]
|
[connection signal="mouse_exited" from="CursorOnFieldCollider" to="CursorOnFieldCollider/CursorNotOnFieldSetter" method="Set"]
|
||||||
|
|||||||
@@ -1718,9 +1718,6 @@ position = Vector2(1226, 3098.15)
|
|||||||
scale = Vector2(1, 1.00622)
|
scale = Vector2(1, 1.00622)
|
||||||
Payload = 1
|
Payload = 1
|
||||||
|
|
||||||
[node name="FieldBehaviour" parent="YSorted/Farm visuals/FieldParent/BaseField2" index="0"]
|
|
||||||
FieldState = 3
|
|
||||||
|
|
||||||
[node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField2/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")]
|
[node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField2/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")]
|
||||||
_state = 2
|
_state = 2
|
||||||
_field = NodePath("../..")
|
_field = NodePath("../..")
|
||||||
@@ -1730,9 +1727,6 @@ position = Vector2(1782, 2606.11)
|
|||||||
scale = Vector2(1, 1.00622)
|
scale = Vector2(1, 1.00622)
|
||||||
Payload = 2
|
Payload = 2
|
||||||
|
|
||||||
[node name="FieldBehaviour" parent="YSorted/Farm visuals/FieldParent/BaseField3" index="0"]
|
|
||||||
FieldState = 3
|
|
||||||
|
|
||||||
[node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField3/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")]
|
[node name="Beet2" parent="YSorted/Farm visuals/FieldParent/BaseField3/FieldBehaviour/PlantPlaceholder" index="0" node_paths=PackedStringArray("_field") instance=ExtResource("41_vyqmy")]
|
||||||
_state = 2
|
_state = 2
|
||||||
_field = NodePath("../..")
|
_field = NodePath("../..")
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using Babushka.scripts.CSharp.Common.Animation;
|
|
||||||
using Babushka.scripts.CSharp.Common.Inventory;
|
using Babushka.scripts.CSharp.Common.Inventory;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines the behaviour of a plant in Babushka.
|
/// Determines the behaviour of a plant in Babushka.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -23,8 +20,9 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
[Export] private bool _magicWordNeeded = true;
|
[Export] private bool _magicWordNeeded = true;
|
||||||
|
|
||||||
private string _magicWordDialogicEventName = "MagicWord";
|
private string _magicWordDialogicEventName = "MagicWord";
|
||||||
private Sprite2D _currentPlantSprite = null;
|
private Sprite2D? _currentPlantSprite = null;
|
||||||
private bool _magicWordSaid = false;
|
private bool _magicWordSaid = false;
|
||||||
|
private bool _calledOnReady = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// public accessor for the field reference
|
/// public accessor for the field reference
|
||||||
@@ -37,6 +35,7 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
GD.Print($"Ready: {Name}");
|
||||||
if (_state == PlantState.None)
|
if (_state == PlantState.None)
|
||||||
{
|
{
|
||||||
_state = PlantState.Planted;
|
_state = PlantState.Planted;
|
||||||
@@ -45,6 +44,8 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
GD.Print("plant state not none.");
|
||||||
|
_calledOnReady = true;
|
||||||
GrowPlant();
|
GrowPlant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,9 +61,13 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void GrowPlant()
|
public void GrowPlant()
|
||||||
{
|
{
|
||||||
if (_field.FieldState != FieldState.Watered || _magicWordSaid != _magicWordNeeded)
|
if (!_calledOnReady)
|
||||||
return;
|
{
|
||||||
|
if (_field.FieldState != FieldState.Watered || _magicWordSaid != _magicWordNeeded)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GD.Print("Growing plant.");
|
||||||
switch (_state)
|
switch (_state)
|
||||||
{
|
{
|
||||||
case PlantState.None:
|
case PlantState.None:
|
||||||
@@ -105,6 +110,7 @@ public partial class PlantBehaviour2D : Node2D
|
|||||||
|
|
||||||
_field.UpdateFieldState(FieldState.Tilled);
|
_field.UpdateFieldState(FieldState.Tilled);
|
||||||
_magicWordSaid = false;
|
_magicWordSaid = false;
|
||||||
|
_calledOnReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Sprite2D GetRandomSprite(Sprite2D[] sprites)
|
private Sprite2D GetRandomSprite(Sprite2D[] sprites)
|
||||||
|
|||||||
Reference in New Issue
Block a user