✨ Added sceneprovider reference to field scripts and made them register on ready. Also added VariableSetter.
This commit is contained in:
@@ -15,6 +15,7 @@ public partial class FarmingControls2D : Node2D
|
||||
[Export] private CpuParticles2D _wateringParticles;
|
||||
[Export] private float _wateringCanParticlesVerticalOffset = 50f;
|
||||
[Export] private Vector2I _fieldOffsetVector = new Vector2I(735, 651);
|
||||
[Export] private Node2D _fieldParent;
|
||||
|
||||
private int _toolId = -1;
|
||||
private bool _wateringCanFilled = false;
|
||||
@@ -143,13 +144,11 @@ public partial class FarmingControls2D : Node2D
|
||||
// reposition and reparent the instance
|
||||
field2d.Position = new Vector2(fieldPosition.X, fieldPosition.Y);
|
||||
|
||||
FieldService.Instance.AddChild(fieldInstance);
|
||||
_fieldParent.AddChild(fieldInstance);
|
||||
EmitSignal(SignalName.FieldCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -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];
|
||||
|
||||
@@ -24,6 +24,7 @@ public partial class FieldService : Node
|
||||
//Create
|
||||
public bool TryAddEntry(string sceneName, Vector2I position, FieldBehaviour2D field)
|
||||
{
|
||||
GD.Print("Trying to add a field at: " + position);
|
||||
if (_outerDict != null )
|
||||
{
|
||||
FieldsInScene innerDict;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using Godot;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Low_Code.Variables;
|
||||
|
||||
public partial class VariableSetter : Node
|
||||
{
|
||||
[Export] private VariableResource _variableResource;
|
||||
[Export] private Variant _payloadToSet;
|
||||
|
||||
public void Set()
|
||||
{
|
||||
_variableResource.Payload = _payloadToSet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://dfpyjxivcuidr
|
||||
Reference in New Issue
Block a user