Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71ca6c3305 | |||
| 1782ff91b4 | |||
| 54b07cccad | |||
| fb0c14c3f1 | |||
| fb362e10ad | |||
| e99b574d1f | |||
| 1062193785 | |||
| 9190b2a16a | |||
| c200098f0c | |||
| 0e775309fb | |||
| 5db71adf03 | |||
| ce5d2b65d3 | |||
| 6016f1cf38 | |||
| b5dcad5614 |
Generated
-1
@@ -1 +0,0 @@
|
||||
Babushka
|
||||
+24
-10
@@ -1,11 +1,12 @@
|
||||
[gd_scene load_steps=302 format=3 uid="uid://dbd1niu3tp8y5"]
|
||||
[gd_scene load_steps=303 format=3 uid="uid://dbd1niu3tp8y5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b4ugrget2x6lb" path="res://scripts/CSharp/Common/CharacterControls/Player3D.cs" id="1_3trg2"]
|
||||
[ext_resource type="Script" uid="uid://xm0um640aes7" path="res://scripts/CSharp/Common/CharacterControls/VesnaBehaviour.cs" id="1_pkl5l"]
|
||||
[ext_resource type="Texture2D" uid="uid://duaideiajsu8r" path="res://art/characters/Vesna/babushka concept art vesna.png" id="2_3trg2"]
|
||||
[ext_resource type="PackedScene" uid="uid://biwd3jj65qrlh" path="res://prefabs/farming/base_field.tscn" id="2_oq5hi"]
|
||||
[ext_resource type="Script" uid="uid://r5tahuqvbucy" path="res://scripts/CSharp/Common/Camera/CameraPivot.cs" id="3_3trg2"]
|
||||
[ext_resource type="Texture2D" uid="uid://c4ggew55w0icj" path="res://art/farm/farming/farmobjekte/harke.png" id="4_kngqo"]
|
||||
[ext_resource type="Script" uid="uid://b1sscdr4ptec8" path="res://scripts/CSharp/Common/Farming/FarmingControls.cs" id="4_q5t2e"]
|
||||
[ext_resource type="Texture2D" uid="uid://x8hr8287ff2n" path="res://art/farm/farming/farmobjekte/tools atlas.png" id="5_pkl5l"]
|
||||
[ext_resource type="Texture2D" uid="uid://dygkh117flcou" path="res://art/animation/vesna/Front/F01-Idle/0001.png" id="7_okmao"]
|
||||
[ext_resource type="Texture2D" uid="uid://rwqptk0hk53" path="res://art/animation/vesna/Front/F01-Idle/0002.png" id="8_ctpgn"]
|
||||
[ext_resource type="Texture2D" uid="uid://c5om11bu7mtvh" path="res://art/animation/vesna/Front/F01-Idle/0003.png" id="9_8n7il"]
|
||||
@@ -1210,11 +1211,9 @@ animations = [{
|
||||
"speed": 25.0
|
||||
}]
|
||||
|
||||
[node name="Player3d" type="Node3D" node_paths=PackedStringArray("_hoeSprite", "_movingPlayer")]
|
||||
script = ExtResource("4_q5t2e")
|
||||
_hoeSprite = NodePath("CharacterBody3D/Farming/Hoe")
|
||||
_fieldPrefab = ExtResource("2_oq5hi")
|
||||
_movingPlayer = NodePath("CharacterBody3D")
|
||||
[node name="Player3d" type="Node3D" node_paths=PackedStringArray("_farmingControls")]
|
||||
script = ExtResource("1_pkl5l")
|
||||
_farmingControls = NodePath("FarmingControls")
|
||||
|
||||
[node name="CharacterBody3D" type="CharacterBody3D" parent="." node_paths=PackedStringArray("_camera", "_frontSpritesAnimated", "_sideSpritesAnimated", "_backSpritesAnimated")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000654221, 0.102765, -0.00300497)
|
||||
@@ -1241,10 +1240,8 @@ region_rect = Rect2(52, 20, 648, 1175)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.119886, 0)
|
||||
shape = SubResource("CapsuleShape3D_1vdrh")
|
||||
|
||||
[node name="CameraPivot2" type="Node3D" parent="CharacterBody3D" node_paths=PackedStringArray("_subPivot")]
|
||||
[node name="CameraPivot2" type="Node3D" parent="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.159723, 0)
|
||||
script = ExtResource("3_3trg2")
|
||||
_subPivot = NodePath("SubPivot")
|
||||
|
||||
[node name="SubPivot" type="Node3D" parent="CharacterBody3D/CameraPivot2"]
|
||||
|
||||
@@ -1261,6 +1258,15 @@ billboard = 1
|
||||
render_priority = 51
|
||||
texture = ExtResource("4_kngqo")
|
||||
|
||||
[node name="Watering can" type="Sprite3D" parent="CharacterBody3D/Farming"]
|
||||
visible = false
|
||||
pixel_size = 0.002
|
||||
billboard = 1
|
||||
render_priority = 51
|
||||
texture = ExtResource("5_pkl5l")
|
||||
region_enabled = true
|
||||
region_rect = Rect2(-2, 1135, 425, 291)
|
||||
|
||||
[node name="Front" type="Node3D" parent="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.001, 0.1, 0.003)
|
||||
|
||||
@@ -1330,3 +1336,11 @@ render_priority = 50
|
||||
sprite_frames = SubResource("SpriteFrames_4q8ml")
|
||||
autoplay = "default"
|
||||
frame_progress = 0.481133
|
||||
|
||||
[node name="FarmingControls" type="Node3D" parent="." node_paths=PackedStringArray("_hoeSprite", "_wateringCanSprite", "_movingPlayer")]
|
||||
script = ExtResource("4_q5t2e")
|
||||
_hoeSprite = NodePath("../CharacterBody3D/Farming/Hoe")
|
||||
_wateringCanSprite = NodePath("../CharacterBody3D/Farming/Watering can")
|
||||
_fieldPrefab = ExtResource("2_oq5hi")
|
||||
_movingPlayer = NodePath("../CharacterBody3D")
|
||||
metadata/_custom_type_script = "uid://b1sscdr4ptec8"
|
||||
|
||||
@@ -42,6 +42,7 @@ columns = 10
|
||||
[node name="SlotSelectContainer" type="Control" parent="SlotsContainer"]
|
||||
custom_minimum_size = Vector2(1000, 100)
|
||||
layout_mode = 1
|
||||
anchors_preset = 7
|
||||
anchor_left = 0.5
|
||||
anchor_top = 1.0
|
||||
anchor_right = 0.5
|
||||
|
||||
@@ -41,4 +41,22 @@ label_settings = SubResource("LabelSettings_7emux")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="AmountLabel" type="Label" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = -1
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -409.0
|
||||
offset_top = -329.0
|
||||
offset_right = -10.0
|
||||
offset_bottom = -10.0
|
||||
grow_horizontal = 0
|
||||
grow_vertical = 0
|
||||
theme_override_colors/font_color = Color(0, 0, 0, 1)
|
||||
text = "999"
|
||||
horizontal_alignment = 2
|
||||
vertical_alignment = 2
|
||||
|
||||
[connection signal="gui_input" from="." to="." method="_on_gui_input"]
|
||||
|
||||
@@ -19,7 +19,7 @@ _showLabel = false
|
||||
shape = SubResource("SphereShape3D_u7egi")
|
||||
|
||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||
transform = Transform3D(0.5, 0, 0, 0, -2.18557e-08, -0.5, 0, 0.5, -2.18557e-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
|
||||
texture = ExtResource("1_2cisk")
|
||||
script = ExtResource("2_u7egi")
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://5hltxpdxmqcq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://udhigottc8rg" path="res://scripts/CSharp/Common/Inventory/ItemOnGround.cs" id="1_mnomu"]
|
||||
[ext_resource type="PackedScene" uid="uid://ob04y3syvo0e" path="res://prefabs/interaction_area.tscn" id="2_ue6ub"]
|
||||
[ext_resource type="Script" uid="uid://c8suoi3i6kqai" path="res://scripts/CSharp/Common/Inventory/ItemOnGroundSpawnWith.cs" id="3_ue6ub"]
|
||||
[ext_resource type="Resource" uid="uid://c7viddcd3kywp" path="res://resources/items/axe.tres" id="4_sfad0"]
|
||||
|
||||
[node name="GenericItemOnGround" type="Node3D"]
|
||||
script = ExtResource("1_mnomu")
|
||||
|
||||
[node name="InteractionArea" parent="." instance=ExtResource("2_ue6ub")]
|
||||
|
||||
[node name="SpawnWithItem" type="Node" parent="."]
|
||||
script = ExtResource("3_ue6ub")
|
||||
_blueprint = ExtResource("4_sfad0")
|
||||
|
||||
[node name="ItemLabel" type="Label3D" parent="."]
|
||||
offset = Vector2(0, 55.64)
|
||||
billboard = 1
|
||||
text = "test"
|
||||
|
||||
[node name="PickupErrorLabel" type="Label3D" parent="."]
|
||||
offset = Vector2(0, 150)
|
||||
billboard = 1
|
||||
|
||||
[connection signal="Interacted" from="InteractionArea" to="." method="TryPickUp"]
|
||||
@@ -13,17 +13,17 @@ emission = Color(1, 1, 1, 1)
|
||||
|
||||
[node name="SpriteSwitcher" type="Node3D" node_paths=PackedStringArray("_trueSprite", "_falseSprite")]
|
||||
script = ExtResource("1_scmhv")
|
||||
_trueSprite = NodePath("Hoe on")
|
||||
_falseSprite = NodePath("Hoe off")
|
||||
_trueSprite = NodePath("On Sprite")
|
||||
_falseSprite = NodePath("Off Sprite")
|
||||
|
||||
[node name="Hoe on" type="Sprite3D" parent="."]
|
||||
[node name="On Sprite" type="Sprite3D" parent="."]
|
||||
modulate = Color(0, 0.996078, 0, 1)
|
||||
pixel_size = 0.001
|
||||
billboard = 1
|
||||
texture = ExtResource("2_jv400")
|
||||
region_rect = Rect2(484, 143, 365, 1317)
|
||||
|
||||
[node name="Hoe off" type="Sprite3D" parent="."]
|
||||
[node name="Off Sprite" type="Sprite3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, -8.47033e-22, 0, 8.47033e-22, 1, 0.106585, 0, 0.0173626)
|
||||
visible = false
|
||||
modulate = Color(1, 0, 0, 1)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bs3vs05wp5a20"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cpbv0b3ahorep" path="res://scripts/CSharp/Common/WorldManagement/WorldChangeTrigger.cs" id="1_wqqyh"]
|
||||
|
||||
[node name="WorldChangeTrigger" type="Area3D"]
|
||||
script = ExtResource("1_wqqyh")
|
||||
+2
-2
@@ -11,7 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="Babushka"
|
||||
run/main_scene="uid://br7yq757cawts"
|
||||
run/main_scene="uid://dbgkbil1ultks"
|
||||
config/features=PackedStringArray("4.4", "C#", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
@@ -129,7 +129,7 @@ interact={
|
||||
}
|
||||
ui_inventory_open_close={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":73,"key_label":0,"unicode":105,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
ui_inventory_advance={
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
script = ExtResource("1_t485b")
|
||||
name = "Axe Deo"
|
||||
color = Color(0.643898, 0.4587, 0.294335, 1)
|
||||
maxStack = 1
|
||||
metadata/_custom_type_script = "uid://cbskymrxs6ksu"
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
script = ExtResource("1_8k5aa")
|
||||
name = "Buck the Bucket"
|
||||
color = Color(0.336269, 0.489145, 0.825324, 1)
|
||||
maxStack = 1
|
||||
metadata/_custom_type_script = "uid://cbskymrxs6ksu"
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
script = ExtResource("1_06nef")
|
||||
name = "Your Mom"
|
||||
color = Color(0.751421, 0.329615, 0.570911, 1)
|
||||
maxStack = 1
|
||||
metadata/_custom_type_script = "uid://cbskymrxs6ksu"
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
script = ExtResource("1_07aya")
|
||||
name = "Pick Axe"
|
||||
color = Color(0.589014, 0.823353, 0.998475, 1)
|
||||
maxStack = 1
|
||||
metadata/_custom_type_script = "uid://cbskymrxs6ksu"
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://d1uuxp1lp4aro"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cbskymrxs6ksu" path="res://scripts/CSharp/Common/Inventory/ItemResource.cs" id="1_dustj"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_dustj")
|
||||
name = "Tomato Seed"
|
||||
color = Color(0.135039, 0.307214, 0.333128, 1)
|
||||
maxStack = 20
|
||||
metadata/_custom_type_script = "uid://cbskymrxs6ksu"
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="SpawnPointResource" load_steps=2 format=3 uid="uid://cipetn2hmnew4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cjr2efpm660kr" path="res://scripts/CSharp/Common/WorldManagement/SpawnPointResource.cs" id="1_ymkjy"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ymkjy")
|
||||
name = ""
|
||||
metadata/_custom_type_script = "uid://cjr2efpm660kr"
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="SpawnPointResource" load_steps=2 format=3 uid="uid://daow8nx85vuc8"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cjr2efpm660kr" path="res://scripts/CSharp/Common/WorldManagement/SpawnPointResource.cs" id="1_kdbco"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_kdbco")
|
||||
name = "GameStart"
|
||||
metadata/_custom_type_script = "uid://cjr2efpm660kr"
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="SpawnPointResource" load_steps=2 format=3 uid="uid://dissbtj4nflu5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cjr2efpm660kr" path="res://scripts/CSharp/Common/WorldManagement/SpawnPointResource.cs" id="1_vyl4c"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_vyl4c")
|
||||
name = "tmp1"
|
||||
metadata/_custom_type_script = "uid://cjr2efpm660kr"
|
||||
@@ -1,10 +1,12 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://br7yq757cawts"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://br7yq757cawts"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dbd1niu3tp8y5" path="res://prefabs/Player3D.tscn" id="1_b1ibi"]
|
||||
[ext_resource type="PackedScene" uid="uid://biwd3jj65qrlh" path="res://prefabs/farming/base_field.tscn" id="2_72r8y"]
|
||||
[ext_resource type="PackedScene" uid="uid://ob04y3syvo0e" path="res://prefabs/interaction_area.tscn" id="4_r4sre"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgjc4wurbgimy" path="res://prefabs/UI/Inventory/Inventory.tscn" id="5_obfp0"]
|
||||
[ext_resource type="Texture2D" uid="uid://x8hr8287ff2n" path="res://art/farm/farming/farmobjekte/tools atlas.png" id="5_r4sre"]
|
||||
[ext_resource type="PackedScene" uid="uid://cf0jpuio8tgim" path="res://prefabs/interactions/sprite_switcher.tscn" id="6_r4sre"]
|
||||
[ext_resource type="Script" uid="uid://c6hh7m8wikv04" path="res://scripts/CSharp/Common/Farming/FieldService.cs" id="7_0ptl4"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_8yprl"]
|
||||
|
||||
@@ -34,13 +36,14 @@ shape = SubResource("BoxShape3D_t58di")
|
||||
|
||||
[node name="Player3d" parent="." node_paths=PackedStringArray("_fieldParent") instance=ExtResource("1_b1ibi")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.51633, 0.725631, 3.57249)
|
||||
_fieldParent = NodePath("../FieldParent")
|
||||
_fieldParent = NodePath("../FieldService")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.618408, 0.785857, 0, -0.785857, 0.618408, -0.802612, 0, 4.73262)
|
||||
|
||||
[node name="BaseField" parent="." instance=ExtResource("2_72r8y")]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.001, 0)
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.0574723, 0)
|
||||
visible = false
|
||||
|
||||
[node name="HoePickup" parent="." instance=ExtResource("4_r4sre")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, -1.06581e-14, 0, 1.06581e-14, 1, -4.327, 1.5, -3.447)
|
||||
@@ -50,8 +53,36 @@ shape = SubResource("SphereShape3D_0ptl4")
|
||||
|
||||
[node name="SpriteSwitcher Hoe" parent="HoePickup" instance=ExtResource("6_r4sre")]
|
||||
|
||||
[node name="FieldParent" type="Node3D" parent="."]
|
||||
[node name="Watering Can Pickup" parent="." instance=ExtResource("4_r4sre")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, -1.06581e-14, 0, 1.06581e-14, 1, -2.3908, 1.5, -3.447)
|
||||
|
||||
[node name="CollisionShape3D" parent="Watering Can Pickup/Area3D" index="0"]
|
||||
shape = SubResource("SphereShape3D_0ptl4")
|
||||
|
||||
[node name="SpriteSwitcher Hoe" parent="Watering Can Pickup" instance=ExtResource("6_r4sre")]
|
||||
|
||||
[node name="On Sprite" parent="Watering Can Pickup/SpriteSwitcher Hoe" index="0"]
|
||||
texture = ExtResource("5_r4sre")
|
||||
region_enabled = true
|
||||
region_rect = Rect2(-3, 1141, 423, 280)
|
||||
|
||||
[node name="Off Sprite" parent="Watering Can Pickup/SpriteSwitcher Hoe" index="1"]
|
||||
texture = ExtResource("5_r4sre")
|
||||
region_enabled = true
|
||||
region_rect = Rect2(-3, 1137, 424, 285)
|
||||
|
||||
[node name="Inventory" parent="." instance=ExtResource("5_obfp0")]
|
||||
visible = false
|
||||
|
||||
[node name="FieldService" type="Node3D" parent="."]
|
||||
script = ExtResource("7_0ptl4")
|
||||
metadata/_custom_type_script = "uid://c6hh7m8wikv04"
|
||||
|
||||
[connection signal="Interacted" from="HoePickup" to="HoePickup/SpriteSwitcher Hoe" method="SwitchState"]
|
||||
[connection signal="Switch" from="HoePickup/SpriteSwitcher Hoe" to="Player3d" method="ActivateHoe"]
|
||||
[connection signal="Interacted" from="Watering Can Pickup" to="Watering Can Pickup/SpriteSwitcher Hoe" method="SwitchState"]
|
||||
[connection signal="Switch" from="Watering Can Pickup/SpriteSwitcher Hoe" to="Player3d" method="ActivateWateringCan"]
|
||||
|
||||
[editable path="HoePickup"]
|
||||
[editable path="Watering Can Pickup"]
|
||||
[editable path="Watering Can Pickup/SpriteSwitcher Hoe"]
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dbgkbil1ultks"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://g338f4yomfo3" path="res://scripts/CSharp/Common/WorldManagement/WorldContainer.cs" id="1_l112d"]
|
||||
[ext_resource type="PackedScene" uid="uid://dbxy2y85r1d8x" path="res://scenes/worlds/Babushka_world_item_pickup_testing.tscn" id="2_akoq3"]
|
||||
[ext_resource type="PackedScene" uid="uid://dbd1niu3tp8y5" path="res://prefabs/Player3D.tscn" id="2_l45op"]
|
||||
[ext_resource type="Resource" uid="uid://daow8nx85vuc8" path="res://resources/spawnpoints/spawnpoint_game_start.tres" id="3_4ix36"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgjc4wurbgimy" path="res://prefabs/UI/Inventory/Inventory.tscn" id="3_akoq3"]
|
||||
|
||||
[node name="BabushkaSceneMain" type="Node"]
|
||||
|
||||
[node name="WorldContainer" type="Node" parent="."]
|
||||
script = ExtResource("1_l112d")
|
||||
startingWorld = ExtResource("2_akoq3")
|
||||
startingSpawnPoint = ExtResource("3_4ix36")
|
||||
|
||||
[node name="Player3d" parent="." instance=ExtResource("2_l45op")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.51633, 0.725631, 3.57249)
|
||||
|
||||
[node name="Inventory" parent="." instance=ExtResource("3_akoq3")]
|
||||
|
||||
[connection signal="WorldChanged" from="WorldContainer" to="Player3d" method="TeleportTo"]
|
||||
@@ -0,0 +1,99 @@
|
||||
[gd_scene load_steps=17 format=3 uid="uid://dbxy2y85r1d8x"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://6aq8mr0sofrs" path="res://scripts/CSharp/Common/WorldManagement/World.cs" id="1_jnel3"]
|
||||
[ext_resource type="PackedScene" uid="uid://biwd3jj65qrlh" path="res://prefabs/farming/base_field.tscn" id="2_741gk"]
|
||||
[ext_resource type="PackedScene" uid="uid://5hltxpdxmqcq" path="res://prefabs/interactions/generic_item_on_ground.tscn" id="5_sjt6k"]
|
||||
[ext_resource type="Resource" uid="uid://cndd64batns31" path="res://resources/items/bucket.tres" id="6_nvnpb"]
|
||||
[ext_resource type="Script" uid="uid://12hleqx8amr8" 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://d1uuxp1lp4aro" path="res://resources/items/tomato_seed.tres" id="8_hv2km"]
|
||||
[ext_resource type="Script" uid="uid://c7eaa0neniiss" path="res://scripts/CSharp/Common/WorldManagement/SpawnPointMarker.cs" id="8_w0pbi"]
|
||||
[ext_resource type="Resource" uid="uid://daow8nx85vuc8" path="res://resources/spawnpoints/spawnpoint_game_start.tres" id="9_sal3e"]
|
||||
[ext_resource type="Resource" uid="uid://cipetn2hmnew4" path="res://resources/spawnpoints/from_test_scene.tres" id="10_sal3e"]
|
||||
[ext_resource type="PackedScene" uid="uid://bs3vs05wp5a20" path="res://prefabs/world_elements/world_change_trigger.tscn" id="11_43jow"]
|
||||
[ext_resource type="PackedScene" uid="uid://cidjhvp38n4b4" path="res://scenes/worlds/babushka_world_level_change_test.tscn" id="12_oux87"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_8yprl"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8tgff"]
|
||||
albedo_color = Color(0.505882, 0.588235, 0.494118, 1)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_t58di"]
|
||||
size = Vector3(2.01563, 0.160522, 2.00824)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_oux87"]
|
||||
size = Vector3(1, 1, 2.94604)
|
||||
|
||||
[node name="WorldItemPickupTest" type="Node3D"]
|
||||
script = ExtResource("1_jnel3")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0)
|
||||
mesh = SubResource("PlaneMesh_8yprl")
|
||||
skeleton = NodePath("")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_8tgff")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000976563, -0.0739136, -0.00112915)
|
||||
shape = SubResource("BoxShape3D_t58di")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.618408, 0.785857, 0, -0.785857, 0.618408, -0.802612, 0, 4.73262)
|
||||
|
||||
[node name="BaseField" parent="." instance=ExtResource("2_741gk")]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.0574723, 0)
|
||||
visible = false
|
||||
|
||||
[node name="FieldService" type="Node3D" parent="."]
|
||||
script = ExtResource("7_3rkjv")
|
||||
|
||||
[node name="GenericItemOnGround" parent="." instance=ExtResource("5_sjt6k")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.53971, -4.76837e-07, -3.81996)
|
||||
|
||||
[node name="SpawnWithItem" parent="GenericItemOnGround" index="1"]
|
||||
_blueprint = ExtResource("6_nvnpb")
|
||||
|
||||
[node name="GenericItemOnGround2" parent="." instance=ExtResource("5_sjt6k")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.73646, -9.53674e-07, -3.96783)
|
||||
|
||||
[node name="GenericItemOnGround3" parent="." instance=ExtResource("5_sjt6k")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.43861, -4.76837e-07, -3.93506)
|
||||
|
||||
[node name="SpawnWithItem" parent="GenericItemOnGround3" index="1"]
|
||||
_blueprint = ExtResource("7_hv2km")
|
||||
|
||||
[node name="GenericItemOnGround4" parent="." instance=ExtResource("5_sjt6k")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6.1678, -4.76837e-07, -3.94977)
|
||||
_infiniteSupply = true
|
||||
|
||||
[node name="SpawnWithItem" parent="GenericItemOnGround4" index="1"]
|
||||
_blueprint = ExtResource("8_hv2km")
|
||||
|
||||
[node name="Spawnpoint" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.87715, 0, 1.54015)
|
||||
script = ExtResource("8_w0pbi")
|
||||
spawnPointResource = ExtResource("9_sal3e")
|
||||
|
||||
[node name="Spawnpoint tmp" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.3672, 0, 0.113484)
|
||||
script = ExtResource("8_w0pbi")
|
||||
spawnPointResource = ExtResource("10_sal3e")
|
||||
|
||||
[node name="WorldChangeTrigger" parent="." instance=ExtResource("11_43jow")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.78829, 0.546566, -0.241783)
|
||||
collision_mask = 17
|
||||
switchToWorld = ExtResource("12_oux87")
|
||||
switchToSpawnPoint = ExtResource("10_sal3e")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="WorldChangeTrigger"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.193655, 0, 0.233521)
|
||||
shape = SubResource("BoxShape3D_oux87")
|
||||
|
||||
[connection signal="area_entered" from="WorldChangeTrigger" to="WorldChangeTrigger" method="AreaEnteredHandler"]
|
||||
|
||||
[editable path="GenericItemOnGround"]
|
||||
[editable path="GenericItemOnGround2"]
|
||||
[editable path="GenericItemOnGround3"]
|
||||
[editable path="GenericItemOnGround4"]
|
||||
@@ -0,0 +1,56 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://cidjhvp38n4b4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://6aq8mr0sofrs" path="res://scripts/CSharp/Common/WorldManagement/World.cs" id="1_nat7a"]
|
||||
[ext_resource type="PackedScene" uid="uid://bs3vs05wp5a20" path="res://prefabs/world_elements/world_change_trigger.tscn" id="5_tb7xe"]
|
||||
[ext_resource type="PackedScene" uid="uid://dbxy2y85r1d8x" path="res://scenes/worlds/Babushka_world_item_pickup_testing.tscn" id="6_evakd"]
|
||||
[ext_resource type="Script" uid="uid://c7eaa0neniiss" path="res://scripts/CSharp/Common/WorldManagement/SpawnPointMarker.cs" id="8_pl6uc"]
|
||||
[ext_resource type="Resource" uid="uid://daow8nx85vuc8" path="res://resources/spawnpoints/spawnpoint_game_start.tres" id="9_rutwt"]
|
||||
[ext_resource type="Resource" uid="uid://cipetn2hmnew4" path="res://resources/spawnpoints/from_test_scene.tres" id="10_s5gm8"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_8yprl"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_8tgff"]
|
||||
albedo_color = Color(0.505882, 0.588235, 0.494118, 1)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_t58di"]
|
||||
size = Vector3(2.01563, 0.160522, 2.00824)
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_tydq3"]
|
||||
size = Vector3(1, 1, 6.21814)
|
||||
|
||||
[node name="WorldItemPickupTest" type="Node3D"]
|
||||
script = ExtResource("1_nat7a")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0)
|
||||
mesh = SubResource("PlaneMesh_8yprl")
|
||||
skeleton = NodePath("")
|
||||
surface_material_override/0 = SubResource("StandardMaterial3D_8tgff")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="MeshInstance3D"]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="MeshInstance3D/StaticBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000976563, -0.0739136, -0.00112915)
|
||||
shape = SubResource("BoxShape3D_t58di")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.618408, 0.785857, 0, -0.785857, 0.618408, -0.802612, 0, 4.73262)
|
||||
|
||||
[node name="Spawnpoint" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.87715, 0, 1.54015)
|
||||
script = ExtResource("8_pl6uc")
|
||||
spawnPointResource = ExtResource("9_rutwt")
|
||||
|
||||
[node name="Spawnpoint tmp" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.00564, 0, 0.0870138)
|
||||
script = ExtResource("8_pl6uc")
|
||||
spawnPointResource = ExtResource("10_s5gm8")
|
||||
|
||||
[node name="WorldChangeTrigger" parent="." instance=ExtResource("5_tb7xe")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9.82414, 0, 0)
|
||||
switchToWorld = ExtResource("6_evakd")
|
||||
switchToSpawnPoint = ExtResource("10_s5gm8")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="WorldChangeTrigger"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.235657)
|
||||
shape = SubResource("BoxShape3D_tydq3")
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
@@ -17,21 +18,25 @@ public partial class Player3D : CharacterBody3D
|
||||
[Export] private AnimatedSprite3D[] _backSpritesAnimated;
|
||||
|
||||
private bool _sideFlipped;
|
||||
private Vector2 _lastDirection;
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
{
|
||||
var inputDir = Input.GetVector("move_left", "move_right", "move_up", "move_down");
|
||||
var inputDir = Input.GetVector("move_left", "move_right", "move_down", "move_up");
|
||||
if (inputDir == Vector2.Zero)
|
||||
{
|
||||
if(_lastDirection != Vector2.Zero)
|
||||
SwitchIdleSprites();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
MoveOnInput(inputDir, delta);
|
||||
SwitchSprites(inputDir);
|
||||
SwitchMovementSprites(inputDir);
|
||||
}
|
||||
|
||||
private void MoveOnInput(Vector2 inputDir, double delta)
|
||||
{
|
||||
inputDir = inputDir.Rotated(-_camera.GlobalRotation.Y);
|
||||
var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y)).Normalized();
|
||||
var direction = (Transform.Basis * new Vector3(inputDir.X, 0, inputDir.Y * (-1))).Normalized();
|
||||
if (direction != Vector3.Zero)
|
||||
Velocity = new Vector3(direction.X * _speed * (float) delta * Scale.X, Velocity.Y, direction.Z * _speed * (float) delta * Scale.Z);
|
||||
else
|
||||
@@ -40,20 +45,33 @@ public partial class Player3D : CharacterBody3D
|
||||
MoveAndSlide();
|
||||
}
|
||||
|
||||
private void SwitchSprites(Vector2 inputDir)
|
||||
private void SwitchIdleSprites()
|
||||
{
|
||||
float X = inputDir.X;
|
||||
float Y = inputDir.Y;
|
||||
|
||||
if (X == 0.0 && Y == 0.0)
|
||||
if (_lastDirection.X != 0)
|
||||
{
|
||||
ActivateFrontSpriteIdle(0, true, false, false);
|
||||
ActivateSprite(0, false, true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(_lastDirection.Y <= 0.0f)
|
||||
ActivateSprite(0, true, false, false);
|
||||
|
||||
if(_lastDirection.Y > 0.0f)
|
||||
ActivateSprite(0, false, false, true);
|
||||
|
||||
_lastDirection = Vector2.Zero;
|
||||
}
|
||||
|
||||
private void SwitchMovementSprites(Vector2 inputDir)
|
||||
{
|
||||
float X = inputDir.X;
|
||||
float Y = inputDir.Y;
|
||||
|
||||
_lastDirection = new Vector2(X, Y);
|
||||
|
||||
if (X != 0)
|
||||
{
|
||||
ActivateFrontSpriteIdle(1, false, true, false);
|
||||
ActivateSprite(1, false, true, false);
|
||||
|
||||
if (X > 0.0f)
|
||||
{
|
||||
@@ -74,20 +92,19 @@ public partial class Player3D : CharacterBody3D
|
||||
|
||||
if (Y != 0)
|
||||
{
|
||||
if (Y < 0.0f)
|
||||
{
|
||||
ActivateFrontSpriteIdle(1, false, false, true);
|
||||
}
|
||||
|
||||
if (Y > 0.0f)
|
||||
{
|
||||
ActivateFrontSpriteIdle(0, true, false, false);
|
||||
ActivateSprite(1, false, false, true);
|
||||
}
|
||||
|
||||
if (Y < 0.0f)
|
||||
{
|
||||
ActivateSprite(1, true, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ActivateFrontSpriteIdle(int index, bool frontActive, bool sideActive, bool backActive)
|
||||
private void ActivateSprite(int index, bool frontActive, bool sideActive, bool backActive)
|
||||
{
|
||||
DeactivateAll();
|
||||
_frontSpritesAnimated[index].Visible = frontActive;
|
||||
@@ -112,5 +129,11 @@ public partial class Player3D : CharacterBody3D
|
||||
animatedSprite.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Teleport(Vector3 newPosition)
|
||||
{
|
||||
GlobalPosition = newPosition;
|
||||
ResetPhysicsInterpolation();
|
||||
GD.Print("Player Teleported");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
using Babushka.scripts.CSharp.Common.Farming;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.CharacterControls;
|
||||
|
||||
public partial class VesnaBehaviour : Node
|
||||
{
|
||||
[ExportGroup("Farming")]
|
||||
[Export] private FieldService _fieldParent;
|
||||
[Export] private FarmingControls _farmingControls;
|
||||
|
||||
[Signal] public delegate void ToolPickupEventHandler(bool success);
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_farmingControls.FieldParent = _fieldParent;
|
||||
}
|
||||
|
||||
public void TeleportTo(Vector3 newPosition)
|
||||
{
|
||||
GetNode<Player3D>("CharacterBody3D").Teleport(newPosition);
|
||||
}
|
||||
|
||||
#region Farming
|
||||
|
||||
public void ActivateHoe(bool activate)
|
||||
{
|
||||
ActivateTool(activate, 0);
|
||||
}
|
||||
|
||||
public void ActivateWateringCan(bool activate)
|
||||
{
|
||||
ActivateTool(activate, 1);
|
||||
}
|
||||
|
||||
private void ActivateTool(bool activate , int toolId)
|
||||
{
|
||||
bool success = false;
|
||||
if (toolId == 0)
|
||||
{
|
||||
success = _farmingControls.ActivateHoe(activate);
|
||||
}
|
||||
else if (toolId == 1)
|
||||
{
|
||||
success = _farmingControls.ActivateWateringCan(activate);
|
||||
}
|
||||
EmitSignal(SignalName.ToolPickup, success);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://xm0um640aes7
|
||||
@@ -1,20 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class FarmingControls : Node3D
|
||||
{
|
||||
[Export] private Sprite3D _hoeSprite;
|
||||
[Export] private Sprite3D _wateringCanSprite;
|
||||
[Export] private PackedScene _fieldPrefab;
|
||||
[Export] private Node _fieldParent;
|
||||
[Export] private Node3D _movingPlayer;
|
||||
|
||||
public FieldService FieldParent;
|
||||
|
||||
private bool _hoeInHand = false;
|
||||
public void ActivateHoe(bool activate)
|
||||
private bool _waterCanInHand = false;
|
||||
|
||||
#region Tools
|
||||
|
||||
public bool ActivateHoe(bool activate)
|
||||
{
|
||||
_hoeSprite.Visible = !activate;
|
||||
_hoeInHand = !activate;
|
||||
bool success = ActivateTool(activate, _hoeSprite);
|
||||
_hoeInHand = success;
|
||||
return success;
|
||||
}
|
||||
|
||||
public bool ActivateWateringCan(bool activate)
|
||||
{
|
||||
bool success = ActivateTool(activate, _wateringCanSprite);
|
||||
_waterCanInHand = success;
|
||||
return success;
|
||||
}
|
||||
|
||||
private bool ActivateTool(bool activate, Sprite3D tool)
|
||||
{
|
||||
tool.Visible = !activate;
|
||||
return !activate;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
@@ -22,22 +46,41 @@ public partial class FarmingControls : Node3D
|
||||
{
|
||||
MakeField();
|
||||
}
|
||||
|
||||
if (@event.IsActionPressed("click") && _waterCanInHand)
|
||||
{
|
||||
WaterTheField();
|
||||
}
|
||||
}
|
||||
|
||||
private void WaterTheField()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void MakeField()
|
||||
{
|
||||
if(_fieldParent == null || _fieldPrefab == null)
|
||||
if(FieldParent == null || _fieldPrefab == null)
|
||||
return;
|
||||
|
||||
Node fieldInstance = _fieldPrefab.Instantiate();
|
||||
|
||||
if (fieldInstance is Node3D field3d)
|
||||
{
|
||||
field3d.Position = _movingPlayer.GlobalPosition;
|
||||
Vector3 playerPos = _movingPlayer.GlobalPosition;
|
||||
playerPos = new Vector3(AdjustValue(playerPos.X), 0.1f, AdjustValue(playerPos.Z));
|
||||
field3d.Position = playerPos;
|
||||
Vector2I intPosition = new Vector2I((int) playerPos.X, (int) playerPos.Z);
|
||||
FieldParent.AddEntry(intPosition, FieldState.Tilled);
|
||||
}
|
||||
|
||||
_fieldParent.AddChild(fieldInstance);
|
||||
|
||||
|
||||
FieldParent.AddChild(fieldInstance);
|
||||
}
|
||||
|
||||
private float AdjustValue(float value)
|
||||
{
|
||||
return Mathf.Floor(value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,14 +13,22 @@ public enum FieldState
|
||||
public partial class FieldBehaviour : Sprite3D
|
||||
{
|
||||
[Export] private Texture2D Tilled;
|
||||
[Export] private Texture3D Watered;
|
||||
[Export] private Texture2D Watered;
|
||||
[Export] private FieldState FieldState = FieldState.Empty;
|
||||
|
||||
public Vector2 FieldPosition;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Texture = Tilled;
|
||||
base._Ready();
|
||||
}
|
||||
|
||||
public void Water()
|
||||
{
|
||||
FieldState = FieldState.Watered;
|
||||
Texture = Watered;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the player enters the field'S interaction area and presses <E>.
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class FieldService : Node3D
|
||||
{
|
||||
[Export] private Dictionary<Vector2I, FieldState> fields = new Dictionary<Vector2I, FieldState>();
|
||||
|
||||
//Create
|
||||
|
||||
public void AddEntry(Vector2I key, FieldState state)
|
||||
{
|
||||
fields.Add(key, state);
|
||||
}
|
||||
|
||||
// Read
|
||||
|
||||
public FieldState Get(Vector2I key)
|
||||
{
|
||||
return fields[key];
|
||||
}
|
||||
|
||||
//Update
|
||||
public void UpdateEntry(Vector2I fieldPosition, FieldState state)
|
||||
{
|
||||
if (fields.ContainsKey(fieldPosition))
|
||||
{
|
||||
fields[fieldPosition] = state;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddEntry(fieldPosition, state);
|
||||
}
|
||||
}
|
||||
|
||||
//Delete
|
||||
|
||||
public void RemoveEntry(Vector2I fieldPosition)
|
||||
{
|
||||
if (fields.ContainsKey(fieldPosition))
|
||||
{
|
||||
fields.Remove(fieldPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://12hleqx8amr8
|
||||
@@ -12,6 +12,7 @@ public partial class InventoryInstance : Node
|
||||
|
||||
[Signal]
|
||||
public delegate void SlotAmountChangedEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void InventoryContentsChangedEventHandler();
|
||||
|
||||
@@ -32,54 +33,99 @@ public partial class InventoryInstance : Node
|
||||
_slots.Add(new InventorySlot());
|
||||
}
|
||||
}
|
||||
|
||||
EmitSignal(SignalName.SlotAmountChanged);
|
||||
}
|
||||
}
|
||||
|
||||
public InventoryActionResult AddItem(ItemInstance newItem, int inventorySlot = -1)
|
||||
|
||||
public InventoryActionResult AddItem(ItemInstance newItem)
|
||||
{
|
||||
if (inventorySlot < 0)
|
||||
var result = AddItemAndStackRecursive(newItem, 0);
|
||||
EmitSignal(SignalName.InventoryContentsChanged);
|
||||
return result;
|
||||
}
|
||||
|
||||
private InventoryActionResult AddItemAndStackRecursive(ItemInstance newItem, int slotSearch)
|
||||
{
|
||||
if (newItem.blueprint == null || newItem.amount == 0)
|
||||
return InventoryActionResult.SourceDoesNotExists;
|
||||
|
||||
var slotIndex = -1;
|
||||
// find stackable slot
|
||||
for (var i = slotSearch; i < _slots.Count; i++)
|
||||
{
|
||||
inventorySlot = _slots.FindIndex(slot => slot.IsEmpty());
|
||||
if (_slots[i].itemInstance?.blueprint == newItem.blueprint)
|
||||
{
|
||||
slotIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (inventorySlot < 0 || !_slots[inventorySlot].IsEmpty())
|
||||
|
||||
if (slotIndex < 0)
|
||||
{
|
||||
// find empty slot
|
||||
for (var i = slotSearch; i < _slots.Count; i++)
|
||||
{
|
||||
if (_slots[i].IsEmpty())
|
||||
{
|
||||
slotIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (slotIndex < 0)
|
||||
{
|
||||
return InventoryActionResult.DestinationFull;
|
||||
}
|
||||
|
||||
if (inventorySlot >= _slots.Count)
|
||||
{
|
||||
return InventoryActionResult.DestinationDoesNotExists;
|
||||
}
|
||||
|
||||
_slots[inventorySlot].itemInstance = newItem;
|
||||
EmitSignal(SignalName.InventoryContentsChanged);
|
||||
return InventoryActionResult.Success;
|
||||
|
||||
var itemInstance = _slots[slotIndex].itemInstance ?? new ItemInstance { blueprint = newItem.blueprint, amount = 0 };
|
||||
var maxStack = itemInstance!.blueprint.maxStack;
|
||||
var freeOnStack = maxStack - itemInstance.amount;
|
||||
var moveAmount = Math.Min(freeOnStack, newItem.amount);
|
||||
itemInstance.amount += moveAmount;
|
||||
newItem.amount -= moveAmount;
|
||||
_slots[slotIndex].itemInstance = itemInstance;
|
||||
return newItem.amount <= 0
|
||||
? InventoryActionResult.Success
|
||||
: AddItemAndStackRecursive(newItem, slotIndex + 1);
|
||||
}
|
||||
|
||||
public InventoryActionResult RemoveItem(int inventorySlot, out ItemInstance? itemInstance )
|
||||
|
||||
public InventoryActionResult RemoveItem(int inventorySlot, out ItemInstance? itemInstance)
|
||||
{
|
||||
if (inventorySlot < 0 || inventorySlot >= _slots.Count)
|
||||
{
|
||||
itemInstance = null;
|
||||
return InventoryActionResult.SourceDoesNotExists;
|
||||
}
|
||||
|
||||
|
||||
if (_slots[inventorySlot].IsEmpty())
|
||||
{
|
||||
itemInstance = null;
|
||||
return InventoryActionResult.SourceIsEmpty;
|
||||
}
|
||||
|
||||
|
||||
itemInstance = _slots[inventorySlot].itemInstance;
|
||||
_slots[inventorySlot].itemInstance = null;
|
||||
EmitSignal(SignalName.InventoryContentsChanged);
|
||||
return InventoryActionResult.Success;
|
||||
}
|
||||
|
||||
|
||||
public InventoryActionResult RemoveItem(int inventorySlot)
|
||||
{
|
||||
return RemoveItem(inventorySlot, out _);
|
||||
}
|
||||
}
|
||||
|
||||
public InventoryActionResult AddItemToSlot(ItemInstance itemInstance, int destinationSlot)
|
||||
{
|
||||
if (destinationSlot < 0 || destinationSlot >= _slots.Count)
|
||||
return InventoryActionResult.DestinationDoesNotExists;
|
||||
|
||||
if (!_slots[destinationSlot].IsEmpty())
|
||||
return InventoryActionResult.DestinationFull;
|
||||
|
||||
_slots[destinationSlot].itemInstance = itemInstance;
|
||||
EmitSignal(SignalName.InventoryContentsChanged);
|
||||
return InventoryActionResult.Success;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
public partial class InventoryManager : Node
|
||||
{
|
||||
public static InventoryManager Instance { get; private set; }
|
||||
|
||||
|
||||
public InventoryInstance playerInventory;
|
||||
|
||||
public override void _EnterTree()
|
||||
@@ -23,11 +23,13 @@ public partial class InventoryManager : Node
|
||||
public InventoryActionResult CreateItem(
|
||||
ItemResource itemBlueprint,
|
||||
InventoryInstance inventory,
|
||||
int amount = 1,
|
||||
int inventorySlot = -1)
|
||||
{
|
||||
var newItem = new ItemInstance { blueprint = itemBlueprint };
|
||||
var addResult = inventory.AddItem(newItem, inventorySlot);
|
||||
return addResult;
|
||||
var newItem = new ItemInstance { blueprint = itemBlueprint, amount = amount };
|
||||
return inventorySlot < 0
|
||||
? inventory.AddItem(newItem)
|
||||
: inventory.AddItemToSlot(newItem, inventorySlot);
|
||||
}
|
||||
|
||||
public InventoryActionResult MoveItem(
|
||||
@@ -39,10 +41,11 @@ public partial class InventoryManager : Node
|
||||
var remResult = sourceInventory.RemoveItem(sourceSlot, out var item);
|
||||
if (remResult != InventoryActionResult.Success) return remResult;
|
||||
|
||||
var addResult = destinationInventory.AddItem(item!, destinationSlot);
|
||||
if(addResult == InventoryActionResult.Success) return InventoryActionResult.Success;
|
||||
var addResult = destinationInventory.AddItemToSlot(item!, destinationSlot);
|
||||
if (addResult == InventoryActionResult.Success) return InventoryActionResult.Success;
|
||||
|
||||
sourceInventory.AddItem(item!, sourceSlot); // can not fail ... in theory
|
||||
// if adding in the destination failed, re-add the item into the source
|
||||
sourceInventory.AddItemToSlot(item!, sourceSlot); // can not fail ... in theory
|
||||
return addResult;
|
||||
}
|
||||
|
||||
@@ -60,4 +63,9 @@ public partial class InventoryManager : Node
|
||||
{
|
||||
return inventory.RemoveItem(inventorySlot);
|
||||
}
|
||||
}
|
||||
|
||||
public InventoryActionResult CollectItem(ItemInstance itemInstance)
|
||||
{
|
||||
return playerInventory.AddItem(itemInstance);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ public partial class InventoryUi : Control
|
||||
PopulateSlots();
|
||||
SetSlotContent();
|
||||
SetSlotSelectPosition();
|
||||
InventoryManager.Instance.playerInventory.InventoryContentsChanged += SetSlotContent;
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
@@ -42,6 +43,12 @@ public partial class InventoryUi : Control
|
||||
uiSlot!.nameLabel.Text = inventorySlot.itemInstance?.blueprint.name ?? "";
|
||||
uiSlot!.nameLabel.LabelSettings = uiSlot!.nameLabel.LabelSettings.Duplicate() as LabelSettings;
|
||||
uiSlot!.nameLabel.LabelSettings!.FontColor = inventorySlot.itemInstance?.blueprint.color ?? Colors.White;
|
||||
|
||||
var amountText = inventorySlot.itemInstance != null &&
|
||||
inventorySlot.itemInstance.amount != 1
|
||||
? inventorySlot.itemInstance.amount.ToString()
|
||||
: "";
|
||||
uiSlot!.amountLabel.Text = amountText;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +95,7 @@ public partial class InventoryUi : Control
|
||||
var destinationSlot = index;
|
||||
InventoryManager.Instance.MoveItem(_playerInventory, sourceSlot, _playerInventory, destinationSlot);
|
||||
_slotOnMouse = null;
|
||||
SetSlotContent();
|
||||
//SetSlotContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +105,7 @@ public partial class InventoryUi : Control
|
||||
{
|
||||
InputInventoryOpenClose();
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("ui_inventory_disadvance"))
|
||||
{
|
||||
_selectedSlot++;
|
||||
@@ -105,7 +113,8 @@ public partial class InventoryUi : Control
|
||||
_selectedSlot = 0;
|
||||
SetSlotSelectPosition();
|
||||
}
|
||||
if(Input.IsActionJustPressed("ui_inventory_advance"))
|
||||
|
||||
if (Input.IsActionJustPressed("ui_inventory_advance"))
|
||||
{
|
||||
_selectedSlot--;
|
||||
if (_selectedSlot < 0)
|
||||
@@ -142,4 +151,4 @@ public partial class InventoryUi : Control
|
||||
_slotOnMouse = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,14 @@
|
||||
public class ItemInstance
|
||||
{
|
||||
public ItemResource blueprint;
|
||||
public int amount = 1;
|
||||
|
||||
public ItemInstance Clone()
|
||||
{
|
||||
return new ItemInstance
|
||||
{
|
||||
blueprint = blueprint,
|
||||
amount = amount
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using Godot;
|
||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
|
||||
public partial class ItemOnGround : Node3D
|
||||
{
|
||||
private ItemInstance _itemInstance;
|
||||
|
||||
[Export]
|
||||
private bool _infiniteSupply = false;
|
||||
|
||||
private Label3D _itemLabel => GetNode<Label3D>("ItemLabel");
|
||||
private Label3D _pickupErrorLabel => GetNode<Label3D>("PickupErrorLabel");
|
||||
|
||||
public ItemInstance itemInstance
|
||||
{
|
||||
get => _itemInstance;
|
||||
set
|
||||
{
|
||||
_itemInstance = value;
|
||||
UpdateVisuals();
|
||||
}
|
||||
}
|
||||
|
||||
public void TryPickUp()
|
||||
{
|
||||
GD.Print("Trying to pick up item");
|
||||
|
||||
var result = InventoryManager.Instance.CollectItem(itemInstance.Clone());
|
||||
if (result == InventoryActionResult.Success)
|
||||
{
|
||||
if (!_infiniteSupply)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_pickupErrorLabel.Text = "Inventory Full";
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.TweenInterval(2);
|
||||
tween.TweenCallback(Callable.From(() => _pickupErrorLabel.Text = ""));
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateVisuals()
|
||||
{
|
||||
_itemLabel.Text = itemInstance.blueprint?.name ?? "Error Item";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://udhigottc8rg
|
||||
@@ -0,0 +1,16 @@
|
||||
#nullable enable
|
||||
using Godot;
|
||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
|
||||
public partial class ItemOnGroundSpawnWith : Node
|
||||
{
|
||||
[Export] private ItemResource? _blueprint = null;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
if(_blueprint == null) return;
|
||||
|
||||
var parent = GetParent<ItemOnGround>();
|
||||
parent.itemInstance = new ItemInstance { blueprint = _blueprint };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c8suoi3i6kqai
|
||||
@@ -2,17 +2,21 @@
|
||||
namespace Babushka.scripts.CSharp.Common.Inventory;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class ItemResource: Resource
|
||||
public partial class ItemResource : Resource
|
||||
{
|
||||
[Export]
|
||||
public string name;
|
||||
|
||||
[Export]
|
||||
public Color color;
|
||||
|
||||
|
||||
[Export]
|
||||
public int maxStack;
|
||||
|
||||
public ItemResource()
|
||||
{
|
||||
name = "";
|
||||
color = Colors.Red;
|
||||
maxStack = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,14 @@ public partial class SlotUi : Control
|
||||
{
|
||||
public Label nameLabel;
|
||||
public int index;
|
||||
public Label amountLabel;
|
||||
|
||||
[Signal] public delegate void ClickedEventHandler(int index);
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
nameLabel = GetNode<Label>("NameLabel");
|
||||
amountLabel = GetNode<Label>("AmountLabel");
|
||||
}
|
||||
|
||||
public void _on_gui_input(InputEvent ev)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://bb4fc5y43ksfg
|
||||
@@ -0,0 +1,8 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Babushka.scripts.CSharp.Common.WorldManagement;
|
||||
|
||||
public partial class SpawnPointMarker : Node3D
|
||||
{
|
||||
[Export] public SpawnPointResource spawnPointResource;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://c7eaa0neniiss
|
||||
@@ -0,0 +1,14 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.WorldManagement;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class SpawnPointResource : Resource
|
||||
{
|
||||
[Export] public string name;
|
||||
|
||||
public SpawnPointResource()
|
||||
{
|
||||
name = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cjr2efpm660kr
|
||||
@@ -0,0 +1,21 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Babushka.scripts.CSharp.Common.WorldManagement;
|
||||
|
||||
public partial class World : Node
|
||||
{
|
||||
public IReadOnlyDictionary<SpawnPointResource, SpawnPointMarker> SpawnPoints;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
GD.Print("World Enter Tree");
|
||||
|
||||
// find all child nodes of type SpawnPoint
|
||||
SpawnPoints = FindChildren("*")
|
||||
.OfType<SpawnPointMarker>()
|
||||
.Select(sp => new KeyValuePair<SpawnPointResource, SpawnPointMarker>(sp.spawnPointResource, sp))
|
||||
.ToDictionary();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://6aq8mr0sofrs
|
||||
@@ -0,0 +1,26 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Babushka.scripts.CSharp.Common.WorldManagement;
|
||||
|
||||
public partial class WorldChangeTrigger : Area3D
|
||||
{
|
||||
[Export] private PackedScene switchToWorld;
|
||||
[Export] private SpawnPointResource switchToSpawnPoint;
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
//AreaEntered += AreaEnteredHandler;
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
//AreaEntered -= AreaEnteredHandler;
|
||||
}
|
||||
|
||||
public void AreaEnteredHandler(Area3D area)
|
||||
{
|
||||
GD.Print("Area Entered");
|
||||
var worldContainer = (WorldContainer)FindParent("WorldContainer");
|
||||
worldContainer.SwitchWorld(switchToWorld, switchToSpawnPoint);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://cpbv0b3ahorep
|
||||
@@ -0,0 +1,41 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Babushka.scripts.CSharp.Common.WorldManagement;
|
||||
|
||||
public partial class WorldContainer : Node
|
||||
{
|
||||
[Export] private PackedScene startingWorld;
|
||||
[Export] private SpawnPointResource startingSpawnPoint;
|
||||
|
||||
[Signal] public delegate void WorldChangedEventHandler(Vector3 spawnPointPosition);
|
||||
|
||||
public void SwitchWorld(PackedScene newWorldScene, SpawnPointResource spawnPoint)
|
||||
{
|
||||
// Unload the current world
|
||||
if (GetChildCount() > 0)
|
||||
{
|
||||
GetChild(0).QueueFree();
|
||||
}
|
||||
|
||||
// Load the new world
|
||||
var newWorld = newWorldScene.Instantiate<World>();
|
||||
AddChild(newWorld);
|
||||
|
||||
// Switch to the new spawn point
|
||||
if (newWorld.SpawnPoints.TryGetValue(spawnPoint, out var spawnPointMarker))
|
||||
{
|
||||
EmitSignalWorldChanged(spawnPointMarker.GlobalPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.PrintErr("Selected spawn point not found in the new world.");
|
||||
EmitSignalWorldChanged(newWorld.SpawnPoints.First().Value.GlobalPosition);
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
SwitchWorld(startingWorld,startingSpawnPoint);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://g338f4yomfo3
|
||||
Reference in New Issue
Block a user