Esempio n. 1
0
        private void UpdateLootContainer(Dictionary <string, LootContainerData> containerData, LootContainer container, Dictionary <string, LootSpawn> lootSpawns)
        {
            if (container == null)
            {
                return;
            }
            LootContainerData containerConfig;

            if (containerData == null || !containerData.TryGetValue(container.PrefabName, out containerConfig))
            {
                Puts("No container data found: {0}", container.PrefabName);
                return;
            }
            container.maxDefinitionsToSpawn    = containerConfig.MaxDefinitionsToSpawn;
            container.minSecondsBetweenRefresh = containerConfig.MinSecondsBetweenRefresh;
            container.maxSecondsBetweenRefresh = containerConfig.MaxSecondsBetweenRefresh;
            container.destroyOnEmpty           = containerConfig.DestroyOnEmpty;
            container.distributeFragments      = containerConfig.DistributeFragments;
            container.lootDefinition           = GetLootSpawn(containerConfig.LootDefinition, lootSpawns);
            container.inventorySlots           = containerConfig.InventorySlots;
            container.SpawnType = containerConfig.SpawnType;
            if (!container.gameObject.activeInHierarchy || container.inventory == null)
            {
                return;
            }
            container.inventory.capacity = containerConfig.InventorySlots;
            container.CancelInvoke("SpawnLoot");
            container.SpawnLoot();
        }
Esempio n. 2
0
        private void UpdateLootContainer(Dictionary <string, LootContainerData> containerData, LootContainer container, Dictionary <string, LootSpawn> lootSpawns)
        {
            if (container == null)
            {
                return;
            }
            LootContainerData containerConfig;

            if (containerData == null || !containerData.TryGetValue(container.PrefabName, out containerConfig))
            {
                Puts("No container data found: {0}", container.PrefabName);
                return;
            }
            container.maxDefinitionsToSpawn    = containerConfig.MaxDefinitionsToSpawn;
            container.minSecondsBetweenRefresh = containerConfig.MinSecondsBetweenRefresh;
            container.maxSecondsBetweenRefresh = containerConfig.MaxSecondsBetweenRefresh;
            container.destroyOnEmpty           = containerConfig.DestroyOnEmpty;
            container.lootDefinition           = GetLootSpawn(containerConfig.LootDefinition, lootSpawns);
            container.inventorySlots           = containerConfig.InventorySlots;
            container.initialLootSpawn         = containerConfig.InitialLootSpawn;
            container.BlockPlayerItemInput     = containerConfig.BlockPlayerItemInput;
            container.scrapAmount    = containerConfig.ScrapAmount;
            container.SpawnType      = containerConfig.SpawnType;
            container.LootSpawnSlots = new LootContainer.LootSpawnSlot[containerConfig.LootSpawnSlots.Length];
            for (var i = 0; i < containerConfig.LootSpawnSlots.Length; i++)
            {
                var lootSpawnSlot = containerConfig.LootSpawnSlots[i];
                container.LootSpawnSlots[i] = new LootContainer.LootSpawnSlot
                {
                    definition    = GetLootSpawn(lootSpawnSlot.Definition, lootSpawns),
                    numberToSpawn = lootSpawnSlot.NumberToSpawn,
                    probability   = lootSpawnSlot.Probability
                };
            }
            if (container.inventory == null)
            {
                return;
            }
            container.CancelInvoke(new Action(container.SpawnLoot));
            container.inventory.capacity = containerConfig.InventorySlots;
            container.inventory.SetFlag(ItemContainer.Flag.NoItemInput, container.BlockPlayerItemInput);
            container.inventory.Clear();
            if (container.gameObject.activeInHierarchy && container.initialLootSpawn)
            {
                container.SpawnLoot();
            }
        }