本文整理汇总了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();
}
示例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();
}