using System; using System.Collections; using System.Collections.Generic; using System.Linq; using BITFALL.Items; using BITKit; using TinyScript; using UnityEngine; namespace BITFALL.LooSystem { public class WorldContainerLootSpawner : MonoBehaviour { [SerializeField] private bool spawnOnStart; [SerializeField] private LootDrop lootDrop; [SerializeField] private WorldItemContainer container; [SerializeField] private int count; private void Start() { if (spawnOnStart) { Execute(); } } [BIT] public void Execute() { var initialAllowStorage = container.AllowStorage; container.AllowStorage = true; foreach (var x in lootDrop.GetGuaranteeedLoot().Select(x=>x.GetComponent())) { var item = x.Pick(); item.Id = Guid.NewGuid().GetHashCode(); container.Add(item); } foreach (var x in lootDrop.GetRandomLoot(count).Select(x=>x.GetComponent())) { var item = x.Pick(); item.Id = Guid.NewGuid().GetHashCode(); container.Add(item); } container.AllowStorage = initialAllowStorage; } } }