Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 protected override void UnloadData()
 {
     base.UnloadData();
     m_oreDetector = null;
     OreDetector.UnloadStatic();
 }
Esempio n. 3
0
 public static void UnloadStatic()
 {
     _instance = null;
 }
Esempio n. 4
0
 static OreDetector()
 {
     _instance = new OreDetector();
 }