🚧 intermediate state with homework

pull/32/head
kziolkowski 2 months ago
parent bee6249c6f
commit c68727aebe

@ -160,11 +160,9 @@ libraries = {
&"": SubResource("AnimationLibrary_54k4r")
}
[node name="InteractionArea" parent="." instance=ExtResource("15_uo3dh")]
[node name="InteractionArea" parent="." node_paths=PackedStringArray("_spritesToOutline") instance=ExtResource("15_uo3dh")]
position = Vector2(18, -250)
_sceneKeyProvider = null
_saveId = "f99549a9-c97e-45a4-b3c9-4bac23fe6fe7"
_outlineMaterial = null
_spritesToOutline = [NodePath("../Duck rendered")]
[node name="CollisionShape3D" parent="InteractionArea/Area2D" index="0"]
shape = SubResource("CircleShape2D_uo3dh")

@ -1,6 +1,7 @@
[gd_scene load_steps=6 format=3 uid="uid://cqc72e4hq6bcd"]
[gd_scene load_steps=7 format=3 uid="uid://cqc72e4hq6bcd"]
[ext_resource type="Script" uid="uid://ckp413wrub5fm" path="res://scripts/CSharp/Common/CharacterControls/InteractionArea2D.cs" id="1_5ajrf"]
[ext_resource type="Resource" uid="uid://tt3d166mntmi" path="res://resources/low code/farming/var_sceneNameProvider.tres" id="2_o1drf"]
[ext_resource type="Material" uid="uid://blch5kdhkbj75" path="res://art/materials/simple_interactable_outline.tres" id="2_qoey7"]
[ext_resource type="Script" uid="uid://cp2q4k62sjo6h" path="res://scripts/CSharp/Common/CharacterControls/DetectableInteractionArea.cs" id="3_2wrrq"]
@ -13,6 +14,7 @@ default_font_size = 30
[node name="InteractionArea" type="Node2D" node_paths=PackedStringArray("_area", "_label")]
script = ExtResource("1_5ajrf")
_sceneKeyProvider = ExtResource("2_o1drf")
_area = NodePath("Area2D")
_label = NodePath("Area2D/CanvasLayer/MarginContainer/Label")
_outlineMaterial = ExtResource("2_qoey7")

@ -1,4 +1,4 @@
[gd_scene load_steps=121 format=3 uid="uid://gigb28qk8t12"]
[gd_scene load_steps=117 format=3 uid="uid://gigb28qk8t12"]
[ext_resource type="PackedScene" uid="uid://c25udixd5m6l0" path="res://prefabs/characters/Player2D.tscn" id="1_7wfwe"]
[ext_resource type="Texture2D" uid="uid://8sr11ex30n0m" path="res://art/mockups/Kenney_Backgrounds/Samples/uncolored_hills.png" id="2_7b2ri"]
@ -236,20 +236,6 @@ shader_parameter/value_mult = 1.0
shader_parameter/brightness_add = 0.0
shader_parameter/contrast_mult = 1.0
[sub_resource type="CircleShape2D" id="CircleShape2D_065st"]
resource_local_to_scene = true
radius = 200.0
[sub_resource type="ViewportTexture" id="ViewportTexture_w1kgo"]
viewport_path = NodePath("SubViewport")
[sub_resource type="CircleShape2D" id="CircleShape2D_w1kgo"]
resource_local_to_scene = true
radius = 200.0
[sub_resource type="ViewportTexture" id="ViewportTexture_q1g8e"]
viewport_path = NodePath("SubViewport")
[sub_resource type="AudioStreamPlaylist" id="AudioStreamPlaylist_ceriq"]
loop = false
stream_count = 1
@ -1073,9 +1059,7 @@ collision_mask = 4
position = Vector2(145.5, -224)
shape = SubResource("RectangleShape2D_0sfl7")
[node name="InteractionArea" parent="YSorted/Well" node_paths=PackedStringArray("_spritesToOutline") instance=ExtResource("27_klb81")]
_spritesToOutline = [NodePath("..")]
_id = 1
[node name="InteractionArea" parent="YSorted/Well" instance=ExtResource("27_klb81")]
[node name="CollisionShape3D" parent="YSorted/Well/InteractionArea/Area2D" index="0"]
position = Vector2(146, -130)
@ -1087,6 +1071,10 @@ position = Vector2(8192, 3507)
[node name="SpawnWithItem" parent="YSorted/CanGenericPickup" index="0"]
_blueprint = ExtResource("28_ipqaa")
[node name="PickupInteractionArea" parent="YSorted/CanGenericPickup" index="3" node_paths=PackedStringArray("_spritesToOutline")]
_outlineMaterial = null
_spritesToOutline = []
[node name="CollisionShape3D" parent="YSorted/CanGenericPickup/PickupInteractionArea/Area2D" index="0"]
shape = SubResource("CircleShape2D_2065p")
@ -1099,6 +1087,10 @@ position = Vector2(8391, 2060)
[node name="SpawnWithItem" parent="YSorted/RakeGenericPickup" index="0"]
_blueprint = ExtResource("28_6b2nr")
[node name="PickupInteractionArea" parent="YSorted/RakeGenericPickup" index="3" node_paths=PackedStringArray("_spritesToOutline")]
_outlineMaterial = null
_spritesToOutline = []
[node name="CollisionShape3D" parent="YSorted/RakeGenericPickup/PickupInteractionArea/Area2D" index="0"]
shape = SubResource("CircleShape2D_tm0yg")
@ -1110,6 +1102,10 @@ _finiteSupply = 3
[node name="SpawnWithItem" parent="YSorted/SeedPickup" index="0"]
_blueprint = ExtResource("35_64mdn")
[node name="PickupInteractionArea" parent="YSorted/SeedPickup" index="3" node_paths=PackedStringArray("_spritesToOutline")]
_outlineMaterial = null
_spritesToOutline = []
[node name="CollisionShape3D" parent="YSorted/SeedPickup/PickupInteractionArea/Area2D" index="0"]
shape = SubResource("CircleShape2D_tm0yg")
@ -1123,6 +1119,10 @@ _finiteSupply = 3
[node name="SpawnWithItem" parent="YSorted/SeedPickup2" index="0"]
_blueprint = ExtResource("36_fv1t2")
[node name="PickupInteractionArea" parent="YSorted/SeedPickup2" index="3" node_paths=PackedStringArray("_spritesToOutline")]
_outlineMaterial = null
_spritesToOutline = []
[node name="CollisionShape3D" parent="YSorted/SeedPickup2/PickupInteractionArea/Area2D" index="0"]
shape = SubResource("CircleShape2D_tm0yg")
@ -1261,11 +1261,9 @@ collision_mask = 6
position = Vector2(-252.56, 231.32)
polygon = PackedVector2Array(247.227, 43.5123, 44.7822, 43.5123, -87.2178, 45.123, -104.329, -55.2797, -154.107, -73.5347, -160.107, -380.38, -175.44, -400.783, -63.44, -512.461, 97.8934, -541.991, 261.671, -599.172, 374.782, -526.421, 502.338, -526.421, 637.893, -396.488, 598.56, -360.783, 596.338, -58.2327, 528.782, -58.2327, 501.449, 45.9283)
[node name="EnterHouseInteraction" parent="YSorted/Farm visuals/Static" node_paths=PackedStringArray("_spritesToOutline") instance=ExtResource("27_klb81")]
[node name="EnterHouseInteraction" parent="YSorted/Farm visuals/Static" instance=ExtResource("27_klb81")]
position = Vector2(5834, 2354)
scale = Vector2(2.425, 2.425)
_spritesToOutline = [NodePath("DoorSprite")]
_id = 0
[node name="DoorSprite" type="Sprite2D" parent="YSorted/Farm visuals/Static/EnterHouseInteraction"]
position = Vector2(0.412364, -33.1959)
@ -2233,10 +2231,8 @@ collision_mask = 4
position = Vector2(-106.663, 182.891)
shape = SubResource("RectangleShape2D_ycj14")
[node name="InteractionArea" parent="YSorted/Blocker" node_paths=PackedStringArray("_spritesToOutline") instance=ExtResource("27_klb81")]
[node name="InteractionArea" parent="YSorted/Blocker" instance=ExtResource("27_klb81")]
position = Vector2(11234, 1850)
_spritesToOutline = [NodePath("Fence Door")]
_id = 1
[node name="CollisionShape3D" parent="YSorted/Blocker/InteractionArea/Area2D" index="0"]
shape = SubResource("CircleShape2D_l7ekk")
@ -2268,24 +2264,12 @@ y_sort_enabled = false
position = Vector2(4374, 2652)
_penTarget = NodePath("../../pen/penSlot1")
[node name="CollisionShape3D" parent="YSorted/ducks/Duck2/InteractionArea/Area2D" index="0"]
shape = SubResource("CircleShape2D_065st")
[node name="Duck rendered" parent="YSorted/ducks/Duck2" index="3"]
texture = SubResource("ViewportTexture_w1kgo")
[node name="Duck3" parent="YSorted/ducks" node_paths=PackedStringArray("_penTarget") instance=ExtResource("62_i36hd")]
z_index = 0
y_sort_enabled = false
position = Vector2(9259, 3194)
_penTarget = NodePath("../../pen/penSlot2")
[node name="CollisionShape3D" parent="YSorted/ducks/Duck3/InteractionArea/Area2D" index="0"]
shape = SubResource("CircleShape2D_w1kgo")
[node name="Duck rendered" parent="YSorted/ducks/Duck3" index="3"]
texture = SubResource("ViewportTexture_q1g8e")
[node name="Duck4" parent="YSorted/ducks" node_paths=PackedStringArray("_penTarget") instance=ExtResource("62_i36hd")]
z_index = 0
y_sort_enabled = false
@ -2361,8 +2345,9 @@ position = Vector2(3183, 2369)
offset = Vector2(1, -50)
region_rect = Rect2(207, 1184, 149, 142)
[node name="InteractionArea" parent="YSorted/trash/trashObject2" index="0"]
[node name="InteractionArea" parent="YSorted/trash/trashObject2" index="0" node_paths=PackedStringArray("_spritesToOutline")]
position = Vector2(-9, -46)
_spritesToOutline = []
[node name="trashObject3" parent="YSorted/trash" instance=ExtResource("53_ycj14")]
z_index = 0
@ -2371,8 +2356,9 @@ position = Vector2(4724, 3519)
offset = Vector2(1, -50)
region_rect = Rect2(400, 1053, 163, 141)
[node name="InteractionArea" parent="YSorted/trash/trashObject3" index="0"]
[node name="InteractionArea" parent="YSorted/trash/trashObject3" index="0" node_paths=PackedStringArray("_spritesToOutline")]
position = Vector2(-13, -53)
_spritesToOutline = []
[node name="trashObject4" parent="YSorted/trash" instance=ExtResource("53_ycj14")]
z_index = 0
@ -2381,8 +2367,9 @@ position = Vector2(5385, 3391)
offset = Vector2(1, -50)
region_rect = Rect2(1048, 1092, 348, 106)
[node name="InteractionArea" parent="YSorted/trash/trashObject4" index="0"]
[node name="InteractionArea" parent="YSorted/trash/trashObject4" index="0" node_paths=PackedStringArray("_spritesToOutline")]
position = Vector2(0, -59)
_spritesToOutline = []
[node name="trashObject5" parent="YSorted/trash" instance=ExtResource("53_ycj14")]
z_index = 0
@ -2418,8 +2405,9 @@ rotation = 1.77025
offset = Vector2(0, 0)
region_rect = Rect2(1048, 1092, 348, 106)
[node name="InteractionArea" parent="YSorted/trash/trashObject9" index="0"]
[node name="InteractionArea" parent="YSorted/trash/trashObject9" index="0" node_paths=PackedStringArray("_spritesToOutline")]
position = Vector2(22.40873, 25.05658)
_spritesToOutline = []
[node name="CanvasLayer" parent="." instance=ExtResource("32_2nee2")]
@ -2569,10 +2557,6 @@ script = ExtResource("79_065st")
[editable path="YSorted/SeedPickup2"]
[editable path="YSorted/SeedPickup2/PickupInteractionArea"]
[editable path="YSorted/Blocker/InteractionArea"]
[editable path="YSorted/ducks/Duck2"]
[editable path="YSorted/ducks/Duck2/InteractionArea"]
[editable path="YSorted/ducks/Duck3"]
[editable path="YSorted/ducks/Duck3/InteractionArea"]
[editable path="YSorted/trash/trashObject2"]
[editable path="YSorted/trash/trashObject3"]
[editable path="YSorted/trash/trashObject4"]

@ -1,18 +1,18 @@
using System;
using System.Linq;
using Babushka.scripts.CSharp.Common.Savegame;
using Babushka.scripts.CSharp.Common.Services;
using Babushka.scripts.CSharp.Low_Code.Variables;
using Godot;
using Godot.Collections;
namespace Babushka.scripts.CSharp.Common.CharacterControls;
[Tool]
public partial class InteractionArea2D : Node2D, ISaveable
{
[ExportGroup("Persistence")]
[Export] public Babushka.scripts.CSharp.Low_Code.Variables.VariableResource _sceneKeyProvider;
[Export] private string _saveId;
[Export] public VariableResource _sceneKeyProvider;
[Export] private string _saveId = ""; // todo: find good default / generated solution
//todo: rewire broken instances in scenes
[ExportGroup("Settings")]
[Export] private Area2D _area;
@ -49,6 +49,13 @@ public partial class InteractionArea2D : Node2D, ISaveable
_backupMaterials = _spritesToOutline.Select(s => s.Material).ToArray();
}
// bad solution for interaction areas, because they are all named the same.
// option (equally bad) 1: take grandparent's name (could be null though)
// option 2 (also bad): Write Identity Provider class that uses, checks and assigns GUIDs for this purpose.
if (string.IsNullOrEmpty(_saveId))
{
_saveId = Name;
}
LoadFromSaveData();
}

Loading…
Cancel
Save