当前位置: 首页>>代码示例>>C#>>正文


C# Area.AddItem方法代码示例

本文整理汇总了C#中Area.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# Area.AddItem方法的具体用法?C# Area.AddItem怎么用?C# Area.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Area的用法示例。


在下文中一共展示了Area.AddItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DistributeItems

        private void DistributeItems(MyEnvironmentItems envItem, ref Vector3D sectorPosition)
        {
            envItem.GetItemsInSector(ref sectorPosition, m_tmpItemInfos);

            var envItemId = envItem.EntityId;
            foreach (var itemInfo in m_tmpItemInfos)
            {
                bool included = false;
                var worldBox = GetWorldBox(itemInfo.SubtypeId, itemInfo.Transform.TransformMatrix);
                var extended = worldBox.GetInflated(DEFAULT_INFLATE_VALUE);
                m_aabbTree.OverlapAllBoundingBox(ref extended, m_tmpAreas);

                for (int i = 0; i < m_tmpAreas.Count; i++)
                {
                    var forestBox = m_tmpAreas[i].ForestBox;
                    if ((forestBox.Center - worldBox.Center).LengthSquared() <= BOX_INCLUDE_DIST_SQ)
                    {
                        forestBox.Include(ref worldBox);
                        m_tmpAreas[i].ForestBox = forestBox;
                        m_tmpAreas[i].AddItem(envItemId, itemInfo.LocalId);
                        included = true;
                        m_aabbTree.MoveProxy(m_tmpAreas[i].ProxyId, ref worldBox, Vector3D.Zero);
                    }
                }

                m_tmpAreas.Clear();

                if (!included)
                {
                    var newForestBox = new Area();
                    newForestBox.ForestBox = worldBox;
                    newForestBox.AddItem(envItemId, itemInfo.LocalId);
                    newForestBox.ProxyId = m_aabbTree.AddProxy(ref worldBox, newForestBox, 0);
                    m_forestAreas.Add(newForestBox);
                }
            }

            m_tmpItemInfos.Clear();
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:39,代码来源:MyFloraAreas.cs

示例2: item_ItemAdded

        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();
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:21,代码来源:MyFloraAreas.cs


注:本文中的Area.AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。