Make the barrier stop pickables.

使屏障可阻止可拾捡物。
This commit is contained in:
Cold-Mint 2024-10-09 17:36:59 +08:00
parent 5b5a9ae198
commit 35dc2ee1b9
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
5 changed files with 48 additions and 5 deletions

View File

@ -92,6 +92,7 @@ collision_layer = 256
collision_mask = 160
script = ExtResource("1_t1qdg")
Path = "res://prefab/ui/SpellEditorUI.tscn"
_furnitureName = "ui_spell_editor"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(-0.5, -0.5)
@ -108,3 +109,9 @@ scale = Vector2(0.7, 0.7)
sprite_frames = SubResource("SpriteFrames_mppe5")
autoplay = "default"
frame_progress = 0.717769
[node name="TipLabel" type="Label" parent="."]
offset_left = -17.0
offset_top = 19.0
offset_right = 23.0
offset_bottom = 44.0

View File

@ -103,9 +103,6 @@ position = Vector2(715, 200)
[node name="WoodenBox3" parent="." instance=ExtResource("7_jybe6")]
position = Vector2(715, 162)
[node name="WoodenBox4" parent="." instance=ExtResource("7_jybe6")]
position = Vector2(714, 122)
[node name="AutoSpawn" type="Node2D" parent="."]
[node name="necromancy" type="Marker2D" parent="AutoSpawn"]

View File

@ -1,4 +1,5 @@
using ColdMint.scripts.damage;
using ColdMint.scripts.utils;
using Godot;
namespace ColdMint.scripts.furniture;
@ -11,6 +12,41 @@ public partial class Furniture : RigidBody2D
{
[Export] private int _initialDurability;
[Export] private int _maxDurability;
[Export]
private string? _furnitureName;
private Label? _tipLabel;
public override void _MouseEnter()
{
if (_tipLabel == null || string.IsNullOrEmpty(_furnitureName))
{
return;
}
var translation = TranslationServerUtils.Translate(_furnitureName);
if (string.IsNullOrEmpty(translation))
{
return;
}
_tipLabel.Visible = true;
_tipLabel.Text = translation;
//Vertical Centering Tip
//垂直居中提示
var oldPosition = _tipLabel.Position;
oldPosition.X = -_tipLabel.Size.X / 2;
_tipLabel.Rotation = -Rotation;
_tipLabel.Position = oldPosition;
}
public override void _MouseExit()
{
if (_tipLabel == null)
{
return;
}
_tipLabel.Visible = false;
}
/// <summary>
/// <para></para>
@ -29,7 +65,8 @@ public partial class Furniture : RigidBody2D
{
_initialDurability = _maxDurability;
}
_tipLabel = GetNodeOrNull<Label>("TipLabel");
InputPickable = true;
_durability = _initialDurability;
SetCollisionLayerValue(Config.LayerNumber.Furniture, true);
SetCollisionMaskValue(Config.LayerNumber.Wall, true);

View File

@ -38,7 +38,6 @@ public partial class GuiFurniture : Furniture
public override void _Ready()
{
base._Ready();
InputPickable = true;
_operateArea2D = GetNode<Area2D>("OperateArea2D");
_operateArea2D.BodyEntered += OnBodyEntered;
_operateArea2D.BodyExited += OnBodyExited;
@ -69,11 +68,13 @@ public partial class GuiFurniture : Furniture
public override void _MouseEnter()
{
base._MouseEnter();
_hasMouseOver = true;
}
public override void _MouseExit()
{
base._MouseExit();
_hasMouseOver = false;
}

View File

@ -202,6 +202,7 @@ public partial class PickAbleTemplate : RigidBody2D, IItem
SetCollisionMaskValue(Config.LayerNumber.Wall, true);
SetCollisionMaskValue(Config.LayerNumber.Platform, true);
SetCollisionMaskValue(Config.LayerNumber.Floor, true);
SetCollisionMaskValue(Config.LayerNumber.Barrier, true);
}
private void OnBodyExited(Node node)