public void CheckState(Errors errors, string owningModuleName) { if (governing == null) { errors.Warnings.Add(new Message("Governing rotor of module {0} is missing.", owningModuleName)); } else if (!governing.IsOperational()) { errors.Warnings.Add(new Message("Governing rotor {0} of module {1} is not operational.", governing.CustomName, owningModuleName)); } else if (!governing.IsAttached) { errors.Warnings.Add(new Message("Governing rotor {0} of module {1} is not attached.", governing.CustomName, owningModuleName)); } if (opposing == null) { errors.Warnings.Add(new Message("Opposing rotor of module {0} is missing.", owningModuleName)); } else if (!opposing.IsOperational()) { errors.Warnings.Add(new Message("Opposing rotor {0} of module {1} is not operational.", opposing.CustomName, owningModuleName)); } else if (!opposing.IsAttached) { errors.Warnings.Add(new Message("Opposing rotor {0} of module {1} is not attached.", opposing.CustomName, owningModuleName)); } if (!IsViable) { return; } if (governing?.IsAttached == true && opposing?.IsAttached == true) { if (governing.TopGrid != opposing.TopGrid) { errors.SanityChecks.Add(new Message("Rotors of module {0} connect to different subgrids ({1} and {2}).", owningModuleName, governing.TopGrid.CustomName, opposing.TopGrid.CustomName)); } else { var governingDegrees = MathHelper.ToDegrees(governing.Angle); var opposedDegrees = RotorLimits.OpposedAngleDegrees(MathHelper.ToDegrees(opposing.Angle)); var rotorOffset = RotorLimits.DifferenceDegrees(governingDegrees, opposedDegrees); if (rotorOffset > 1) { errors.SanityChecks.Add(new Message("Rotors of module {0} are not properly synchronised: {1}.", owningModuleName, rotorOffset)); } } } if (!ValidateLimits(CurrentAngleDegrees)) { errors.SafetyConcerns.Add(new Message("Rotors of module {0} are outside of set limits.", owningModuleName)); } }
private bool IsDrillViable() { if (!pistonGroup.IsViable) { return(false); } if (!drillHead.IsViable) { return(false); } if (rotor?.IsOperational() != true) { return(false); } return(true); }
public void Describe(StringBuilder builder) { builder.AppendLine(DescribeState(state)); // Pistons: builder.AppendFormat("Pistons: {0} / {1} ", pistonGroup.Operable, pistonGroup.Total); if (pistonGroup.IsViable) { builder.Append(pistonGroup.IsExtending ? $"Extending, {pistonGroup.ExtensionPercentage:P}" : pistonGroup.IsRetracting ? $"Retracting, {pistonGroup.ExtensionPercentage:P}" : "Stopped"); } else { builder.Append("DAMAGED"); } builder.AppendLine(); // Rotor: builder.Append("Rotor: "); if (rotor == null) { builder.Append("MISSING"); } else if (rotor.IsOperational()) { builder.Append(IsRotorRunning() ? "Running" : "Stopped"); } else { builder.Append("DAMAGED"); } builder.AppendLine(); // Drills: builder.AppendFormat("Drills: {0} / {1} ", drillHead.Operable, drillHead.Total); if (drillHead.IsViable) { builder.Append(drillHead.IsDrilling ? "Drilling" : "Stopped"); } else { builder.Append("DAMAGED"); } builder.AppendLine(); // Clamps: builder.AppendFormat("Clamps: {0} / {1} ", clampGroup.Operable, clampGroup.Total); if (clampGroup.IsViable) { builder.Append(clampGroup.AnyLocked ? $"Locked, {clampGroup.Locked}" : "Unlocked"); } else { builder.Append("DAMAGED"); } builder.AppendLine(); // Lights: if (lights.Total > 0) { builder.AppendFormat("Lights: {0} / {1} ", lights.Operable, lights.Total); builder.Append(lights.SwitchedOn > 0 ? $"On, {lights.SwitchedOn}" : "Off"); builder.AppendLine(); } errors.Clear(); pistonGroup.CheckState(errors); errors.WriteTo(builder); }