Skip to content

Commit 9fe32dd

Browse files
committed
Item drops despawn after some time
1 parent e172ffb commit 9fe32dd

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Item/ItemDrop.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ namespace KentingStation.Item;
66

77
public partial class ItemDrop : Area2D
88
{
9+
private const int DespawnTimer = 10000;
10+
911
private IItem _item;
1012
private int _itemCount;
1113
private Sprite2D _sprite;
14+
private int _timestamp;
1215

1316
// Called when the node enters the scene tree for the first time.
1417
public override void _Ready()
@@ -24,6 +27,9 @@ public override void _Ready()
2427
// Called every frame. 'delta' is the elapsed time since the previous frame.
2528
public override void _Process(double delta)
2629
{
30+
_timestamp++;
31+
if (_timestamp > DespawnTimer)
32+
QueueFree();
2733
}
2834

2935
private void OnBodyEntered(Node2D body)

KentingStation.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/UserDictionary/Words/=despawn/@EntryIndexedValue">True</s:Boolean>
23
<s:Boolean x:Key="/Default/UserDictionary/Words/=kenting/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)