Example #1
0
        private void WeldTarget()
        {
            if (m_targetBlock.HasDeformation)
            {
                m_targetBlock.FixBones(0f, 1f);
            }

            float        damage    = (MyAPIGateway.Session.WelderSpeedMultiplier * MyShipGrinderConstants.GRINDER_AMOUNT_PER_SECOND) * 8f * NaniteConstructionManager.Settings.ConstructionEfficiency;
            IMyInventory inventory = ((MyEntity)m_constructionBlock.ConstructionBlock).GetInventory();

            if (m_targetBlock.CanContinueBuild(inventory) || MyAPIGateway.Session.CreativeMode)
            {
                var functional = m_targetBlock as IMyFunctionalBlock;
                if (functional != null)
                {
                    Logging.Instance.WriteLine(string.Format("Functional block '{0}': {1}", functional.CustomName, functional.Enabled));
                    //if (functional.IsFunctional && !functional.Enabled)
                    if (!functional.Enabled)
                    {
                        Logging.Instance.WriteLine(string.Format("Requesting Enable: {0}", functional.CustomName));
                        functional.Enabled = true;
                    }
                }

                m_targetBlock.MoveItemsToConstructionStockpile(inventory);
                m_targetBlock.IncreaseMountLevel(damage, m_constructionBlock.ConstructionBlock.OwnerId, inventory, maxAllowedBoneMovement: 1.0f);
            }
        }
Example #2
0
        private void WeldTarget()
        {
            try
            {
                if (m_targetBlock == null)
                {
                    return;
                }

                if (m_targetBlock.HasDeformation)
                {
                    m_targetBlock.FixBones(0f, 1f);
                }

                float        damage    = (MyAPIGateway.Session.WelderSpeedMultiplier * MyShipGrinderConstants.GRINDER_AMOUNT_PER_SECOND) * 8f * NaniteConstructionManager.Settings.ConstructionEfficiency;
                IMyInventory inventory = ((MyEntity)m_constructionBlock.ConstructionBlock).GetInventory();
                if (m_targetBlock.CanContinueBuild(inventory) || MyAPIGateway.Session.CreativeMode)
                {
                    var functional = m_targetBlock as IMyFunctionalBlock;
                    if (functional != null && !functional.Enabled)
                    {
                        functional.Enabled = true;
                    }

                    m_targetBlock.MoveItemsToConstructionStockpile(inventory);
                    m_targetBlock.IncreaseMountLevel(damage, m_constructionBlock.ConstructionBlock.OwnerId, inventory, maxAllowedBoneMovement: 1.0f);
                }
            }
            catch (Exception e)
            { Logging.Instance.WriteLine($"{e}"); }
        }