Ejemplo n.º 1
0
        private void LoadVoxelMapsInfo()
        {
            m_voxelMapsToAdd.Clear();

            foreach (var item in m_items)
            {
                var envItem = m_sector.DataView.Items[item];
                MyRuntimeEnvironmentItemInfo it;
                m_sector.Owner.GetDefinition((ushort)envItem.DefinitionIndex, out it);
                var definitionId = new MyDefinitionId(typeof(MyObjectBuilder_VoxelMapCollectionDefinition), it.Subtype);
                var definition   = MyDefinitionManager.Static.GetDefinition <MyVoxelMapCollectionDefinition>(definitionId);
                Debug.Assert(definition != null, "Definition not found!");

                if (definition == null)
                {
                    continue;
                }

                // Get the logical counterparts to calculate EntityId.
                int logicalId;
                MyLogicalEnvironmentSectorBase logicalSector;
                m_sector.DataView.GetLogicalSector(item, out logicalId, out logicalSector);

                string name   = String.Format("P({0})S({1})A({2}__{3})", m_sector.Owner.Entity.Name, logicalSector.Id, it.Subtype, logicalId);
                Matrix matrix = MatrixD.CreateFromQuaternion(envItem.Rotation);
                matrix.Translation = m_sector.SectorCenter + envItem.Position;
                long id = MyEntityIdentifier.ConstructIdFromString(MyEntityIdentifier.ID_OBJECT_TYPE.PLANET_VOXEL_DETAIL, name);

                using (m_random.PushSeed(envItem.Rotation.GetHashCode()))
                {
                    m_voxelMapsToAdd.Add(new VoxelMapInfo
                    {
                        Name     = name,
                        Storage  = definition.StorageFiles.Sample(m_random),
                        Matrix   = matrix,
                        Item     = item,
                        Modifier = definition.Modifier,
                        EntityId = id
                    });
                }
            }
        }
Ejemplo n.º 2
0
 public static long MakeSectorEntityId(int x, int y, int lod, int face, long parentId)
 {
     return(MyEntityIdentifier.ConstructIdFromString(MyEntityIdentifier.ID_OBJECT_TYPE.PLANET_ENVIRONMENT_SECTOR, string.Format("P({0})S(x{1}, y{2}, f{3}, l{4})", parentId, x, y, face, lod)));
 }