public MyMaterialLayer() { StartHeight = 0; EndHeight = 0; MaterialName = null; MaterialDefinition = null; }
public static string GetVoxelDisplayTexture(this MyVoxelMaterialDefinition voxelMaterialDefinition) { string texture = null; var dx11MaterialDefinition = voxelMaterialDefinition as MyDx11VoxelMaterialDefinition; if (dx11MaterialDefinition != null) { texture = dx11MaterialDefinition.ColorMetalXZnY; if (texture == null) { texture = dx11MaterialDefinition.NormalGlossXZnY; } } if (texture == null) { texture = voxelMaterialDefinition.DiffuseXZ; } if (texture == null) { // The VoxelHandPreview texture is oddly shaped, and not suitable for SEToolbox. // It is a texture of last resort. texture = voxelMaterialDefinition.VoxelHandPreview; } return(texture); }
public MyMaterialLayer(float start, float end, string name) { StartHeight = start; EndHeight = end; MaterialName = name; MaterialDefinition = null; }
public override void LoadData() { base.LoadData(); foreach (MyPhysicalItemDefinition definition2 in MyDefinitionManager.Static.GetPhysicalItemDefinitions()) { if (!definition2.HasModelVariants) { if (string.IsNullOrEmpty(definition2.Model)) { continue; } MyModels.GetModelOnlyData(definition2.Model); continue; } if (definition2.Models != null) { string[] models = definition2.Models; for (int i = 0; i < models.Length; i++) { MyModels.GetModelOnlyData(models[i]); } } } MyVoxelMaterialDefinition voxelMaterialDefinition = MyDefinitionManager.Static.GetVoxelMaterialDefinition((byte)0); BoundingSphereD sphere = new BoundingSphereD(); Spawn(new MyPhysicalInventoryItem(1, MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_Ore>(voxelMaterialDefinition.MinedOre), 1f), sphere, null, voxelMaterialDefinition, item => item.Close()); }
public void CreateDirectedDebris(Vector3 sourceWorldPosition, Vector3 offsetDirection, float minSourceDistance, float maxSourceDistance, float minDeviationAngle, float maxDeviationAngle, int debrisPieces, float initialSpeed, float scale, MyVoxelMaterialDefinition material) { ProfilerShort.Begin("Create directed debris"); MyDebug.AssertDebug(debrisPieces > 0); for (int i = 0; i < debrisPieces; ++i) { var newObj = CreateVoxelDebris(); if (newObj == null) { break; // no point in continuing } float dist = MyUtils.GetRandomFloat(minSourceDistance, maxSourceDistance); float angleX = MyUtils.GetRandomFloat(minDeviationAngle, maxDeviationAngle); float angleY = MyUtils.GetRandomFloat(minDeviationAngle, maxDeviationAngle); var rotation = Matrix.CreateRotationX(angleX) * Matrix.CreateRotationY(angleY); var deviatedDir = Vector3.Transform(offsetDirection, rotation); var startPos = sourceWorldPosition + deviatedDir * dist; var initialVelocity = deviatedDir * initialSpeed; (newObj.Debris as MyDebrisVoxel.MyDebrisVoxelLogic).Start(startPos, initialVelocity, scale, material); } ProfilerShort.End(); }
public MiningInformationPB(MiningInformation mi) { Material = mi.Material; Location = mi.Location; Voxel = mi.Voxel; Count = (ulong)mi.Positions.Count; }
public MiningEntry(MyObjectBuilder_VoxelMiningDefinition_MiningDef item) { var dictionary = new Dictionary <MyDefinitionId, int>(); if (item.MinedItems != null) { foreach (MyObjectBuilder_VoxelMiningDefinition_MinedItem minedItem in item.MinedItems) { var sid = new SerializableDefinitionId { TypeIdString = minedItem.Type, SubtypeName = minedItem.Subtype }; dictionary[sid] = minedItem.Amount; } } MinedItems = dictionary; var num = item.Volume.HasValue ? Math.Max(item.Volume.Value, 1) : 64; var materialDefinition = MyDefinitionManager.Get <MyVoxelMaterialDefinition>(item.VoxelMaterial); if (materialDefinition == null || materialDefinition.Index == byte.MaxValue) { MySession.Static.Log.Warning($"Cannot find voxel material {item.VoxelMaterial}"); Material = MyVoxelMaterialDefinition.Default; Volume = 64; } else { Material = materialDefinition; Volume = num; } }
public MyVoxelMaterialDefinition GetMaterialForPosition(ref Vector3 pos, float lodSize, out byte biomeValue, bool preciseOrePositions) { MaterialSampleParams @params; biomeValue = 0; this.GetPositionParams(ref pos, lodSize, out @params, false); MyVoxelMaterialDefinition material = null; float num = !preciseOrePositions ? ((@params.SurfaceDepth / Math.Max((float)(lodSize * 0.5f), (float)1f)) + 0.5f) : (@params.SurfaceDepth + 0.5f); if (this.m_oreMap != null) { List <PlanetOre> list; byte key = this.m_oreMap.Faces[@params.Face].GetValue(@params.Texcoord.X, @params.Texcoord.Y); if (this.m_ores.TryGetValue(key, out list)) { using (List <PlanetOre> .Enumerator enumerator = list.GetEnumerator()) { while (true) { if (!enumerator.MoveNext()) { break; } PlanetOre current = enumerator.Current; if ((current.Start <= -num) && ((current.Start + current.Depth) >= -num)) { return(current.Material); } } } } } PlanetMaterial layeredMaterialForPosition = this.GetLayeredMaterialForPosition(ref @params, out biomeValue); float num2 = @params.SurfaceDepth / lodSize; if (!layeredMaterialForPosition.HasLayers) { if (num2 >= -layeredMaterialForPosition.Depth) { material = layeredMaterialForPosition.Material; } } else { VoxelMaterial[] layers = layeredMaterialForPosition.Layers; for (int i = 0; i < layers.Length; i++) { if (num2 >= -layers[i].Depth) { material = layeredMaterialForPosition.Layers[i].Material; break; } } } if (material == null) { material = this.m_subsurfaceMaterial.FirstOrDefault; } return(material); }
public static string GetVoxelDisplayTexture(this MyVoxelMaterialDefinition voxelMaterialDefinition) { string texture = null; texture = voxelMaterialDefinition.RenderParams.TextureSets[0].ColorMetalXZnY; if (texture == null) { texture = voxelMaterialDefinition.RenderParams.TextureSets[0].NormalGlossXZnY; } if (texture == null) { texture = voxelMaterialDefinition.DiffuseXZ; } if (texture == null) { // The VoxelHandPreview texture is oddly shaped, and not suitable for SEToolbox. // It is a texture of last resort. texture = voxelMaterialDefinition.VoxelHandPreview; } return(texture); }
public VoxelPlacementDefinition(MyObjectBuilder_VoxelMiningDefinition.MiningDef ob, NamedLogger log) { Material = MyDefinitionManager.Get <MyVoxelMaterialDefinition>(ob.VoxelMaterial); if (Material == null) { log.Warning($"Could not find voxel material definition {ob.VoxelMaterial}"); Material = MyVoxelMaterialDefinition.Default; } Volume = ob.VolumeAttribute; var replacementItems = new Dictionary <MyDefinitionId, int>(); foreach (var item in ob.MinedItems) { MyObjectBuilderType type; try { type = MyObjectBuilderType.Parse(item.Type); } catch { log.Warning($"Can not parse defined builder type {item.Type}"); continue; } var key = new MyDefinitionId(type, MyStringHash.GetOrCompute(item.Subtype)); replacementItems[key] = item.Amount; } Items = replacementItems; }
public void ChangeOreDepositCellContent(byte oldContent, byte newContent, ref Vector3I voxelCoord) { // if contents are same, then do nothing if (oldContent == newContent) { return; } MyVoxelMaterialDefinition material = GetMaterial(ref voxelCoord); // we change content only if material is ore if (!material.IsRare) { return; } Vector3I cellCoord; ComputeCellCoord(ref voxelCoord, out cellCoord); var oreDepositCell = GetOreDepositCell(ref cellCoord, createIfNeeded: true) as DepositCell; Debug.Assert(oreDepositCell.Storage != null); int content = newContent - oldContent; oreDepositCell.AddOreContent(material, content); if (oreDepositCell.TotalRareOreContent == 0) { RemoveOreDepositCell(ComputeCellIndex(ref cellCoord)); } }
/// <summary> /// Returns the world location of the last position of the ore at the starting point, in a continuous line. /// </summary> /// <param name="start"></param> /// <param name="dir"></param> /// <returns></returns> public Vector3D GetLastMatchingVoxelInDirection(Vector3D start, Vector3D dir) { //var startmat = GetSingleMaterialAtPoint(start); var previous = start; var incrementLength = 2; byte content, material; GetVoxelContent(start, out content, out material); var startmat = MyDefinitionManager.Static.GetVoxelMaterialDefinition(material); if (startmat == null || (material == 0 && content == MyVoxelConstants.VOXEL_CONTENT_EMPTY)) { return(start); } MyVoxelMaterialDefinition currentmat = startmat; dir.Normalize(); // Normalize, just in case it's not already Logger.Instance.LogDebug(string.Format("Start Mat: {2}; {0}; Pos: {1}", startmat.MinedOre, start.ToString(), material.ToString())); do { previous = start; start = start + (dir * incrementLength); GetVoxelContent(start, out content, out material); currentmat = MyDefinitionManager.Static.GetVoxelMaterialDefinition(material); //Logger.Instance.LogDebug(string.Format("Current Mat: {2}; {0}; Pos: {1}", currentmat.MinedOre, start.ToString(), material.ToString())); //currentmat = GetSingleMaterialAtPoint(start); } while (currentmat != null && currentmat.MinedOre == startmat.MinedOre && content != MyVoxelConstants.VOXEL_CONTENT_EMPTY && material != 0); return(previous); }
/// <summary> /// Covers surface of the voxel map using given material. /// Material is applied per data cell and number of consecutive cells is given by cellThickness. /// </summary> /// <param name="material">Material to use for surface.</param> /// <param name="cellThickness">Number of consecutive cells covered using given material. Min. is 1.</param> public void SetSurfaceMaterial(MyVoxelMaterialDefinition material, int cellThickness) { Storage.SetSurfaceMaterial(material, cellThickness); Vector3I minCorner = Vector3I.Zero; Vector3I maxCorner = Size; InvalidateCache(minCorner, maxCorner); }
private bool HasMaterial(MyVoxelMaterialDefinition material) { if (material == Material0 || material == Material1 || material == Material2) { return(true); } return(false); }
// Use when you want to change whole cell to one single material public void Reset(MyVoxelMaterialDefinition defaultMaterial) { IsSingleMaterial = true; m_singleMaterial = defaultMaterial.Index; m_averageCellMaterial = m_singleMaterial; m_averageNonRareCellMaterial = m_singleMaterial; // might be rare, but we have no way of knowing what non-rare material to use m_materials = null; }
//based on MyGuiScreenHudSpace.DrawOreMarkers private IEnumerable <PositionedOreMarker> CreateMarkers() { MyHudOreMarkers oreMarkers = MyHud.OreMarkers; Vector3D controlledEntityPosition = Vector3D.Zero; if (MySession.Static != null && MySession.Static.ControlledEntity != null) { controlledEntityPosition = ((MyEntity)MySession.Static.ControlledEntity).WorldMatrix.Translation; } PositionedOreMarker[] nearestOreDeposits = new PositionedOreMarker[MyDefinitionManager.Static.VoxelMaterialCount]; float[] nearestDistancesSquared = new float[nearestOreDeposits.Length]; for (int i = 0; i < nearestOreDeposits.Length; i++) { nearestOreDeposits[i] = null; nearestDistancesSquared[i] = float.MaxValue; } foreach (MyEntityOreDeposit oreMarker in oreMarkers) { for (int i = 0; i < oreMarker.Materials.Count; i++) { MyEntityOreDeposit.Data depositData = oreMarker.Materials[i]; var oreMaterial = depositData.Material; Vector3D oreWorldPosition; var voxelMap = oreMarker.VoxelMap; MyVoxelCoordSystems.LocalPositionToWorldPosition( (voxelMap.PositionComp.GetPosition() - (Vector3D)voxelMap.StorageMin), ref depositData.AverageLocalPosition, out oreWorldPosition); //ProfilerShort.BeginNextBlock("Distance"); Vector3D diff = (controlledEntityPosition - oreWorldPosition); float distanceSquared = (float)diff.LengthSquared(); float nearestDistanceSquared = nearestDistancesSquared[oreMaterial.Index]; if (distanceSquared < nearestDistanceSquared) { MyVoxelMaterialDefinition voxelMaterial = MyDefinitionManager.Static.GetVoxelMaterialDefinition(oreMaterial.Index); nearestOreDeposits[oreMaterial.Index] = new PositionedOreMarker() { Position = oreWorldPosition, OreDeposit = oreMarker, Name = oreMarkers.GetOreName(voxelMaterial), Distance = diff.Length(), }; nearestDistancesSquared[oreMaterial.Index] = distanceSquared; } } } return(nearestOreDeposits.Where(nod => nod?.OreDeposit?.VoxelMap != null && !nod.OreDeposit.VoxelMap.Closed)); }
public void OverwriteAllMaterials(MyVoxelMaterialDefinition material) { Profiler.Begin("MyVoxelMap.OverwriteAllMaterials"); Storage.OverwriteAllMaterials(material); InvalidateCache(Vector3I.Zero, Size); Profiler.End(); }
private static MyVoxelMaterialDefinition GetMaterial(string name) { MyVoxelMaterialDefinition voxelMaterialDefinition = MyDefinitionManager.Static.GetVoxelMaterialDefinition(name); if (voxelMaterialDefinition == null) { MyLog.Default.WriteLine("Could not load voxel material " + name); } return(voxelMaterialDefinition); }
private void ProcessCharacterDamage() { foreach (IMyEntity entity in _topEntityCache) { var character = entity as IMyCharacter; if (character != null) { if (character.Closed || character.MarkedForClose) { continue; } if (Config.PLAYER_ACID_RAIN && !Utilities.IsEntityCovered(entity, _sphere.Center)) { _damageEntities.AddOrUpdate(character, Config.PLAYER_DAMAGE_AMOUNT); } if (Config.PLAYER_RADIATION_DAMAGE) { var comp = character.Components.Get <MyCharacterOxygenComponent>(); //MyAPIGateway.Utilities.ShowMessage("Oxygen at Point Check: ", MyAPIGateway.Session.OxygenProviderSystem.GetOxygenInPoint(character.GetPosition()).ToString()); //MyAPIGateway.Utilities.ShowMessage("Oxygen at Char: ", comp.OxygenLevelAtCharacterLocation.ToString()); if (comp == null || MyAPIGateway.Session.OxygenProviderSystem.GetOxygenInPoint(character.GetPosition()) >= comp.OxygenLevelAtCharacterLocation) { _damageEntities.AddOrUpdate(character, Config.PLAYER_DAMAGE_AMOUNT); } } if (Config.PLAYER_VOXEL_DAMAGE) { Vector3D characterPos = character.GetPosition(); Vector3D surfacePos = _planet.GetClosestSurfacePointGlobal(ref characterPos); //if (surfacePos == Vector3.Zero) // continue; if (Vector3D.DistanceSquared(characterPos, surfacePos) > 6.25) { continue; } MyVoxelMaterialDefinition mat = _planet.GetMaterialAt_R(ref surfacePos); //MyAPIGateway.Utilities.ShowMessage("Damage", mat.MaterialTypeName); VoxelDamageItem item; if (Config.VOXEL_IDS.TryGetValue(mat.Index, out item)) { _damageEntities.AddOrUpdate(character, Config.PLAYER_DAMAGE_AMOUNT * item.CharacterMultiplier); } } //_damageEntities[character] = Config.PLAYER_DAMAGE_AMOUNT; //character.DoDamage(Config.PLAYER_DAMAGE_AMOUNT, _damageHash, true); } } }
public void Start(Vector3D position, Vector3D initialVelocity, MyVoxelMaterialDefinition mat) { MyRenderComponentDebrisVoxel render = base.Container.Entity.Render as MyRenderComponentDebrisVoxel; render.TexCoordOffset = MyUtils.GetRandomFloat(5f, 15f); render.TexCoordScale = MyUtils.GetRandomFloat(8f, 12f); render.VoxelMaterialIndex = mat.Index; base.Start(position, initialVelocity); base.Container.Entity.Render.NeedsResolveCastShadow = true; base.Container.Entity.Render.FastCastShadowResolve = true; }
protected override void Hit() { if (Target.Entity == null || !(Target.Entity is MyVoxelBase)) { return; } MrzUtils.ShowNotificationDebug($"VoxelPainter::Hit {Target.Entity}"); try { var voxelBase = Target.Entity as MyVoxelBase; voxelBase = voxelBase.RootVoxel; // getting the planet if (voxelBase.MarkedForClose) { return; } MyVoxelMaterialDefinition voxelMaterial = GetVoxelMaterial(voxelBase, Target.Position); MyVoxelMiningDefinition.MiningEntry miningDef; if (voxelMaterial != null && _mining.MiningEntries.TryGetValue(voxelMaterial.Index, out miningDef)) { UpdateDurability(-1); Vector3 pos; CalculateCoords(voxelBase, Target.Position, out pos); MrzUtils.ShowNotificationDebug($"VoxelPainter::Request Paint - Position:{Target.Position} Radius:{Definition.PaintRadius} Material:{_fillMaterial}", 1000); if (MrzUtils.IsServer) { var plane = new Plane(pos, Target.Normal); plane.D = Definition.PaintDepth; DoOperationServer(voxelBase, pos, Definition.PaintRadius, plane); } //MyAPIGateway.Multiplayer.RaiseStaticEvent(x => DoOperationServer, OperationServer.CreateCut( // Holder.EntityId, voxelBase.EntityId, pos, Modified //)); } else { if (Holder == MySession.Static.PlayerEntity) { _wrongToolMessage.Show(); } } } catch (Exception e) { MrzUtils.ShowNotificationDebug(e.Message); } }
private static MyVoxelMaterialDefinition GetMaterial(string name) { MyVoxelMaterialDefinition def = MyDefinitionManager.Static.GetVoxelMaterialDefinition(name); if (def == null) { //Debug.Fail("Could not load voxel material " + name); MyLog.Default.WriteLine("Could not load voxel material " + name); } return(def); }
public void OverwriteAllMaterials(MyVoxelMaterialDefinition material) { MyPrecalcComponent.AssertUpdateThread(); using (m_storageLock.AcquireExclusiveUsing()) { m_compressedData = null; OverwriteAllMaterialsInternal(material); } OnRangeChanged(Vector3I.Zero, Size - 1, MyStorageDataTypeFlags.Material); }
public Vector3 GetColorShift(Vector3 position, byte material, float maxDepth = 1f) { if (maxDepth >= 1f) { int num; Vector2 vector2; List <PlanetOre> list; MyVoxelMaterialDefinition voxelMaterialDefinition = MyDefinitionManager.Static.GetVoxelMaterialDefinition(material); if ((voxelMaterialDefinition == null) || (voxelMaterialDefinition.ColorKey == null)) { return(Vector3.Zero); } MyCubemapHelpers.CalculateSampleTexcoord(ref position - this.m_planetShape.Center(), out num, out vector2); if (this.m_oreMap == null) { return(Vector3.Zero); } byte key = this.m_oreMap.Faces[num].GetValue(vector2.X, vector2.Y); if (!this.m_ores.TryGetValue(key, out list)) { return(Vector3.Zero); } float num3 = (float)MathHelper.Saturate(this.m_perlin.GetValue((double)(vector2.X * 1000f), (double)(vector2.Y * 1000f), 0.0)); using (List <PlanetOre> .Enumerator enumerator = list.GetEnumerator()) { while (true) { if (!enumerator.MoveNext()) { break; } PlanetOre current = enumerator.Current; float colorInfluence = current.ColorInfluence; colorInfluence = 256f; if ((colorInfluence >= 1f) && ((colorInfluence >= current.Start) && ((current.Start <= maxDepth) && (current.TargetColor != null)))) { Vector3 targetShift = current.TargetColor.Value; Color violet = Color.Violet; if (targetShift == Vector3.Backward) { targetShift = new Vector3(0f, 1f, -0.08f); } else { targetShift = this.m_targetShift; } return((Vector3)((num3 * targetShift) * (1f - (current.Start / colorInfluence)))); } } } } return(Vector3.Zero); }
internal void RecalculateDeposits() { ClearPositionsAndMaxContent(); int sizeInVoxels = MyVoxelConstants.DATA_CELL_SIZE_IN_VOXELS; Vector3I cellCoord; m_storage.ComputeCellCoord(m_cellIndex, out cellCoord); Vector3I voxelStartCoord = cellCoord * sizeInVoxels; Vector3I voxelEndCoord = voxelStartCoord + sizeInVoxels - 1; Debug.Assert(m_storage.IsInside(ref voxelStartCoord), "Incorrect position of deposit cell."); Debug.Assert(m_storage.IsInside(ref voxelEndCoord), "Incorrect position of deposit cell."); Vector3I 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_storage.GetContent(ref voxelCoord); if (content >= MyVoxelConstants.VOXEL_ISO_LEVEL) { MyVoxelMaterialDefinition material = m_storage.GetMaterial(ref voxelCoord); byte maxContent; m_helpersMaxContentForMaterial.TryGetValue((int)material.Index, out maxContent); if (!m_allMaterialsPositions.ContainsKey((int)material.Index) || content > maxContent) { if (!m_allMaterialsPositions.ContainsKey((int)material.Index)) { m_allMaterialsPositions.Add((int)material.Index, m_storage.GetVoxelPositionAbsolute(ref voxelCoord)); } else { m_allMaterialsPositions[(int)material.Index] = m_storage.GetVoxelPositionAbsolute(ref voxelCoord); } if (!m_helpersMaxContentForMaterial.ContainsKey((int)material.Index)) { m_helpersMaxContentForMaterial.Add((int)material.Index, content); } else { m_helpersMaxContentForMaterial[(int)material.Index] = content; } } } } } } }
public override MyVoxelMaterialDefinition GetMaterialForPosition(ref Vector3 pos, float lodSize) { Vector3 localPosition = pos - Shape.Center(); float lenghtToCenter = localPosition.Length(); if (lenghtToCenter < 0.01) { return(null); } float distance = m_planetShape.SampleField(ref pos); if (distance <= MyCsgPrecomputedHelpres.FROZEN_OCEAN_LEVEL && MyFakes.ENABLE_PLANET_FROZEN_SEA) { return(MyDefinitionManager.Static.GetVoxelMaterialDefinition("Ice_01")); } float originalDistance = m_planetShape.SignedDistanceUnchecked(ref pos, lodSize, null, null); if (lenghtToCenter <= m_oreDeposits.MinDepth) { MyVoxelMaterialDefinition definiton = m_oreDeposits.GetMaterialForPosition(ref pos, lodSize); if (definiton != null) { return(definiton); } } if (originalDistance < -2.0f) { return(MyDefinitionManager.Static.GetVoxelMaterialDefinition("Stone_01")); } Vector3I samplePos; Vector2 positon = Vector2.Zero; MyCsgPrecomputedHelpres.CalculateSamplePosition(ref localPosition, out samplePos, ref positon, m_resolution); byte materialData; m_reader[samplePos.X].Read(sizeof(int) + samplePos.Z * m_resolution + samplePos.Y, out materialData); byte material = (byte)(materialData & 127); byte spawns = (byte)(materialData & 128); var voxelMaterial = MyDefinitionManager.Static.GetVoxelMaterialDefinition(material); if (voxelMaterial != null) { voxelMaterial.SpawnsFlora = spawns == 0 ? false : true; } return(voxelMaterial); }
protected MyVoxelMaterialDefinition GetMaterialAt(Vector3I voxelPosition) { Object rawResult = InvokeEntityMethod(BackingObject, VoxelMapGetMaterialAtPositionMethod, new object[] { voxelPosition }); if (rawResult == null) { return(null); } MyVoxelMaterialDefinition result = (MyVoxelMaterialDefinition)rawResult; return(result); }
public Vector3?GetPosition(MyVoxelMaterialDefinition material) { if (m_positionIsDirty) { RecalculateDeposits(); m_positionIsDirty = false; } Vector3?pos; m_allMaterialsPositions.TryGetValue(material.Index, out pos); return(pos); }
public static MySingleMaterialHelper GetForMaterial(MyVoxelMaterialDefinition material) { if (m_preallocatedSingleMaterialHelpers[(int)material.Index] == null) { m_preallocatedSingleMaterialHelpers[(int)material.Index] = new MySingleMaterialHelper(); m_preallocatedSingleMaterialHelpers[(int)material.Index].LoadData(); m_preallocatedSingleMaterialHelpers[(int)material.Index].SetMaterial(material); } return(m_preallocatedSingleMaterialHelpers[(int)material.Index]); //m_singleMaterialHelper.SetMaterial(material); //return m_singleMaterialHelper; }
public static float CalculateAmount(MyVoxelMaterialDefinition material, float amount) { var oreObjBuilder = VRage.ObjectBuilders.MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_Ore>(material.MinedOre); oreObjBuilder.MaterialTypeName = material.Id.SubtypeId; float amountCubicMeters = (float)(((float)amount / (float)MyVoxelConstants.VOXEL_CONTENT_FULL) * MyVoxelConstants.VOXEL_VOLUME_IN_METERS * Sandbox.Game.MyDrillConstants.VOXEL_HARVEST_RATIO); amountCubicMeters *= (float)material.MinedOreRatio; var physItem = MyDefinitionManager.Static.GetPhysicalItemDefinition(oreObjBuilder); MyFixedPoint amountInItemCount = (MyFixedPoint)(amountCubicMeters / physItem.Volume); return((float)amountInItemCount); }