コード例 #1
0
        bool CheckTorpedo(Torpedo torpedo, out string output)
        {
            var OK = true;

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("======== ERRORS ========");

            if (torpedo.Controller == null)
            {
                builder.AppendLine("=> NO REMOTE CONTROL!");
            }
            if (torpedo.Thrusters.Count == 0)
            {
                builder.AppendLine("=> NO THRUSTERS!");
            }
            if (torpedo.SubTorpedos.Count > torpedo.Splitters.Count)
            {
                builder.AppendLine("=> CANNOT SEPARATE CLUSTER!");
            }
            if (Base == null)
            {
                builder.AppendLine("=> BASE MISSING!");
                OK = false;
            }

            builder.AppendLine("======== WARNINGS ========");

            if (torpedo.Cameras.Count == 0)
            {
                builder.AppendLine("=> No camera.");
            }
            if (torpedo.Sensor == null)
            {
                builder.AppendLine("=> No sensor.");
            }
            if (torpedo.Fuse == null)
            {
                builder.AppendLine("=> No fuse.");
            }
            if (torpedo.Warheads == null)
            {
                builder.AppendLine("=> No warheads (OK for kinetic or trainer).");
            }

            foreach (var torp in torpedo.SubTorpedos)
            {
                builder.AppendLine();
                builder.AppendLine($"Cluster Missile {torp.Tag}");
                string suboutput;
                OK &= CheckTorpedo(torp, out suboutput);
                builder.Append(suboutput);
            }

            output = builder.ToString();
            return(torpedo.OK() && OK);
        }