コード例 #1
0
        private void UpdateZoneStatistics(IMyTextSurface textSurface, IReadOnlyDictionary <String, EntityState> zones)
        {
            var builder    = new StringBuilder();
            var zonestatus = new List <String>();
            var gridType   = "Ship";

            if (Me.CubeGrid.IsStatic)
            {
                gridType = "Station";
            }

            var zonepad = gridType.Length;

            if (zones.Any())
            {
                zonepad = Math.Max(zones.Max(z => z.Key.Length), gridType.Length);
            }

            builder.Append($"{gridType.PadLeft(zonepad)} ");

            if (GridState.HasFlag(EntityState.Destruct))
            {
                zonestatus.Add("Self Destruct");
            }

            if (GridState.HasFlag(EntityState.Battle))
            {
                zonestatus.Add("Battle Stations");
            }

            if (GridState.HasFlag(EntityState.LowPower))
            {
                zonestatus.Add("Low Power");
            }

            builder.AppendLine(String.Join(", ", zonestatus.DefaultIfEmpty("Normal")));

            foreach (var zone in zones.OrderBy(z => z.Key))
            {
                zonestatus.Clear();
                builder.Append($"{zone.Key.PadLeft(zonepad)} ");

                if (zone.Value.HasFlag(EntityState.Decompress))
                {
                    zonestatus.Add("Decompressed");
                }

                if (zone.Value.HasFlag(EntityState.Intruder))
                {
                    zonestatus.Add("Intruder");
                }

                builder.AppendLine(String.Join(", ", zonestatus.DefaultIfEmpty("Normal")));
            }

            textSurface.DrawScaledSpriteText(builder, textSurface.Font, textSurface.FontColor);
        }