public void Init(MyObjectBuilder_ConveyorPacket builder, MyEntity parent)
        {
            Item         = new MyPhysicalInventoryItem(builder.Item);
            LinePosition = builder.LinePosition;

            var physicalItem = MyDefinitionManager.Static.GetPhysicalItemDefinition(Item.Content);

            var ore = Item.Content as MyObjectBuilder_Ore;

            string model = physicalItem.Model;
            float  scale = 1.0f;

            if (ore != null)
            {
                foreach (var mat in MyDefinitionManager.Static.GetVoxelMaterialDefinitions())
                {
                    if (mat.MinedOre == ore.SubtypeName)
                    {
                        model = MyDebris.GetRandomDebrisVoxel();
                        scale = (float)Math.Pow((float)Item.Amount * physicalItem.Volume / MyDebris.VoxelDebrisModelVolume, 0.333f);
                        break;
                    }
                }
            }

            if (scale < 0.05f)
            {
                scale = 0.05f;
            }
            else if (scale > 1.0f)
            {
                scale = 1.0f;
            }

            bool entityIdAllocationSuspended = MyEntityIdentifier.AllocationSuspended;

            MyEntityIdentifier.AllocationSuspended = false;
            Init(null, model, parent, null, null);
            MyEntityIdentifier.AllocationSuspended = entityIdAllocationSuspended;
            PositionComp.Scale = scale;

            // Packets are serialized by conveyor lines
            Save = false;
        }
Esempio n. 2
0
        public void Init(MyObjectBuilder_ConveyorPacket builder, MyEntity parent)
        {
            Item = new MyPhysicalInventoryItem(builder.Item);
            LinePosition = builder.LinePosition;

            var physicalItem = MyDefinitionManager.Static.GetPhysicalItemDefinition(Item.Content);

            var ore = Item.Content as MyObjectBuilder_Ore;

            string model = physicalItem.Model;
            float scale = 1.0f;
            if (ore != null)
            {
                foreach (var mat in MyDefinitionManager.Static.GetVoxelMaterialDefinitions())
                {
                    if (mat.MinedOre == ore.SubtypeName)
                    {
                        model = MyDebris.GetRandomDebrisVoxel();
                        scale = (float)Math.Pow((float)Item.Amount * physicalItem.Volume / MyDebris.VoxelDebrisModelVolume, 0.333f);
                        break;
                    }
                }
            }

            if (scale < 0.05f)
                scale = 0.05f;
            else if (scale > 1.0f)
                scale = 1.0f;

            bool entityIdAllocationSuspended = MyEntityIdentifier.AllocationSuspended;
            MyEntityIdentifier.AllocationSuspended = false;
            Init(null, model, parent, null, null);
            MyEntityIdentifier.AllocationSuspended = entityIdAllocationSuspended;
            PositionComp.Scale = scale;

            // Packets are serialized by conveyor lines
            Save = false;
        }