private void item_ItemRemoved(MyEnvironmentItems item, ItemInfo itemInfo) { var entityId = item.EntityId; int i = 0; while (i < m_forestAreas.Count) { var area = m_forestAreas[i]; if (area.IsValid && area.ItemIds.ContainsKey(entityId) && area.ItemIds[entityId].Contains(itemInfo.LocalId)) { area.ItemIds[entityId].Remove(itemInfo.LocalId); if (area.IsValid) { InvalidateArea(area); i++; } else { RemoveArea(m_forestAreas, i); } } else { i++; } } }
private void item_ItemAdded(MyEnvironmentItems envItems, ItemInfo itemInfo) { m_checkedSectors.Add(envItems.GetSectorId(ref itemInfo.Transform.Position)); var itemBox = GetWorldBox(itemInfo.SubtypeId, itemInfo.Transform.TransformMatrix); var checkBox = itemBox.GetInflated(DEFAULT_INFLATE_VALUE); m_aabbTree.OverlapAllBoundingBox(ref checkBox, m_tmpAreas); var newForestBox = new Area(); newForestBox.ForestBox = itemBox; newForestBox.AddItem(envItems.EntityId, itemInfo.LocalId); newForestBox.ProxyId = m_aabbTree.AddProxy(ref itemBox, newForestBox, 0); m_tmpAreas.Add(newForestBox); MergeAreas(m_tmpAreas); if (newForestBox.IsValid) m_forestAreas.Add(newForestBox); m_tmpAreas.Clear(); }