✨ Added inventorylistener for watering can
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=17 format=3 uid="uid://b1d2e7ely6hyw"]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://b1d2e7ely6hyw"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bdffon388rkty" path="res://scripts/CSharp/Common/Farming/FieldBehaviour2D.cs" id="1_qa01x"]
|
||||
[ext_resource type="Texture2D" uid="uid://cgmu3qlovdr22" path="res://art/masks/field_outline_1.png" id="2_w8caw"]
|
||||
@@ -16,6 +16,7 @@
|
||||
[ext_resource type="Script" uid="uid://3t0af586fimq" path="res://scripts/CSharp/Common/Inventory/InventoryListener.cs" id="14_w08sx"]
|
||||
[ext_resource type="Resource" uid="uid://d1uuxp1lp4aro" path="res://resources/items/tomato_seed.tres" id="15_i4qwg"]
|
||||
[ext_resource type="Resource" uid="uid://duq7tshxv6uhp" path="res://resources/items/beet_seed.tres" id="16_i4qwg"]
|
||||
[ext_resource type="Resource" uid="uid://cndd64batns31" path="res://resources/items/wateringcan.tres" id="17_1mi0u"]
|
||||
|
||||
[node name="BaseField" type="Node2D"]
|
||||
|
||||
@@ -60,10 +61,15 @@ _spritesToOutline = [NodePath("../FieldBehaviour/OutlineSprite")]
|
||||
script = ExtResource("9_teirr")
|
||||
_eventResources = Array[Object]([ExtResource("10_wx561")])
|
||||
|
||||
[node name="InventoryListener" type="Node" parent="."]
|
||||
[node name="InventoryListener Seeds" type="Node" parent="."]
|
||||
script = ExtResource("14_w08sx")
|
||||
_itemResourcesToListenFor = Array[Object]([ExtResource("15_i4qwg"), ExtResource("16_i4qwg")])
|
||||
|
||||
[node name="InventoryListener watering can" type="Node" parent="."]
|
||||
script = ExtResource("14_w08sx")
|
||||
_itemResourcesToListenFor = Array[Object]([ExtResource("17_1mi0u")])
|
||||
|
||||
[connection signal="Planted" from="FieldBehaviour" to="PlantCreationEventRaiser" method="RaiseEvents"]
|
||||
[connection signal="Interacted" from="InteractionArea" to="FieldBehaviour" method="Farm"]
|
||||
[connection signal="ItemInstanceActivated" from="InventoryListener" 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"]
|
||||
|
||||
@@ -62,9 +62,6 @@ public partial class InteractionArea2D : Node2D
|
||||
|
||||
public void OnPlayerExited(Node2D player)
|
||||
{
|
||||
if (!_active)
|
||||
return;
|
||||
|
||||
_label.Hide();
|
||||
|
||||
if (!_useOutline)
|
||||
|
||||
@@ -24,6 +24,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
public Vector2 FieldPosition;
|
||||
|
||||
private bool _seedsActive;
|
||||
private bool _wateringCanActive;
|
||||
|
||||
[Signal] public delegate void PlantedEventHandler();
|
||||
|
||||
@@ -32,7 +33,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
// fieldstate == tilled / watered && samen im Inventar
|
||||
bool canPlant = (FieldState == FieldState.Tilled || FieldState == FieldState.Watered) && _seedsActive;
|
||||
// fieldstate == tilled && watering can ausgewählt
|
||||
bool canWater = false;
|
||||
bool canWater = FieldState == FieldState.Tilled && _wateringCanActive;
|
||||
FieldInteractionArea.IsActive = canPlant || canWater;
|
||||
}
|
||||
|
||||
@@ -42,10 +43,15 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
UpdateInteractionArea();
|
||||
}
|
||||
|
||||
public void ActivateWateringCanInInventory(bool activated)
|
||||
{
|
||||
_wateringCanActive = activated;
|
||||
UpdateInteractionArea();
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
UpdateFieldState(FieldState);
|
||||
UpdateInteractionArea();
|
||||
int randomIndex = new Random().Next(0, _maskTexture.Length);
|
||||
_maskSprite.Texture = _maskTexture[randomIndex];
|
||||
_outlineSprite.Texture = _maskOutlineTextures[randomIndex];
|
||||
@@ -79,6 +85,7 @@ public partial class FieldBehaviour2D : Sprite2D
|
||||
FieldState = FieldState.NotFound;
|
||||
break;
|
||||
}
|
||||
UpdateInteractionArea();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user