public MyDebugRenderCompomentDrawDrillBase(MyDrillBase drillBase):base(null)
 {
     m_drillBase = drillBase;
 }
Exemple #2
0
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            if (objectBuilder.SubtypeName != null && objectBuilder.SubtypeName.Length > 0)
            {
                PhysicalObject = MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_PhysicalGunObject>(objectBuilder.SubtypeName + "Item");
                m_physItemDef  = MyDefinitionManager.Static.GetPhysicalItemDefinition(new MyDefinitionId(typeof(MyObjectBuilder_PhysicalGunObject), objectBuilder.SubtypeName + "Item"));
            }
            else
            {
                PhysicalObject = MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_PhysicalGunObject>("HandDrillItem");
                m_physItemDef  = MyDefinitionManager.Static.GetPhysicalItemDefinition(new MyDefinitionId(typeof(MyObjectBuilder_PhysicalGunObject), "HandDrillItem"));
            }

            (PositionComp as MyPositionComponent).WorldPositionChanged = WorldPositionChanged;

            m_handItemDefId = objectBuilder.GetId();

            var definition = MyDefinitionManager.Static.TryGetHandItemDefinition(ref m_handItemDefId);

            m_speedMultiplier = 1f / (definition as MyHandDrillDefinition).SpeedMultiplier;
            m_drillBase       = new MyDrillBase(this,
                                                MyDrillConstants.DRILL_HAND_DUST_EFFECT,
                                                MyDrillConstants.DRILL_HAND_DUST_STONES_EFFECT,
                                                MyDrillConstants.DRILL_HAND_SPARKS_EFFECT,
                                                new MyDrillSensorRayCast(-0.5f, 1.8f),
                                                new MyDrillCutOut(0.5f, 0.35f * (definition as MyHandDrillDefinition).DistanceMultiplier),
                                                SPIKE_SLOWDOWN_TIME_IN_SECONDS,
                                                floatingObjectSpawnOffset: -0.25f,
                                                floatingObjectSpawnRadius: 1.4f * 0.25f
                                                );
            m_drillBase.VoxelHarvestRatio = MyDrillConstants.VOXEL_HARVEST_RATIO * (definition as MyHandDrillDefinition).HarvestRatioMultiplier;
            AddDebugRenderComponent(new Components.MyDebugRenderCompomentDrawDrillBase(m_drillBase));
            base.Init(objectBuilder);

            var physDefinition = MyDefinitionManager.Static.GetPhysicalItemDefinition(definition.PhysicalItemId);

            Init(null, physDefinition.Model, null, null, null);
            Render.CastShadows            = true;
            Render.NeedsResolveCastShadow = false;

            m_spike        = Subparts["Spike"];
            m_spikeBasePos = m_spike.PositionComp.LocalMatrix.Translation;

            m_drillBase.IgnoredEntities.Add(this);
            m_drillBase.OnWorldPositionChanged(PositionComp.WorldMatrix);

            PhysicalObject.GunEntity          = (MyObjectBuilder_EntityBase)objectBuilder.Clone();
            PhysicalObject.GunEntity.EntityId = this.EntityId;

            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
            m_oreDetectorBase.DetectionRadius = 20;
            m_oreDetectorBase.OnCheckControl  = OnCheckControl;

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                MyStringHash.GetOrCompute("Utility"),
                MyEnergyConstants.REQUIRED_INPUT_HAND_DRILL,
                () => m_tryingToDrill ? SinkComp.MaxRequiredInput : 0f);
            SinkComp = sinkComp;

            foreach (ToolSound toolSound in definition.ToolSounds)
            {
                if (toolSound.type == null || toolSound.subtype == null || toolSound.sound == null)
                {
                    continue;
                }
                if (toolSound.type.Equals("Main"))
                {
                    if (toolSound.subtype.Equals("Idle"))
                    {
                        m_drillBase.m_idleSoundLoop = new MySoundPair(toolSound.sound);
                    }
                    if (toolSound.subtype.Equals("Soundset"))
                    {
                        m_drillBase.m_drillMaterial = MyStringHash.GetOrCompute(toolSound.sound);
                    }
                }
            }
        }
Exemple #3
0
        public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
        {
            m_defId = builder.GetId();
            var def = MyDefinitionManager.Static.GetCubeBlockDefinition(m_defId) as MyShipDrillDefinition;

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                def.ResourceSinkGroup,
                ComputeMaxRequiredPower(),
                ComputeRequiredPower);
            ResourceSink = sinkComp;

            m_drillBase = new MyDrillBase(this,
                                          MyDrillConstants.DRILL_SHIP_DUST_EFFECT,
                                          MyDrillConstants.DRILL_SHIP_DUST_STONES_EFFECT,
                                          MyDrillConstants.DRILL_SHIP_SPARKS_EFFECT,
                                          new MyDrillSensorSphere(def.SensorRadius, def.SensorOffset),
                                          new MyDrillCutOut(def.SensorOffset, def.SensorRadius),
                                          HEAD_SLOWDOWN_TIME_IN_SECONDS,
                                          floatingObjectSpawnOffset: -0.4f,
                                          floatingObjectSpawnRadius: 0.4f,
                                          inventoryCollectionRatio: 0.7f
                                          );

            base.Init(builder, cubeGrid);

            m_blockLength    = def.Size.Z;
            m_cubeSideLength = MyDefinitionManager.Static.GetCubeSize(def.CubeSize);

            float   inventoryVolume = def.Size.X * def.Size.Y * def.Size.Z * m_cubeSideLength * m_cubeSideLength * m_cubeSideLength * 0.5f;
            Vector3 inventorySize   = new Vector3(def.Size.X, def.Size.Y, def.Size.Z * 0.5f);

            if (this.GetInventory() == null)
            {
                Components.Add <MyInventoryBase>(new MyInventory(inventoryVolume, inventorySize, MyInventoryFlags.CanSend, this));
            }
            Debug.Assert(this.GetInventory().Owner == this, "Ownership was not set!");

            this.GetInventory().Constraint = new MyInventoryConstraint(MySpaceTexts.ToolTipItemFilter_AnyOre)
                                             .AddObjectBuilderType(typeof(MyObjectBuilder_Ore));

            SlimBlock.UsesDeformation  = false;
            SlimBlock.DeformationRatio = def.DeformationRatio; // 3x times harder for destruction by high speed


            m_drillBase.OutputInventory = this.GetInventory();
            m_drillBase.IgnoredEntities.Add(this);
            m_drillBase.OnWorldPositionChanged(WorldMatrix);
            m_wantsToCollect = false;
            AddDebugRenderComponent(new Components.MyDebugRenderCompomentDrawDrillBase(m_drillBase));


            ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink.Update();

            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawPowerReciever(ResourceSink, this));

            var obDrill = (MyObjectBuilder_Drill)builder;

            this.GetInventory().Init(obDrill.Inventory);

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            m_useConveyorSystem.Value = obDrill.UseConveyorSystem;

            UpdateDetailedInfo();

            m_wantsToDrill    = obDrill.Enabled;
            IsWorkingChanged += OnIsWorkingChanged;

            m_drillBase.m_drillMaterial = MyStringHash.GetOrCompute("ShipDrill");
            m_drillBase.m_idleSoundLoop = new MySoundPair("ToolShipDrillIdle");
        }