Exemplo n.º 1
0
        public static Dictionary <string, int> ReadMissingComponents(this IMySlimBlock Block)
        {
            Dictionary <string, int> MissingList = new Dictionary <string, int>();

            Block.ReadMissingComponents(MissingList);
            return(MissingList);
        }
Exemplo n.º 2
0
        void PrintMissing(HashSet <IMySlimBlock> UnbuiltBlocks)
        {
            //if (UnbuiltBlocks == null || UnbuiltBlocks.Count == 0) return;
            var Player = MyAPIGateway.Session.Player;

            if (Player == null)
            {
                return;
            }
            if (Player.IdentityId != Tool.OwnerId)
            {
                return;
            }
            if (Player.GetPosition().DistanceTo(Tool.GetPosition()) > 1000)
            {
                return;
            }

            StringBuilder Text = new StringBuilder();

            Text.AppendLine($"Performance impact: {(RunTimesAvailable ? Math.Round(AvgRunTime, 4).ToString() : "--")}/{(RunTimesAvailable ? Math.Round(MaxRunTime, 4).ToString() : "--")} ms (avg/max)");
            if (UnbuiltBlocks.Count == 1)
            {
                IMySlimBlock Block = UnbuiltBlocks.First();
                Text.AppendLine($"{Tool.CustomName}: can't proceed to build {Block.BlockDefinition.DisplayNameText}, missing:\n");
                var Missing = Block.ReadMissingComponents();
                foreach (var ItemPair in Missing)
                {
                    Text.AppendLine($"{ItemPair.Key}: {ItemPair.Value}");
                }
            }
            else if (UnbuiltBlocks.Count > 1)
            {
                Text.AppendLine($"{Tool.CustomName}: can't proceed to build {UnbuiltBlocks.Count} blocks:\n");
                foreach (IMySlimBlock Block in UnbuiltBlocks)
                {
                    var Missing = Block.ReadMissingComponents();
                    Text.AppendLine($"{Block.BlockDefinition.DisplayNameText}: missing:");
                    foreach (var ItemPair in Missing)
                    {
                        Text.AppendLine($"{ItemPair.Key}: {ItemPair.Value}");
                    }
                    Text.AppendLine();
                }
            }
            Text.RemoveTrailingNewlines();
            IMyHudNotification hud = MyAPIGateway.Utilities.CreateNotification(Text.ToString(), (int)(SessionCore.TickLengthMs * (SessionCore.WorkSkipTicks + 1)), "Red"); // Adding 1 excess tick is needed, otherwise notification can flicker

            hud.Show();
        }