Basic watering functionality implemented

remotes/checkIfPRContentChanged-1749884192368007736/c_sharp_setup
kziolkowski 9 months ago
parent 7e19268847
commit 339428c312

@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArea3D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F8a54226fa2e1c9371a8091f24cfd744aef11fe6869527dc23b9b837623a29b9_003FArea3D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AArea3D_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F8a54226fa2e1c9371a8091f24cfd744aef11fe6869527dc23b9b837623a29b9_003FArea3D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACastHelpers_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fd111abf504bf42b5968a609b168fd093b2e200_003Fbb_003F1c116fcd_003FCastHelpers_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

@ -4,12 +4,11 @@ importer="scene"
importer_version=1 importer_version=1
type="PackedScene" type="PackedScene"
uid="uid://b3kyrsoobmkhp" uid="uid://b3kyrsoobmkhp"
path="res://.godot/imported/best_house_blender.blend-ac89c74aef2f275bdf4b4baadee17c0c.scn" valid=false
[deps] [deps]
source_file="res://art/mockups/3d/best_house_blender.blend" source_file="res://art/mockups/3d/best_house_blender.blend"
dest_files=["res://.godot/imported/best_house_blender.blend-ac89c74aef2f275bdf4b4baadee17c0c.scn"]
[params] [params]

@ -1,6 +1,6 @@
[gd_scene load_steps=5 format=3 uid="uid://cgjc4wurbgimy"] [gd_scene load_steps=5 format=3 uid="uid://cgjc4wurbgimy"]
[ext_resource type="Script" uid="uid://b7vlkecrn0t5c" path="res://scripts/CSharp/Common/Inventory/InventoryUi.cs" id="1_6wusm"] [ext_resource type="Script" uid="uid://hg7jay2kt441" path="res://scripts/CSharp/Common/Inventory/InventoryUi.cs" id="1_6wusm"]
[ext_resource type="Script" uid="uid://b2jhdxcrhtm2d" path="res://scripts/CSharp/Common/Inventory/InventoryTestScript.cs" id="3_exrk4"] [ext_resource type="Script" uid="uid://b2jhdxcrhtm2d" path="res://scripts/CSharp/Common/Inventory/InventoryTestScript.cs" id="3_exrk4"]
[ext_resource type="Resource" uid="uid://datee0flk1e84" path="res://resources/items/pickaxe.tres" id="4_5fdxq"] [ext_resource type="Resource" uid="uid://datee0flk1e84" path="res://resources/items/pickaxe.tres" id="4_5fdxq"]
[ext_resource type="Texture2D" uid="uid://c7wqla0mbu3np" path="res://graphics/ui/babushka_ui_tmp_inventory_select.png" id="4_tiss4"] [ext_resource type="Texture2D" uid="uid://c7wqla0mbu3np" path="res://graphics/ui/babushka_ui_tmp_inventory_select.png" id="4_tiss4"]

@ -1,7 +1,8 @@
[gd_scene load_steps=6 format=3 uid="uid://biwd3jj65qrlh"] [gd_scene load_steps=7 format=3 uid="uid://biwd3jj65qrlh"]
[ext_resource type="Texture2D" uid="uid://c2pirgay3jfnn" path="res://art/farm/tilable grounds/böden/trockene farming erde.png" id="1_2cisk"] [ext_resource type="Texture2D" uid="uid://c2pirgay3jfnn" path="res://art/farm/tilable grounds/böden/trockene farming erde.png" id="1_2cisk"]
[ext_resource type="Script" uid="uid://histmmyi1wr" path="res://scripts/CSharp/Common/Farming/FieldBehaviour.cs" id="2_u7egi"] [ext_resource type="Script" uid="uid://histmmyi1wr" path="res://scripts/CSharp/Common/Farming/FieldBehaviour.cs" id="2_u7egi"]
[ext_resource type="Texture2D" uid="uid://ctvdxwgmfaj5c" path="res://art/farm/tilable grounds/böden/nasse farming erde.png" id="4_lsseu"]
[ext_resource type="PackedScene" uid="uid://bjhj1wa5olwcu" path="res://prefabs/farming/base_plant.tscn" id="4_u7egi"] [ext_resource type="PackedScene" uid="uid://bjhj1wa5olwcu" path="res://prefabs/farming/base_plant.tscn" id="4_u7egi"]
[ext_resource type="PackedScene" uid="uid://ob04y3syvo0e" path="res://prefabs/interaction_area.tscn" id="4_xc4m0"] [ext_resource type="PackedScene" uid="uid://ob04y3syvo0e" path="res://prefabs/interaction_area.tscn" id="4_xc4m0"]
@ -18,17 +19,20 @@ _showLabel = false
[node name="CollisionShape3D" parent="InteractionArea/Area3D" index="0"] [node name="CollisionShape3D" parent="InteractionArea/Area3D" index="0"]
shape = SubResource("SphereShape3D_u7egi") shape = SubResource("SphereShape3D_u7egi")
[node name="Sprite3D" type="Sprite3D" parent="."] [node name="FieldBehaviour" type="Sprite3D" parent="."]
transform = Transform3D(0.4, 0, 0, 0, -1.74846e-08, -0.4, 0, 0.4, -1.74846e-08, 0, 0, 0) transform = Transform3D(0.4, 0, 0, 0, -1.74846e-08, -0.4, 0, 0.4, -1.74846e-08, 0, 0, 0)
pixel_size = 0.004 pixel_size = 0.004
texture = ExtResource("1_2cisk")
script = ExtResource("2_u7egi") script = ExtResource("2_u7egi")
Tilled = ExtResource("1_2cisk") Tilled = ExtResource("1_2cisk")
Watered = ExtResource("4_lsseu")
FieldState = 1 FieldState = 1
metadata/_custom_type_script = "uid://histmmyi1wr"
[node name="BasePlant" parent="Sprite3D" instance=ExtResource("4_u7egi")] [node name="BasePlant" parent="FieldBehaviour" node_paths=PackedStringArray("_seeds", "_smallPlants", "_bigPlants", "_readyPlants") instance=ExtResource("4_u7egi")]
transform = Transform3D(0.5, 0, 0, 0, -2.18557e-08, 0.5, 0, -0.5, -2.18557e-08, 0, 0, 0) transform = Transform3D(0.5, 0, 0, 0, -2.18557e-08, 0.5, 0, -0.5, -2.18557e-08, 0, 0, 0)
_seeds = [null, null, null]
[connection signal="Interacted" from="InteractionArea" to="Sprite3D/BasePlant" method="Grow"] _smallPlants = [null, null, null, null]
_bigPlants = [null, null, null, null]
_readyPlants = [null, null, null, null]
[editable path="InteractionArea"] [editable path="InteractionArea"]

@ -11,7 +11,7 @@ config_version=5
[application] [application]
config/name="Babushka" config/name="Babushka"
run/main_scene="uid://dbxy2y85r1d8x" run/main_scene="uid://br7yq757cawts"
config/features=PackedStringArray("4.4", "C#", "Forward Plus") config/features=PackedStringArray("4.4", "C#", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"

@ -6,5 +6,4 @@
script = ExtResource("1_07aya") script = ExtResource("1_07aya")
name = "Pick Axe" name = "Pick Axe"
color = Color(0.589014, 0.823353, 0.998475, 1) color = Color(0.589014, 0.823353, 0.998475, 1)
maxStack = 1
metadata/_custom_type_script = "uid://cbskymrxs6ksu" metadata/_custom_type_script = "uid://cbskymrxs6ksu"

@ -5,7 +5,7 @@
[ext_resource type="PackedScene" uid="uid://5hltxpdxmqcq" path="res://prefabs/interactions/generic_item_on_ground.tscn" id="5_sjt6k"] [ext_resource type="PackedScene" uid="uid://5hltxpdxmqcq" path="res://prefabs/interactions/generic_item_on_ground.tscn" id="5_sjt6k"]
[ext_resource type="PackedScene" uid="uid://cgjc4wurbgimy" path="res://prefabs/UI/Inventory/Inventory.tscn" id="6_876p1"] [ext_resource type="PackedScene" uid="uid://cgjc4wurbgimy" path="res://prefabs/UI/Inventory/Inventory.tscn" id="6_876p1"]
[ext_resource type="Resource" uid="uid://cndd64batns31" path="res://resources/items/bucket.tres" id="6_nvnpb"] [ext_resource type="Resource" uid="uid://cndd64batns31" path="res://resources/items/bucket.tres" id="6_nvnpb"]
[ext_resource type="Script" uid="uid://d17si23dtlg72" path="res://scripts/CSharp/Common/Farming/FieldService.cs" id="7_3rkjv"] [ext_resource type="Script" uid="uid://c6hh7m8wikv04" path="res://scripts/CSharp/Common/Farming/FieldService.cs" id="7_3rkjv"]
[ext_resource type="Resource" uid="uid://c5yg3lx756v4v" path="res://resources/items/hoe.tres" id="7_hv2km"] [ext_resource type="Resource" uid="uid://c5yg3lx756v4v" path="res://resources/items/hoe.tres" id="7_hv2km"]
[ext_resource type="Resource" uid="uid://d1uuxp1lp4aro" path="res://resources/items/tomato_seed.tres" id="8_hv2km"] [ext_resource type="Resource" uid="uid://d1uuxp1lp4aro" path="res://resources/items/tomato_seed.tres" id="8_hv2km"]

@ -1,5 +1,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Godot; using Godot;
using Godot.Collections;
namespace Babushka.scripts.CSharp.Common.Farming; namespace Babushka.scripts.CSharp.Common.Farming;
@ -55,7 +58,13 @@ public partial class FarmingControls : Node3D
private void WaterTheField() private void WaterTheField()
{ {
Vector2I currentPos = new Vector2I(AdjustValue(_movingPlayer.GlobalPosition.X), AdjustValue(_movingPlayer.GlobalPosition.Z));
FieldBehaviour field = FieldParent.Get(currentPos);
if (field == null)
return;
field.Water();
Debug.Print("Watered the field.");
} }
private void MakeField() private void MakeField()
@ -75,7 +84,9 @@ public partial class FarmingControls : Node3D
if (fieldInstance is Node3D field3d) if (fieldInstance is Node3D field3d)
{ {
// add dictionary entry for the field // add dictionary entry for the field
FieldParent.TryAddEntry(intPosition, field3d as FieldBehaviour); Array<Node> fields = field3d.FindChildren("*", nameof(FieldBehaviour));
if (fields.Count > 0)
FieldParent.TryAddEntry(intPosition, fields[0] as FieldBehaviour);
// reposition and reparent the instance // reposition and reparent the instance
field3d.Position = playerPos; field3d.Position = playerPos;
@ -84,9 +95,9 @@ public partial class FarmingControls : Node3D
} }
} }
private float AdjustValue(float value) private int AdjustValue(float value)
{ {
return Mathf.Floor(value); return (int) Mathf.Floor(value);
} }
} }

@ -1,7 +1,8 @@
using System.Diagnostics;
using Godot; using Godot;
namespace Babushka.scripts.CSharp.Common.Farming; namespace Babushka.scripts.CSharp.Common.Farming
{
public enum FieldState public enum FieldState
{ {
Empty = 0, Empty = 0,
@ -11,6 +12,7 @@ public enum FieldState
NotFound = 99 NotFound = 99
} }
[GlobalClass]
public partial class FieldBehaviour : Sprite3D public partial class FieldBehaviour : Sprite3D
{ {
[Export] private Texture2D Tilled; [Export] private Texture2D Tilled;
@ -29,6 +31,7 @@ public partial class FieldBehaviour : Sprite3D
{ {
FieldState = FieldState.Watered; FieldState = FieldState.Watered;
Texture = Watered; Texture = Watered;
Debug.Print($"Current Texture: {Texture.ResourceName}");
} }
/// <summary> /// <summary>
@ -53,3 +56,5 @@ public partial class FieldBehaviour : Sprite3D
} }
} }
}

@ -15,9 +15,9 @@ public partial class FieldService : Node3D
if (!fields.ContainsKey(key)) if (!fields.ContainsKey(key))
{ {
fields.Add(key, field); fields.Add(key, field);
Debug.Print("Added entry: " + key);
return true; return true;
} }
Debug.Print("Added entry: " + key);
return false; return false;
} }
@ -26,7 +26,11 @@ public partial class FieldService : Node3D
{ {
Debug.Print($"Getting field at {key}. Found: {fields.ContainsKey(key)}."); Debug.Print($"Getting field at {key}. Found: {fields.ContainsKey(key)}.");
if (fields.TryGetValue(key, out FieldBehaviour field)) if (fields.TryGetValue(key, out FieldBehaviour field))
{
Debug.Print($"Getting field at {key}, field: {field.Name}.");
return field; return field;
}
return null; return null;
} }

Loading…
Cancel
Save