Added sceneprovider reference to field scripts and made them register on ready. Also added VariableSetter.

This commit is contained in:
2025-11-11 12:15:30 +01:00
parent fe1dd2bcc1
commit 97dcadf07a
9 changed files with 61 additions and 54 deletions
@@ -1,6 +1,7 @@
using System;
using Babushka.scripts.CSharp.Common.CharacterControls;
using Babushka.scripts.CSharp.Common.Inventory;
using Babushka.scripts.CSharp.Low_Code.Variables;
using Godot;
namespace Babushka.scripts.CSharp.Common.Farming;
@@ -20,6 +21,7 @@ public partial class FieldBehaviour2D : Sprite2D
[Export] public Node2D PlantingPlaceholder;
[Export] public ItemRepository ItemRepository;
[Export] public InteractionArea2D FieldInteractionArea;
[Export] public VariableResource _sceneKeyProvider;
public Vector2 FieldPosition;
@@ -52,6 +54,7 @@ public partial class FieldBehaviour2D : Sprite2D
public override void _Ready()
{
UpdateFieldState(FieldState);
FieldService.Instance.TryAddEntry(_sceneKeyProvider.Payload.AsString(), (Vector2I) GlobalPosition, this);
int randomIndex = new Random().Next(0, _maskTexture.Length);
_maskSprite.Texture = _maskTexture[randomIndex];
_outlineSprite.Texture = _maskOutlineTextures[randomIndex];