WIP trying to toggle interactable colliders at runtime for fields

kziolkowski 7 months ago
parent 6def053d22
commit e04f9f65d4

@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://b1d2e7ely6hyw"]
[gd_scene load_steps=8 format=3 uid="uid://b1d2e7ely6hyw"]
[ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="1_femni"]
[ext_resource type="Script" uid="uid://bdffon388rkty" path="res://scripts/CSharp/Common/Farming/FieldBehaviour2D.cs" id="2_femni"]
@ -6,9 +6,13 @@
[ext_resource type="Texture2D" uid="uid://d3dq15edmgbwf" path="res://art/farm/tilable grounds/böden/nasse farming erde rund.png" id="4_lsfck"]
[ext_resource type="PackedScene" uid="uid://c3hwbwo423nbm" path="res://prefabs/farm/base_plant_2d.tscn" id="5_femni"]
[sub_resource type="CircleShape2D" id="CircleShape2D_yi42k"]
resource_local_to_scene = true
radius = 201.345
[sub_resource type="CircleShape2D" id="CircleShape2D_femni"]
resource_local_to_scene = true
radius = 300.0
radius = 194.926
[node name="BaseField" type="Node2D"]
@ -17,13 +21,14 @@ visible = false
z_index = 1
scale = Vector2(2.225, 2.225)
[node name="FieldBehaviour" type="Sprite2D" parent="."]
[node name="FieldBehaviour" type="Sprite2D" parent="." node_paths=PackedStringArray("_growingCollider")]
z_index = -1
scale = Vector2(0.9, 1)
texture = ExtResource("2_yi42k")
script = ExtResource("2_femni")
Tilled = ExtResource("2_yi42k")
Watered = ExtResource("4_lsfck")
_growingCollider = NodePath("BasePlant/InteractionArea")
[node name="BasePlant" parent="FieldBehaviour" node_paths=PackedStringArray("_field") instance=ExtResource("5_femni")]
_field = NodePath("..")
@ -31,9 +36,18 @@ _field = NodePath("..")
[node name="BigPlant" parent="FieldBehaviour/BasePlant" index="2"]
position = Vector2(6, -161)
[node name="InteractionArea" parent="FieldBehaviour/BasePlant" index="3"]
z_index = 3
[node name="CollisionShape3D" parent="FieldBehaviour/BasePlant/InteractionArea/Area2D" index="0"]
shape = SubResource("CircleShape2D_yi42k")
[node name="CollisionShape3D" parent="FieldBehaviour/BasePlant/ReadyPlantInventoryItem/InteractionArea2/Area2D" index="0"]
shape = SubResource("CircleShape2D_femni")
[node name="Label" parent="FieldBehaviour/BasePlant/ReadyPlantInventoryItem/InteractionArea2" index="1"]
visible = false
[node name="ReadyPlant" parent="FieldBehaviour/BasePlant/ReadyPlantInventoryItem" index="5"]
visible = false
position = Vector2(0, -291.3)
@ -44,5 +58,6 @@ visible = true
[connection signal="Interacted" from="InteractionArea2" to="FieldBehaviour/BasePlant" method="Grow"]
[editable path="FieldBehaviour/BasePlant"]
[editable path="FieldBehaviour/BasePlant/InteractionArea"]
[editable path="FieldBehaviour/BasePlant/ReadyPlantInventoryItem"]
[editable path="FieldBehaviour/BasePlant/ReadyPlantInventoryItem/InteractionArea2"]

@ -1,3 +1,4 @@
using Babushka.scripts.CSharp.Common.CharacterControls;
using Godot;
namespace Babushka.scripts.CSharp.Common.Farming;
@ -17,6 +18,7 @@ public partial class FieldBehaviour2D : Sprite2D
[Export] private Texture2D Tilled;
[Export] private Texture2D Watered;
[Export] public FieldState FieldState = FieldState.Tilled;
[Export] private InteractionArea2D _growingCollider;
public Vector2 FieldPosition;
@ -36,10 +38,12 @@ public partial class FieldBehaviour2D : Sprite2D
case FieldState.Tilled:
FieldState = FieldState.Tilled;
Texture = Tilled;
_growingCollider.Visible = false;
break;
case FieldState.Watered:
FieldState = FieldState.Watered;
Texture = Watered;
_growingCollider.Visible = true;
break;
case FieldState.Planted:
FieldState = FieldState.Planted;

Loading…
Cancel
Save