Esempio n. 1
0
        private void RecalculatePositions()
        {
            ClearPositionsAndMaxContent();
            int sizeInVoxels = MyVoxelConstants.VOXEL_DATA_CELL_SIZE_IN_VOXELS * MyVoxelConstants.VOXEL_MAP_ORE_DEPOSIT_CELL_IN_DATA_CELLS;

            MyMwcVector3Int voxelStartCoord = new MyMwcVector3Int(sizeInVoxels * m_coord.X, sizeInVoxels * m_coord.Y, sizeInVoxels * m_coord.Z);
            MyMwcVector3Int voxelEndCoord   = new MyMwcVector3Int(voxelStartCoord.X + sizeInVoxels - 1, voxelStartCoord.Y + sizeInVoxels - 1, voxelStartCoord.Z + sizeInVoxels - 1);

            MyMwcVector3Int voxelCoord;

            for (voxelCoord.X = voxelStartCoord.X; voxelCoord.X <= voxelEndCoord.X; voxelCoord.X++)
            {
                for (voxelCoord.Y = voxelStartCoord.Y; voxelCoord.Y <= voxelEndCoord.Y; voxelCoord.Y++)
                {
                    for (voxelCoord.Z = voxelStartCoord.Z; voxelCoord.Z <= voxelEndCoord.Z; voxelCoord.Z++)
                    {
                        byte content = m_voxelMap.GetVoxelContent(ref voxelCoord);
                        if (content >= MyVoxelConstants.VOXEL_ISO_LEVEL)
                        {
                            MyMwcVoxelMaterialsEnum material = m_voxelMap.GetVoxelMaterial(ref voxelCoord);
                            byte maxContent;
                            m_helpersMaxContentForMaterial.TryGetValue((int)material, out maxContent);

                            if (!m_allMaterialsPositions.ContainsKey((int)material) || content > maxContent)
                            {
                                if (!m_allMaterialsPositions.ContainsKey((int)material))
                                {
                                    m_allMaterialsPositions.Add((int)material, m_voxelMap.GetVoxelCenterPositionAbsolute(ref voxelCoord));
                                }
                                else
                                {
                                    m_allMaterialsPositions[(int)material] = m_voxelMap.GetVoxelCenterPositionAbsolute(ref voxelCoord);
                                }

                                if (!m_helpersMaxContentForMaterial.ContainsKey((int)material))
                                {
                                    m_helpersMaxContentForMaterial.Add((int)material, content);
                                }
                                else
                                {
                                    m_helpersMaxContentForMaterial[(int)material] = content;
                                }
                            }
                        }
                    }
                }
            }

            //if (m_oreWithContent.Count > 0)
            //{
            //    SortByContent();
            //    m_position = m_allMaterialsPositions[(int)m_oreWithContent[0]].Value;
            //}
            //else
            //{
            //    m_position = WorldAABB.GetCenter();
            //}
        }
Esempio n. 2
0
        //  When tube/head mounted into voxels and is harvesting
        void StartInVoxel(MyVoxelMap voxelMap)
        {
            //  We found voxel so we stop here
            m_inVoxelMap = voxelMap;
            CurrentState = MyHarvestingDeviceEnum.InVoxel;
            StopTubeMovingCue();
            StartGrindingCue();
            m_lastTimeParticleAdded = null;
            m_parentMinerShip.Physics.Clear();
            m_parentMinerShip.Physics.Immovable = true;

            MyMwcVector3Int tempVoxelCoord = voxelMap.GetVoxelCenterCoordinateFromMeters(ref m_headPositionTransformed);

            m_originalVoxelContent = voxelMap.GetVoxelContent(ref tempVoxelCoord);
            m_voxelMaterial        = voxelMap.GetVoxelMaterial(ref tempVoxelCoord);


            m_harvestingParticleEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Harvester_Harvesting);
            m_harvestingParticleEffect.UserBirthMultiplier  = 0.25f;
            m_harvestingParticleEffect.UserRadiusMultiplier = 1;
            m_harvestingParticleEffect.UserColorMultiplier  = new Vector4(3, 3, 3, 3);
            Matrix dirMatrix = MyMath.MatrixFromDir(WorldMatrix.Forward);

            m_harvestingParticleEffect.WorldMatrix = Matrix.CreateWorld(m_headPositionTransformed, dirMatrix.Forward, dirMatrix.Up);

            //  Empty voxels are problematic and can lead to "extremely fast harvesting". So here we do this
            //  trick and its effect will be that even empty voxels will take few seconds to harvest.
            if (m_originalVoxelContent == 0)
            {
                m_originalVoxelContent = 1;
            }

            m_actualVoxelContent = (float)m_originalVoxelContent;
            m_harvestingSpeed    = m_actualVoxelContent / TIME_TO_HARVEST_WHOLE_VOXEL_IN_UPDATE_TIMES;

            if (!MyVoxelMapOreMaterials.CanBeHarvested(m_voxelMaterial))
            {
                HUD.MyHud.ShowIndestructableAsteroidNotification();
                StartReturningBack();
            }
        }
        //  When tube/head mounted into voxels and is harvesting
        void StartInVoxel(MyVoxelMap voxelMap)
        {
            //  We found voxel so we stop here
            m_inVoxelMap = voxelMap;
            CurrentState = MyHarvestingDeviceEnum.InVoxel;
            StopTubeMovingCue();
            StartGrindingCue();
            m_lastTimeParticleAdded = null;
            m_parentMinerShip.Physics.Clear();
            m_parentMinerShip.Physics.Immovable = true;

            MyMwcVector3Int tempVoxelCoord = voxelMap.GetVoxelCenterCoordinateFromMeters(ref m_headPositionTransformed);
            m_originalVoxelContent = voxelMap.GetVoxelContent(ref tempVoxelCoord);
            m_voxelMaterial = voxelMap.GetVoxelMaterial(ref tempVoxelCoord);


            m_harvestingParticleEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Harvester_Harvesting);
            m_harvestingParticleEffect.UserBirthMultiplier = 0.25f;
            m_harvestingParticleEffect.UserRadiusMultiplier = 1;
            m_harvestingParticleEffect.UserColorMultiplier = new Vector4(3, 3, 3, 3);
            Matrix dirMatrix = MyMath.MatrixFromDir(WorldMatrix.Forward);
            m_harvestingParticleEffect.WorldMatrix = Matrix.CreateWorld(m_headPositionTransformed, dirMatrix.Forward, dirMatrix.Up);

            //  Empty voxels are problematic and can lead to "extremely fast harvesting". So here we do this
            //  trick and its effect will be that even empty voxels will take few seconds to harvest.
            if (m_originalVoxelContent == 0) m_originalVoxelContent = 1;

            m_actualVoxelContent = (float)m_originalVoxelContent;
            m_harvestingSpeed = m_actualVoxelContent / TIME_TO_HARVEST_WHOLE_VOXEL_IN_UPDATE_TIMES;

            if (!MyVoxelMapOreMaterials.CanBeHarvested(m_voxelMaterial))
            {
                HUD.MyHud.ShowIndestructableAsteroidNotification();
                StartReturningBack();
            }
        }