Compare commits

...

3 Commits

11 changed files with 241 additions and 45 deletions
+8 -2
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://gishbn0a8eke"]
[gd_scene load_steps=12 format=3 uid="uid://gishbn0a8eke"]
[ext_resource type="Script" uid="uid://cms357f23fmfy" path="res://scripts/CSharp/Common/Farming/PlantBehaviour2D.cs" id="1_66p1c"]
[ext_resource type="Texture2D" uid="uid://mrnc81ukugh6" path="res://art/farm/farming/farmobjekte/plant_template.png" id="2_oyl0t"]
@@ -6,6 +6,7 @@
[ext_resource type="PackedScene" uid="uid://cqc72e4hq6bcd" path="res://prefabs/interactions/interaction_area_2d.tscn" id="5_3j24b"]
[ext_resource type="PackedScene" uid="uid://dpbbroif2tnil" path="res://prefabs/interactions/generic_item_on_ground_2d.tscn" id="6_gdrin"]
[ext_resource type="Resource" uid="uid://blr8tine5m0ma" path="res://resources/items/tomato.tres" id="7_vjw4j"]
[ext_resource type="Script" uid="uid://j2mhvb45egej" path="res://scripts/CSharp/Low Code/Variables/VariableNode.cs" id="8_3og52"]
[ext_resource type="Texture2D" uid="uid://bleimj6jr1jka" path="res://art/general/rectangle.png" id="9_vjw4j"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_u4cty"]
@@ -28,7 +29,7 @@ radius = 300.0
resource_local_to_scene = true
radius = 300.0
[node name="BasePlant" type="Node2D" node_paths=PackedStringArray("_seeds", "_smallPlants", "_bigPlants", "_readyPlants", "_harvestablePlant", "_magicEffect")]
[node name="BasePlant" type="Node2D" node_paths=PackedStringArray("_seeds", "_smallPlants", "_bigPlants", "_readyPlants", "_harvestablePlant", "_magicEffect", "_lifecycle")]
z_index = 1
y_sort_enabled = true
script = ExtResource("1_66p1c")
@@ -38,6 +39,7 @@ _bigPlants = [NodePath("BigPlant/01"), NodePath("BigPlant/02"), NodePath("BigPla
_readyPlants = [NodePath("ReadyPlantInventoryItem/ReadyPlant/01"), NodePath("ReadyPlantInventoryItem/ReadyPlant/02"), NodePath("ReadyPlantInventoryItem/ReadyPlant/03")]
_harvestablePlant = NodePath("ReadyPlantInventoryItem")
_magicEffect = NodePath("magic vfx")
_lifecycle = NodePath("LifeCycle")
[node name="Seeds" type="Node2D" parent="."]
position = Vector2(0, 0.5)
@@ -206,6 +208,10 @@ scale_amount_max = 0.1
color = Color(0.400601, 0.62444, 0.791217, 1)
hue_variation_max = 0.4
[node name="LifeCycle" type="Node" parent="."]
script = ExtResource("8_3og52")
Payload = 3
[connection signal="Interacted" from="GrowingInteractionArea" to="." method="Grow"]
[connection signal="SuccessfulPickUp" from="ReadyPlantInventoryItem" to="." method="queue_free"]
+5
View File
@@ -300,6 +300,11 @@ ui_inventory_journal_open_close={
"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":74,"key_label":0,"unicode":106,"location":0,"echo":false,"script":null)
]
}
NextDayCheat={
"deadzone": 0.2,
"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":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
]
}
[internationalization]
+24 -1
View File
@@ -1,7 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://bopv10dqm1knc"]
[gd_scene load_steps=7 format=3 uid="uid://bopv10dqm1knc"]
[ext_resource type="PackedScene" uid="uid://c6wnoif01ltld" path="res://scenes/Babushka_scene_startMenu.tscn" id="1_15ton"]
[ext_resource type="Script" uid="uid://bbp0dyddwdbl8" path="res://scripts/CSharp/Common/Savegame/WindowSettingsSync.cs" id="2_d3jfo"]
[ext_resource type="Script" uid="uid://d27xoo1reo5gu" path="res://scripts/CSharp/Low Code/Variables/SaveableVariableNode.cs" id="3_ocsjo"]
[ext_resource type="Script" uid="uid://du5facslfvg77" path="res://scripts/CSharp/Common/DayAndNight/CalendarController.cs" id="4_iyo8m"]
[ext_resource type="Script" uid="uid://iquhbkr7pqeg" path="res://scripts/CSharp/Common/Savegame/SaveCheats.cs" id="4_ocsjo"]
[ext_resource type="Script" uid="uid://ca4s0algeij1h" path="res://scripts/CSharp/Common/Savegame/SaveIDProviderTool.cs" id="5_iyo8m"]
[node name="BabushkaSceneBootstrap" type="Node2D"]
@@ -11,3 +15,22 @@
[node name="WindowSettings" type="Node" parent="."]
script = ExtResource("2_d3jfo")
[node name="Day and Night" type="Node" parent="."]
[node name="DayCounter" type="Node" parent="Day and Night" groups=["Saveable"]]
script = ExtResource("3_ocsjo")
Payload = 0
metadata/SaveID = "b46b67a2-427b-4f43-8066-4ffebf17b75f"
[node name="Controller" type="Node" parent="Day and Night" node_paths=PackedStringArray("_dayCounter")]
script = ExtResource("4_iyo8m")
_dayCounter = NodePath("../DayCounter")
[node name="SaveSystem" type="Node" parent="."]
[node name="SaveGameCheat" type="Node" parent="SaveSystem"]
script = ExtResource("4_ocsjo")
[node name="SaveIDProvider" type="Node" parent="SaveSystem"]
script = ExtResource("5_iyo8m")
+54 -34
View File
@@ -1,6 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://c6wnoif01ltld"]
[gd_scene load_steps=5 format=3 uid="uid://c6wnoif01ltld"]
[ext_resource type="Script" uid="uid://cssdu8viimwm6" path="res://scripts/CSharp/Common/SceneTransition.cs" id="1_fj2fh"]
[ext_resource type="Script" uid="uid://iquhbkr7pqeg" path="res://scripts/CSharp/Common/Savegame/SaveCheats.cs" id="3_dl0t1"]
[ext_resource type="Texture2D" uid="uid://c7atj6ohlmir3" path="res://art/ui/StartScreen/titlescreen.png" id="3_r0y6o"]
[ext_resource type="Texture2D" uid="uid://du612t3xytly3" path="res://art/ui/StartScreen/babushkalog_white.png" id="4_dl0t1"]
@@ -21,37 +22,6 @@ expand_mode = 2
stretch_mode = 6
metadata/_edit_use_anchors_ = true
[node name="Start" type="Button" parent="CanvasLayer/TextureRect"]
custom_minimum_size = Vector2(100, 30)
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 200.0
offset_top = -15.5
offset_right = 400.0
offset_bottom = 24.5
grow_vertical = 2
scale = Vector2(2, 2)
toggle_mode = true
text = "Start"
[node name="Quit" type="Button" parent="CanvasLayer/TextureRect"]
custom_minimum_size = Vector2(100, 30)
layout_mode = 1
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_left = 200.0
offset_top = 97.0
offset_right = 400.0
offset_bottom = 137.0
grow_vertical = 2
scale = Vector2(2, 2)
toggle_mode = true
text = "Quit
"
[node name="Text" type="TextureRect" parent="CanvasLayer/TextureRect"]
layout_mode = 1
offset_left = 50.0
@@ -62,5 +32,55 @@ scale = Vector2(0.5, 0.5)
texture = ExtResource("4_dl0t1")
stretch_mode = 3
[connection signal="pressed" from="CanvasLayer/TextureRect/Start" to="." method="LoadScene"]
[connection signal="pressed" from="CanvasLayer/TextureRect/Quit" to="." method="Quit"]
[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/TextureRect"]
custom_minimum_size = Vector2(500, 300)
layout_mode = 0
offset_left = 204.0
offset_top = 497.0
offset_right = 704.0
offset_bottom = 797.0
[node name="MarginContainer" type="MarginContainer" parent="CanvasLayer/TextureRect/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 10
theme_override_constants/margin_bottom = 10
[node name="Continue" type="Button" parent="CanvasLayer/TextureRect/VBoxContainer/MarginContainer"]
custom_minimum_size = Vector2(100, 80)
layout_mode = 2
theme_override_font_sizes/font_size = 36
toggle_mode = true
text = "Continue
"
[node name="MarginContainer2" type="MarginContainer" parent="CanvasLayer/TextureRect/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 10
theme_override_constants/margin_bottom = 10
[node name="New Game" type="Button" parent="CanvasLayer/TextureRect/VBoxContainer/MarginContainer2"]
custom_minimum_size = Vector2(100, 80)
layout_mode = 2
theme_override_font_sizes/font_size = 36
toggle_mode = true
text = "New Game
"
script = ExtResource("3_dl0t1")
[node name="MarginContainer3" type="MarginContainer" parent="CanvasLayer/TextureRect/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_top = 10
theme_override_constants/margin_bottom = 10
[node name="Quit" type="Button" parent="CanvasLayer/TextureRect/VBoxContainer/MarginContainer3"]
custom_minimum_size = Vector2(100, 80)
layout_mode = 2
theme_override_font_sizes/font_size = 36
toggle_mode = true
text = "Quit
"
[connection signal="pressed" from="CanvasLayer/TextureRect/VBoxContainer/MarginContainer/Continue" to="." method="LoadScene"]
[connection signal="pressed" from="CanvasLayer/TextureRect/VBoxContainer/MarginContainer2/New Game" to="." method="LoadScene"]
[connection signal="pressed" from="CanvasLayer/TextureRect/VBoxContainer/MarginContainer2/New Game" to="CanvasLayer/TextureRect/VBoxContainer/MarginContainer2/New Game" method="Reset"]
[connection signal="pressed" from="CanvasLayer/TextureRect/VBoxContainer/MarginContainer3/Quit" to="." method="Quit"]
@@ -0,0 +1,20 @@
using Babushka.scripts.CSharp.Low_Code.Variables;
using Godot;
namespace Babushka.scripts.CSharp.Common.DayAndNight;
public partial class CalendarController : Node
{
[Export] private SaveableVariableNode _dayCounter;
public override void _Input(InputEvent @event)
{
if (@event.IsActionPressed("NextDayCheat"))
{
int days = _dayCounter.Payload.AsInt32();
days++;
_dayCounter.Payload = days;
}
}
}
@@ -0,0 +1 @@
uid://du5facslfvg77
@@ -195,7 +195,7 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
{
{ "prefab_path", _currentPlant.PrefabPath },
{ "plant_state", (int)_currentPlant.State },
{ "plant_days_growing", _currentPlant.DaysGrowing }
{ "plant_start_day", _currentPlant.DayPlanted }
}
);
}
@@ -243,11 +243,18 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
_currentPlant.GrowPlant();
}
if (plantDataDict.TryGetValue("plant_days_growing", out Variant plantDaysGrowingVar) && _currentPlant != null)
if (plantDataDict.TryGetValue("plant_start_day", out Variant plantDaysGrowingVar) && _currentPlant != null)
{
_currentPlant.DaysGrowing = plantDaysGrowingVar.AsInt32();
_currentPlant.DayPlanted = plantDaysGrowingVar.AsInt32();
}
if (_currentPlant != null)
{
//todo: find out how to load the current day from save and provide it to the plant script
_currentPlant.CurrentDayInCalendar = GD.RandRange(0, 12);
GD.Print($"Set current Day in calendar for plant {_currentPlant.Name} to {_currentPlant.CurrentDayInCalendar}");
}
}
}
}
@@ -1,6 +1,9 @@
using System;
using System.Diagnostics;
using Babushka.scripts.CSharp.Common.Inventory;
using Babushka.scripts.CSharp.Low_Code.Variables;
using Godot;
using Godot.Collections;
namespace Babushka.scripts.CSharp.Common.Farming;
@@ -9,7 +12,8 @@ namespace Babushka.scripts.CSharp.Common.Farming;
/// </summary>
public partial class PlantBehaviour2D : Node2D
{
[Export] private string _prefabPath;
[ExportGroup("Plant State")]
[Export] private Sprite2D[] _seeds;
[Export] private Sprite2D[] _smallPlants;
[Export] private Sprite2D[] _bigPlants;
@@ -19,11 +23,17 @@ public partial class PlantBehaviour2D : Node2D
[Export] private ItemOnGround2D _harvestablePlant;
[Export] private CpuParticles2D _magicEffect;
[Export] private bool _magicWordNeeded = true;
[ExportGroup("PlantConfig")]
[Export] private string _prefabPath;
[Export] private VariableNode _lifecycle;
private string _magicWordDialogicEventName = "MagicWord";
private Sprite2D? _currentPlantSprite = null;
private bool _magicWordSaid = false;
private bool _calledOnReady = false;
private int _dayPlanted;
private int _currentDay;
public PlantState State
{
@@ -31,8 +41,45 @@ public partial class PlantBehaviour2D : Node2D
set => _state = value;
}
public int DaysGrowing { get; set; }
public int DayPlanted { get; set; }
public int CurrentDayInCalendar
{
get => _currentDay;
set
{
if (_currentDay == value) return;
_currentDay = value;
DaysGrowingChanged();
}
}
public void IncrementDaysGrowing()
{
DayPlanted++;
}
private void DaysGrowingChanged()
{
int _daysGrowing = _currentDay - _dayPlanted;
int lifecycle = _lifecycle.Payload.AsInt32();
Debug.Assert(lifecycle > 0);
float growth = (float)_daysGrowing / lifecycle;
int growthFloor = Mathf.FloorToInt(growth);
_state = growthFloor switch
{
0 => PlantState.Planted,
1 => PlantState.SmallPlant,
2 => PlantState.BigPlant,
_ => PlantState.Ready
};
_calledOnReady = true;
Grow();
}
public string PrefabPath => _prefabPath;
/// <summary>
@@ -0,0 +1,48 @@
using Babushka.scripts.CSharp.Common.Savegame;
using Godot;
using Godot.Collections;
namespace Babushka.scripts.CSharp.Low_Code.Variables;
public partial class SaveableVariableNode : VariableNode, ISaveable
{
public override void _Ready()
{
LoadFromSaveData();
ValueChanged += UpdateSaveData;
}
public override void _ExitTree()
{
ValueChanged -= UpdateSaveData;
}
public void UpdateSaveData()
{
var payloadData = new Dictionary<string, Variant>
{
{ "payload", Payload },
};
string id = GetMeta("SaveID").AsString();
SavegameService.AppendDataToSave( id, payloadData);
}
public void LoadFromSaveData()
{
string id = GetMeta("SaveID").AsString();
Dictionary<string, Variant> save = SavegameService.GetSaveData(id);
if (save.Count > 0)
{
if (Payload.VariantType == Variant.Type.Int)
{
Payload = save["payload"].AsInt32();
}
else
{
Payload = save["payload"];
}
}
}
}
@@ -0,0 +1 @@
uid://d27xoo1reo5gu
@@ -7,5 +7,23 @@ namespace Babushka.scripts.CSharp.Low_Code.Variables;
/// </summary>
public partial class VariableNode : Node
{
[Export] public Variant Payload { get; set; }
[Export] public Variant Payload
{
get
{
return _payload;
}
set
{
if (_payload.Equals(value))
return;
_payload = value;
EmitSignal(SignalName.ValueChanged);
}
}
private Variant _payload;
[Signal] public delegate void ValueChangedEventHandler();
}