public static bool CheckGeneral(this CompDecorate comp) { bool OneError = false; if (OneError |= !comp.CheckParentIsBuilding()) { Tools.Warn("this comp is meant for a building, this will fail", comp.DebugCheck); } if (OneError |= !comp.CheckPropertiesNotEmpty()) { Tools.Warn("Properties are empty, this will fail", comp.DebugCheck); } if (OneError |= !comp.CheckMoteDecoration()) { Tools.Warn("At least one item lacks a proper <moteDef></moteDef> <label></label> or has non unique label or no <tranformation/>", comp.DebugCheck); } if (OneError) { Tools.Warn("At least one error, it will most likely fail", comp.DebugCheck); } else { Tools.Warn("No error in the parameters, congraturations", comp.DebugCheck); } return(OneError); }
public static bool FuelAndPowerValidation(this CompDecorate comp) { if (comp.CurItem.RequiresNeitherFuelNorPowerCheck) { Tools.Warn(comp.CurItem.label + " does not require fuel or power check; ok", comp.CurItem.debug); return(true); } if (comp.RequiresFuelAndPowerCheck && (!comp.HasPowerOn || !comp.IsFueled)) { Tools.Warn(comp.CurItem.label + " requires fuel or power check; but one is not ok; ko", comp.CurItem.debug); return(false); } if (comp.RequiresFuelCheck && !comp.IsFueled) { Tools.Warn(comp.CurItem.label + " requires fuel check; but not fueled; ko", comp.CurItem.debug); return(false); } if (comp.RequiresPowerCheck && !comp.HasPowerOn) { Tools.Warn(comp.CurItem.label + " requires power check; but no power; ko", comp.CurItem.debug); return(false); } Tools.Warn(comp.CurItem.label + " fuel and power check; ok", comp.CurItem.debug); return(true); }
public static bool UpdateReservationAndWorker(this CompDecorate comp) { bool DoHaveReservation = comp.UpdateReservation() && comp.UpdateWorker(); Tools.Warn(comp.parent.LabelShort + " >> reservation: " + DoHaveReservation + " worker: " + comp.Worker?.LabelShort, comp.MyDebug); return(DoHaveReservation); }
public static bool NonCoexistingMoteInTracer(this CompDecorate comp) { return (comp.HasLivingMotes && comp.LivingMotes.Any( LM => LM.ForbidsCoexistWithAny )); }
public static bool DifferentMoteExists(this CompDecorate comp) { return (comp.HasLivingMotes && comp.LivingMotes.Any( LM => LM.LabelsNoMatch(comp.CurItem) )); }
public static void MaybeUpdateReservations(this CompDecorate comp) { if (!comp.RequiresReservationUpdate || !comp.IsTimeToUpdate) { return; } comp.UpdateReservationAndWorker(); }
public static bool SameMoteAlreadyExists(this CompDecorate comp) { return (comp.HasLivingMotes && comp.LivingMotes.Any( LM => LM.LabelsMatch(comp.CurItem) )); }
public static bool SameMoteWithGraceInTracer(this CompDecorate comp) { return (comp.CurItem.HasGraceTicks && comp.LivingMotes.Any( LM => LM.HasRemainingGraceTicks && LM.LabelsMatch(comp.CurItem) )); }
public static bool UpdateReservation(this CompDecorate comp) { comp.reservations = comp.parent.Map.reservationManager.ReservationsReadOnly.Where( r => r.Target == new LocalTargetInfo(comp.parent) && r.Faction == Faction.OfPlayer ); return(comp.IsReserved); }
public static bool CheckMoteDecoration(this CompDecorate comp) { bool OneError = false; foreach (MoteDecoration md in comp.ItemList) { OneError |= md.IsInvalid; OneError |= comp.ItemList.Any(IL => IL != md && IL.label == md.label); OneError |= md.transformation == null; } return(!OneError); }
public static bool ReservationIsItemCompatible(this CompDecorate comp) { if (!comp.IsReserved) { return(false); } if (comp.FirstReservation == null) { return(false); } ReservationManager.Reservation resItem = comp.FirstReservation; bool compatible = true; if (comp.CurItem.condition.HasIncludedJob) { if (!(compatible &= comp.CurItem.condition.includeJob.Contains(resItem.Job.def))) { return(false); } } if (comp.CurItem.condition.HasExcludedJob) { if (!(compatible &= !comp.CurItem.condition.excludeJob.Contains(resItem.Job.def))) { return(false); } } if (comp.CurItem.condition.HasIncludedRecipe && resItem.Job.RecipeDef != null) { if (!(compatible &= comp.CurItem.condition.includeRecipe.Contains(resItem.Job.RecipeDef))) { return(false); } } if (comp.CurItem.condition.HasExcludedRecipe && resItem.Job.RecipeDef != null) { if (!(compatible &= !comp.CurItem.condition.excludeRecipe.Contains(resItem.Job.RecipeDef))) { return(false); } } return(compatible); }
public static bool GraceValidation(this CompDecorate comp) { if (!comp.CurItem.HasGraceTicks) { Tools.Warn(comp.CurItem.label + " does not require gracetick check; ok", comp.CurItem.debug); return(true); } if (comp.SameMoteWithGraceInTracer()) { Tools.Warn(comp.CurItem.label + " found same item type with graceTicks; ko", comp.CurItem.debug); return(false); } Tools.Warn(comp.CurItem.label + " grace check ok", comp.CurItem.debug); return(true); }
public static bool AllConditionsValidation(this CompDecorate comp) { if (comp.CurItem.HasNoCondition) { return(true); } if ((comp.CurItem.forbidsSomeCoexist || comp.CurItem.HasGraceTicks) && comp.HasEmptyTracer) { Tools.Warn("Empty tracer -> ok", comp.CurItem.debug); } else { if (!comp.CoexistingValidation()) { Tools.Warn("coexistance invalidation -> ko", comp.CurItem.debug); return(false); } if (!comp.GraceValidation()) { Tools.Warn("grace invalidation -> ko", comp.CurItem.debug); return(false); } } if (!comp.FuelAndPowerValidation()) { Tools.Warn("Fuel And power invalidation -> ko", comp.CurItem.debug); return(false); } if (!comp.ReservationValidation()) { Tools.Warn("reservation invalidation -> ko", comp.CurItem.debug); return(false); } return(true); }
public static bool ReservationValidation(this CompDecorate comp) { if (!comp.CurItem.RequiresReservationCheck) { Tools.Warn(comp.CurItem.label + " did not require a reservation check ; ok", comp.CurItem.debug); return(true); } if (comp.CurItem.condition.ifWorker && !comp.HasWorker) { Tools.Warn(comp.CurItem.label + " has no worker; ko", comp.CurItem.debug); return(false); } //if (!comp.IsOccupied) if (comp.CurItem.condition.ifWorkerOnInteractionCell && !comp.HasWorkerOnInteractionCell) { Tools.Warn(comp.CurItem.label + " has no worker on interaction cell ; ko", comp.CurItem.debug); return(false); } if (comp.CurItem.condition.ifWorkerTouch && !comp.HasWorkerTouchingBuilding) { Tools.Warn( comp.CurItem.label + " has no worker touching building; " + comp.Worker.Position + "-" + comp.GetBuilding.Position + " - " + comp.GetBuilding.OccupiedRect().AdjacentCells.Contains(comp.Worker.Position) + //" - " + comp.Worker.Position.IsAdjacentToCardinalOrInside(comp.GetBuilding.OccupiedRect()) + " ko", comp.CurItem.debug); return(false); } if (!comp.ReservationIsItemCompatible()) { Tools.Warn(comp.CurItem.label + " is not compatible with reservation ; ko", comp.CurItem.debug); return(false); } Tools.Warn(comp.CurItem.label + " reservation ok", comp.CurItem.debug); return(true); }
public static bool CoexistingValidation(this CompDecorate comp) { if (comp.CurItem.allowsCoexistWithAny) { Tools.Warn(comp.CurItem.label + " coexists with all motes; ok", comp.CurItem.debug); return(true); } if (comp.CurItem.forbidsCoexistWithOther && comp.DifferentMoteExists()) { Tools.Warn(comp.CurItem.label + " forbids other motes and some exist; ko", comp.CurItem.debug); return(false); } if (comp.CurItem.forbidsCoexistWithSame && comp.SameMoteAlreadyExists()) { Tools.Warn(comp.CurItem.label + " forbids same motes and some exist; ko", comp.CurItem.debug); return(false); } Tools.Warn(comp.CurItem.label + " coexist check ok", comp.CurItem.debug); return(true); }
public static bool UpdateWorker(this CompDecorate comp) { comp.Worker = comp.IsReserved ? comp.FirstReservation.Claimant : null; return(comp.HasWorker); }
public static void MoteTracerMaintenanceRemoval(this CompDecorate comp) { comp.LivingMotes.RemoveAll(MT => MT.MoteIsDead()); }
public static void AddMoteTracer(this CompDecorate comp, string nLabel, Thing nThing, int nGrace, bool nCoexistSame, bool nCoexistOther) { comp.LivingMotes.Add(new MoteTracer(nLabel, nThing, nGrace, nCoexistSame, nCoexistOther)); }
public static bool CheckParentIsBuilding(this CompDecorate comp) { return(comp.parent is Building); }
public static bool CheckPropertiesNotEmpty(this CompDecorate comp) { return(!comp.EmptyParameters); }