mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-08 21:55:54 +00:00
Moved events inside the player
This commit is contained in:
parent
11a22684d4
commit
7d9db8cfb6
7 changed files with 57 additions and 75 deletions
|
|
@ -28,8 +28,6 @@ public partial class GameManager : Node2D
|
|||
|
||||
//[Export] public Marker2D PlayerSpawnMarker { get; set; }
|
||||
|
||||
[Export] public PackedScene WeaponTemplate { get; private set; }
|
||||
|
||||
[Export] public Array<LootItem> StartingEquipment { get; private set; } = new();
|
||||
|
||||
private InventoryManager _inventoryManager { get; set; }
|
||||
|
|
@ -150,21 +148,6 @@ public partial class GameManager : Node2D
|
|||
return;
|
||||
}
|
||||
|
||||
if (_inventoryManager is not null)
|
||||
{
|
||||
_inventoryManager.ItemAdded += (LootItem item, int amount) =>
|
||||
{
|
||||
if (item.Item == ItemTypes.Weapon)
|
||||
{
|
||||
SpawnPlayerWeapon(item);
|
||||
}
|
||||
};
|
||||
|
||||
_inventoryManager.WeaponEquip += _player.EquipWeapon;
|
||||
|
||||
_inventoryManager.ItemUsed += _player.UseItem;
|
||||
}
|
||||
|
||||
// Wait before the player is fully initialized before spawning weapons on it
|
||||
CallDeferred(MethodName.SpawnWeapons);
|
||||
}
|
||||
|
|
@ -252,25 +235,6 @@ public partial class GameManager : Node2D
|
|||
}
|
||||
}
|
||||
|
||||
private void SpawnPlayerWeapon(LootItem startingItem)
|
||||
{
|
||||
if (WeaponTemplate == null)
|
||||
{
|
||||
GD.Print("Could not spawn weapon because template is null");
|
||||
return;
|
||||
}
|
||||
|
||||
var weapon = _player.CreateChild<Weapon>(WeaponTemplate);
|
||||
weapon.WeaponData = startingItem.WeaponData;
|
||||
|
||||
_player.AddWeapon(weapon);
|
||||
|
||||
if (_player.EquippedWeapon == null)
|
||||
{
|
||||
_player.EquipWeapon(weapon);
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnBulletsContainer()
|
||||
{
|
||||
_bulletsContainer = new Node2D();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue