コード例 #1
0
            public override void SetBlock(SuperBlock block)
            {
                base.SetBlock(block, TBlockSubtypes.GunBase);

                if (subtype != null)
                {
                    ammoTypes.Clear();
                    (subtype.AmmoInventory as IMyInventory).GetAcceptedItems(ammoTypes);

                    AmmoName.Clear();
                    TerminalUtilities.GetBeautifiedTypeID(AmmoTypes[0].SubtypeId, AmmoName);
                }
            }
コード例 #2
0
        /// <summary>
        /// Retrieves a Block Property's Terminal Name.
        /// </summary>
        private static void GetTooltipName(ITerminalProperty prop, StringBuilder dst)
        {
            var tooltip = prop as IMyTerminalControlTitleTooltip;

            if (tooltip != null)
            {
                StringBuilder name = MyTexts.Get(tooltip.Title);

                // Exclude leading spaces
                int start = 0;

                for (int i = 0; i < name.Length; i++)
                {
                    if (name[i] > ' ')
                    {
                        break;
                    }

                    start++;
                }

                dst.EnsureCapacity(name.Length - start);

                for (int n = start; n < name.Length; n++)
                {
                    char ch     = name[n],
                         nextCh = name[Math.Min(n + 1, name.Length - 1)];

                    if (
                        // Exclude special chars and most punctuation
                        (ch == ' ' || ch >= 'A' || (ch >= '0' && ch <= '9'))
                        // Exclude repeating and trailing spaces
                        && !(nextCh == ' ' && ch == ' '))
                    {
                        dst.Append(ch);
                    }
                }
            }
            else
            {
                TerminalUtilities.GetBeautifiedTypeID(prop.Id, dst);
            }
        }