Spawn rescued item at correct location and enable pickup
This commit is contained in:
@@ -2,14 +2,42 @@ using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class RescuedItems : Marker3D
|
||||
public partial class RescuedItems : Node3D
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency] public IGame Game => this.DependOn<IGame>();
|
||||
|
||||
[Node] public Marker3D Spawn1 { get; set; } = default!;
|
||||
[Node] public Marker3D Spawn2 { get; set; } = default!;
|
||||
[Node] public Marker3D Spawn3 { get; set; } = default!;
|
||||
[Node] public Marker3D Spawn4 { get; set; } = default!;
|
||||
[Node] public Marker3D Spawn5 { get; set; } = default!;
|
||||
[Node] public Marker3D Spawn6 { get; set; } = default!;
|
||||
[Node] public Marker3D Spawn7 { get; set; } = default!;
|
||||
[Node] public Marker3D Spawn8 { get; set; } = default!;
|
||||
|
||||
private List<Marker3D> SpawnLocations;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
SpawnLocations = new List<Marker3D>()
|
||||
{
|
||||
Spawn1,
|
||||
Spawn2,
|
||||
Spawn3,
|
||||
Spawn4,
|
||||
Spawn5,
|
||||
Spawn6,
|
||||
Spawn7,
|
||||
Spawn8
|
||||
};
|
||||
}
|
||||
|
||||
public void SpawnRescuedItems()
|
||||
{
|
||||
foreach (var item in Game.RescuedItems.Items)
|
||||
@@ -17,8 +45,9 @@ public partial class RescuedItems : Marker3D
|
||||
var droppedScene = GD.Load<PackedScene>("res://src/items/dropped/DroppedItem.tscn");
|
||||
var dropped = droppedScene.Instantiate<DroppedItem>();
|
||||
dropped.Item = item;
|
||||
dropped.GlobalPosition = GlobalPosition;
|
||||
AddChild(dropped);
|
||||
SpawnLocations.First().AddChild(dropped);
|
||||
dropped.GlobalPosition = SpawnLocations.First().GlobalPosition;
|
||||
SpawnLocations.Remove(SpawnLocations.First());
|
||||
}
|
||||
|
||||
Game.RescuedItems.Items.Clear();
|
||||
|
||||
Reference in New Issue
Block a user