public static void RemoveVoxelContent(long voxelId, Vector3D position, out byte materialRemoved, out float amountOfMaterial)
        {
            materialRemoved  = 0;
            amountOfMaterial = 0f;
            MyStorageData cache = new MyStorageData();

            IMyEntity entity;

            if (!MyAPIGateway.Entities.TryGetEntityById(voxelId, out entity))
            {
                return;
            }

            IMyVoxelBase voxel = entity as IMyVoxelBase;

            byte     original, material;
            var      targetMin = position;
            var      targetMax = position;
            Vector3I minVoxel, maxVoxel;

            MyVoxelCoordSystems.WorldPositionToVoxelCoord(voxel.PositionLeftBottomCorner, ref targetMin, out minVoxel);
            MyVoxelCoordSystems.WorldPositionToVoxelCoord(voxel.PositionLeftBottomCorner, ref targetMax, out maxVoxel);

            OreDetector.Instance.GetVoxelContent(voxel, position, out original, out material, cache);

            if (original == MyVoxelConstants.VOXEL_CONTENT_EMPTY)
            {
                Logger.Instance.LogMessage("Voxel Content empty");
                //Logging.Instance.WriteLine(string.Format("Content is empty"));
                return;
            }

            // Calculate Material Mined
            var voxelMat = MyDefinitionManager.Static.GetVoxelMaterialDefinition(material);

            materialRemoved  = material;
            amountOfMaterial = OreDetector.CalculateAmount(voxelMat, original * 3.9f);

            // Remove Content
            cache.Content(0, 0);
            voxel.Storage.WriteRange(cache, MyStorageDataTypeFlags.ContentAndMaterial, minVoxel, maxVoxel);
        }
Exemple #2
0
 protected override void UnloadData()
 {
     base.UnloadData();
     m_oreDetector = null;
     OreDetector.UnloadStatic();
 }
 public static void UnloadStatic()
 {
     _instance = null;
 }
 static OreDetector()
 {
     _instance = new OreDetector();
 }