Working on item rescue
This commit is contained in:
32
src/item_rescue/RescuedItems.cs
Normal file
32
src/item_rescue/RescuedItems.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class RescuedItems : Marker3D
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] public IGame Game => this.DependOn<IGame>();
|
||||
|
||||
public void SpawnRescuedItems()
|
||||
{
|
||||
foreach (var item in Game.RescuedItems.Items)
|
||||
{
|
||||
var droppedScene = GD.Load<PackedScene>("res://src/items/dropped/DroppedItem.tscn");
|
||||
var dropped = droppedScene.Instantiate<DroppedItem>();
|
||||
dropped.Item = item;
|
||||
dropped.GlobalPosition = GlobalPosition;
|
||||
AddChild(dropped);
|
||||
}
|
||||
|
||||
Game.RescuedItems.Items.Clear();
|
||||
}
|
||||
|
||||
public void OnSpawnItemsEntered(Node3D body)
|
||||
{
|
||||
GD.Print("Spawn items");
|
||||
SpawnRescuedItems();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user