public new void ItemsScanned(ReadOnlyList <ScannedItemData> items) { int num = (int)((m_subsystemGameInfo.TotalElapsedGameTime - m_lastRotTime) / 60.0); if (num > 0) { if (m_isRotEnabled) { for (int i = 0; i < items.Count; i++) { ScannedItemData item = items[i]; var block = BlocksManager.Blocks[Terrain.ExtractContents(item.Value)]; int rotPeriod = block.GetRotPeriod(item.Value); if (rotPeriod > 0) { int num2 = item.Container is ComponentNewChest chestNew && chestNew.Powered ? 4 : 1; int num3 = block.GetDamage(item.Value); for (int j = 0; j < num; j++) { if (num3 > 1) { break; } if ((j + m_rotStep) % (rotPeriod * num2) == 0) { num3++; } } if (num3 <= 1) { m_subsystemItemsScanner.TryModifyItem(item, block.SetDamage(item.Value, num3)); } else { m_subsystemItemsScanner.TryModifyItem(item, block.GetDamageDestructionValue(item.Value)); } } } } m_rotStep += num; m_lastRotTime += num * 60.0; } }
public bool TryModifyItem(ScannedItemData itemData, int newValue) { if (itemData.Container is IInventory) { IInventory obj = (IInventory)itemData.Container; obj.RemoveSlotItems(itemData.IndexInContainer, itemData.Count); int slotCapacity = obj.GetSlotCapacity(itemData.IndexInContainer, newValue); obj.AddSlotItems(itemData.IndexInContainer, newValue, MathUtils.Min(itemData.Count, slotCapacity)); return(true); } if (itemData.Container is WorldItem) { ((WorldItem)itemData.Container).Value = newValue; return(true); } if (itemData.Container is IMovingBlockSet) { IMovingBlockSet obj2 = (IMovingBlockSet)itemData.Container; MovingBlock movingBlock = obj2.Blocks.ElementAt(itemData.IndexInContainer); obj2.SetBlock(movingBlock.Offset, newValue); return(true); } return(false); }
public ReadOnlyList <ScannedItemData> ScanItems() { m_items.Clear(); foreach (Subsystem subsystem in base.Project.Subsystems) { IInventory inventory = subsystem as IInventory; if (inventory != null) { ScanInventory(inventory, m_items); } } foreach (Entity entity in base.Project.Entities) { foreach (Component component in entity.Components) { IInventory inventory2 = component as IInventory; if (inventory2 != null) { ScanInventory(inventory2, m_items); } } } ScannedItemData item; foreach (Pickable pickable in base.Project.FindSubsystem <SubsystemPickables>(throwOnError: true).Pickables) { if (pickable.Count > 0 && pickable.Value != 0) { List <ScannedItemData> items = m_items; item = new ScannedItemData { Container = pickable, Value = pickable.Value, Count = pickable.Count }; items.Add(item); } } foreach (Projectile projectile in base.Project.FindSubsystem <SubsystemProjectiles>(throwOnError: true).Projectiles) { if (projectile.Value != 0) { List <ScannedItemData> items2 = m_items; item = new ScannedItemData { Container = projectile, Value = projectile.Value, Count = 1 }; items2.Add(item); } } foreach (IMovingBlockSet movingBlockSet in base.Project.FindSubsystem <SubsystemMovingBlocks>(throwOnError: true).MovingBlockSets) { for (int i = 0; i < movingBlockSet.Blocks.Count; i++) { List <ScannedItemData> items3 = m_items; item = new ScannedItemData { Container = movingBlockSet, Value = movingBlockSet.Blocks[i].Value, Count = 1, IndexInContainer = i }; items3.Add(item); } } return(new ReadOnlyList <ScannedItemData>(m_items)); }