예제 #1
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();
            m_drillBase.UpdateAfterSimulation();

            if (IsShooting)
            {
                CreateCollisionSparks();
            }

            if (m_drillBase.IsDrilling || m_drillBase.AnimationMaxSpeedRatio > 0f)
            {
                float timeDelta = (MySandboxGame.TotalGamePlayTimeInMilliseconds - m_spikeLastUpdateTime) / 1000f;

                if (m_objectInDrillingRange && Owner != null && Owner.ControllerInfo.IsLocallyControlled() && (Owner.IsInFirstPersonView || Owner.ForceFirstPersonCamera))
                {
                    m_drillBase.PerformCameraShake();
                }



#if ROTATE_DRILL_SPIKE
                m_spikeRotationAngle += timeDelta * m_drillBase.AnimationMaxSpeedRatio * SPIKE_MAX_ROTATION_SPEED;
                if (m_spikeRotationAngle > MathHelper.TwoPi)
                {
                    m_spikeRotationAngle -= MathHelper.TwoPi;
                }
                if (m_spikeRotationAngle < MathHelper.TwoPi)
                {
                    m_spikeRotationAngle += MathHelper.TwoPi;
                }
#endif

                m_spikeThrustPosition += timeDelta * m_drillBase.AnimationMaxSpeedRatio / SPIKE_THRUST_PERIOD_IN_SECONDS;
                if (m_spikeThrustPosition > 1.0f)
                {
                    m_spikeThrustPosition -= 2.0f;
                    if (Owner != null && m_objectInDrillingRange)
                    {
                        Owner.WeaponPosition.AddBackkick(0.035f);
                    }
                }

                m_spikeLastUpdateTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;

                m_spike.PositionComp.LocalMatrix =
#if ROTATE_DRILL_SPIKE
                    Matrix.CreateRotationZ(m_spikeRotationAngle) *
#endif
                    Matrix.CreateTranslation(m_spikeBasePos + Math.Abs(m_spikeThrustPosition) * Vector3.UnitZ * SPIKE_THRUST_DISTANCE_HALF);
            }

            //MyTrace.Watch("MyHandDrill.RequiredPowerInput", RequiredPowerInput);
        }
예제 #2
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            m_drillBase.UpdateAfterSimulation();

            if (WantsToDrill || m_drillBase.AnimationMaxSpeedRatio > 0f)
            {
                if (Owner != null && Owner.ControllerInfo.IsLocallyControlled() && MySession.Static.CameraController != null &&
                    (MySession.Static.CameraController.IsInFirstPersonView || MySession.Static.CameraController.ForceFirstPersonCamera) &&
                    HasObjectInDrillingRange())
                {
                    m_drillBase.PerformCameraShake();
                }

                if (MySession.Static.EnableToolShake && MyFakes.ENABLE_TOOL_SHAKE)
                {
                    ApplyShakeForce();
                }

                if (WantsToDrill)
                {
                    CheckDustEffect();
                }

                float timeDelta          = (MySandboxGame.TotalGamePlayTimeInMilliseconds - m_headLastUpdateTime) / 1000f;
                float rotationDeltaAngle = timeDelta * m_drillBase.AnimationMaxSpeedRatio * HEAD_MAX_ROTATION_SPEED;

                m_headLastUpdateTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;

                var rotationDeltaMatrix = Matrix.CreateRotationZ(rotationDeltaAngle);
                foreach (var subpart in Subparts)
                {
                    subpart.Value.PositionComp.LocalMatrix = subpart.Value.PositionComp.LocalMatrix * rotationDeltaMatrix;
                }
            }
            else
            {
                // Don't want to drill and animation speed has hit 0, we can stop updating the drills every frame now
                NeedsUpdate &= ~MyEntityUpdateEnum.EACH_FRAME;
            }
        }