Added pickup error text
This commit is contained in:
@@ -19,4 +19,8 @@ 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"]
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://dbxy2y85r1d8x"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://dbxy2y85r1d8x"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dbd1niu3tp8y5" path="res://prefabs/Player3D.tscn" id="1_pdc5e"]
|
||||
[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="PackedScene" uid="uid://cgjc4wurbgimy" path="res://prefabs/UI/Inventory/Inventory.tscn" id="6_876p1"]
|
||||
[ext_resource type="Resource" uid="uid://cndd64batns31" path="res://resources/items/bucket.tres" id="6_nvnpb"]
|
||||
[ext_resource type="Script" uid="uid://d178x7agr603o" path="res://scripts/CSharp/Common/Farming/FieldService.cs" id="7_3rkjv"]
|
||||
[ext_resource type="Script" uid="uid://cywyym5l7ymhr" 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://datee0flk1e84" path="res://resources/items/pickaxe.tres" id="8_hae25"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_8yprl"]
|
||||
|
||||
@@ -46,8 +48,28 @@ visible = false
|
||||
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_hae25")
|
||||
|
||||
[editable path="GenericItemOnGround"]
|
||||
[editable path="GenericItemOnGround2"]
|
||||
[editable path="GenericItemOnGround3"]
|
||||
[editable path="GenericItemOnGround4"]
|
||||
|
||||
@@ -5,6 +5,12 @@ 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;
|
||||
@@ -22,25 +28,22 @@ public partial class ItemOnGround : Node3D
|
||||
var result = InventoryManager.Instance.CollectItem(itemInstance);
|
||||
if (result == InventoryActionResult.Success)
|
||||
{
|
||||
QueueFree();
|
||||
if (!_infiniteSupply)
|
||||
{
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GD.Print("Inventory is full");
|
||||
// TODO: player message
|
||||
_pickupErrorLabel.Text = "Inventory Full";
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.TweenInterval(2);
|
||||
tween.TweenCallback(Callable.From(() => _pickupErrorLabel.Text = ""));
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateVisuals()
|
||||
{
|
||||
var label = GetNode<Label3D>("ItemLabel");
|
||||
if (itemInstance.blueprint != null)
|
||||
{
|
||||
label.Text = itemInstance.blueprint.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
label.Text = "Error Item";
|
||||
}
|
||||
_itemLabel.Text = itemInstance.blueprint?.name ?? "Error Item";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user