Ejemplo n.º 1
0
        public virtual void Update()
        {
            m_updateCount++;
            if (!m_started && MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds - m_startTime > m_waitTime)
            {
                m_started      = true;
                m_cubeEntityId = m_targetBlock.CubeGrid.EntityId;
                m_position     = m_targetBlock.Position;

                if (Sync.IsClient)
                {
                    NaniteConstructionManager.ParticleManager.AddParticle(m_cubeEntityId, m_position, MyParticleEffectsNameEnum.WelderFlame);
                }
                else
                {
                    m_constructionBlock.SendStartParticleEffect(m_cubeEntityId, m_position, 27);
                }
            }

            if (MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds - m_startTime > m_waitTime + m_completeTime && m_isGrinder)
            {
                Complete();
                return;
            }

            if (m_started && m_updateCount % 240 == 0)
            {
                //if(m_isGrinder)
                //GrindTarget();
                if (!m_isGrinder)
                {
                    WeldTarget();
                }
            }
        }
Ejemplo n.º 2
0
        public virtual void Update()
        {
            if (m_performanceFriendly)
            {
                if (!m_started && MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds - m_startTime > m_waitTime)
                {
                    m_started = true;

                    m_cubeEntityId = m_targetBlock.CubeGrid.EntityId;
                    m_position     = m_targetBlock.Position;

                    if (Sync.IsClient)
                    {
                        NaniteConstructionManager.ParticleManager.AddParticle(m_cubeEntityId, m_position, 27);
                    }
                    else
                    {
                        m_constructionBlock.SendStartParticleEffect(m_cubeEntityId, m_position, 27);
                    }
                }

                if (MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds - m_startTime > m_waitTime + m_completeTime)
                {
                    Complete(!m_isGrinder);
                }

                return;
            }

            if (m_targetBlock.IsDestroyed)
            {
                if (m_tool != null && !m_tool.Closed && m_tool.Enabled)
                {
                    m_tool.Enabled = false;
                }

                return;
            }

            if (m_toolEntity.Closed)
            {
                return;
            }

            // This moves the tool to the position of the target even if the parent cube moves.
            Vector3D targetBlockPosition;

            if (m_targetBlock.FatBlock != null)
            {
                targetBlockPosition = m_targetBlock.FatBlock.PositionComp.GetPosition();
            }
            else
            {
                targetBlockPosition = Vector3D.Transform(m_targetBlock.Position * (m_targetBlock.CubeGrid.GridSizeEnum == MyCubeSize.Small ? 0.5f : 2.5f), m_targetBlock.CubeGrid.WorldMatrix);
            }

            if (m_toolEntity != null && !m_toolEntity.Closed && m_toolEntity.PositionComp.GetPosition() != targetBlockPosition)
            {
                m_toolEntity.SetPosition(targetBlockPosition);
            }

            if (m_completed)
            {
                return;
            }

            if (m_started) //(int)MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds - m_lastToolUse > 30 && m_started)
            {
                m_lastToolUse = (int)MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds;
                ToggleToolStatus();
            }

            if (MyAPIGateway.Session.ElapsedPlayTime.TotalMilliseconds - m_startTime > m_waitTime)
            {
                if (m_started)
                {
                    return;
                }

                m_started = true;
            }
        }