public static bool AllowAction(EventPack ep) { if (!TutorialMode) { return(true); } if (DebugViewSettings.logTutor) { Log.Message("AllowAction: " + ep); } if (ep.Cells != null && ep.Cells.Count() == 1) { return(AllowAction(new EventPack(ep.Tag, ep.Cells.First()))); } if (Find.ActiveLesson.Current != null) { AcceptanceReport acceptanceReport = Find.ActiveLesson.Current.AllowAction(ep); if (!acceptanceReport.Accepted) { Messages.Message((!acceptanceReport.Reason.NullOrEmpty()) ? acceptanceReport.Reason : Find.ActiveLesson.Current.DefaultRejectInputMessage, MessageTypeDefOf.RejectInput, historical: false); return(false); } } return(true); }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; float y = 15; this.compInput.Draw(0, ref y, inRect.width); this.categoryInput?.Draw(20, ref y, inRect.width - 20); this.incidentInput?.Draw(20, ref y, inRect.width - 20); if (Widgets.ButtonText(new Rect(15f, inRect.height - 50f, 75, 35f), "OK".Translate(), true, false, true)) { AcceptanceReport acceptanceReport = this.isValid(this.comp); if (!acceptanceReport.Accepted) { if (acceptanceReport.Reason.NullOrEmpty()) { Messages.Message("Invalid Input", MessageTypeDefOf.RejectInput, false); } else { Messages.Message(acceptanceReport.Reason, MessageTypeDefOf.RejectInput, false); } } else { Find.WindowStack.TryRemove(this, true); } } if (Widgets.ButtonText(new Rect(100, inRect.height - 50, 75, 35), "Close".Translate())) { Find.WindowStack.TryRemove(this, true); } }
private int GetValueToCompare(Pawn pawn) { int result; if (pawn.training == null) { result = int.MinValue; } else if (pawn.training.HasLearned(this.def.trainable)) { result = 4; } else { bool flag; AcceptanceReport acceptanceReport = pawn.training.CanAssignToTrain(this.def.trainable, out flag); if (!flag) { result = 0; } else if (!acceptanceReport.Accepted) { result = 1; } else if (!pawn.training.GetWanted(this.def.trainable)) { result = 2; } else { result = 3; } } return(result); }
private int GetValueToCompare(Pawn pawn) { if (pawn.training == null) { return(int.MinValue); } if (pawn.training.HasLearned(this.def.trainable)) { return(4); } bool flag; AcceptanceReport acceptanceReport = pawn.training.CanAssignToTrain(this.def.trainable, out flag); if (!flag) { return(0); } if (!acceptanceReport.Accepted) { return(1); } if (!pawn.training.GetWanted(this.def.trainable)) { return(2); } return(3); }
public static void Postfix(ref AcceptanceReport __result, BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null, Thing thing = null, ThingDef stuffDef = null) { if (entDef == TerrainDefOf.ConcreteBridge && map.terrainGrid.TerrainAt(center).affordances.Contains(TerrainAffordanceDefOf.Bridgeable)) // ConcreteBridge on normal water (bridgeable) { __result = AcceptanceReport.WasAccepted; } }
public override AcceptanceReport CanDesignateCell(IntVec3 c) { AcceptanceReport result; if (!c.InBounds(base.Map) || c.Fogged(base.Map)) { result = false; } else { Plant plant = c.GetPlant(base.Map); if (plant == null) { result = "MessageMustDesignatePlants".Translate(); } else { AcceptanceReport acceptanceReport = this.CanDesignateThing(plant); if (!acceptanceReport.Accepted) { result = acceptanceReport; } else { result = true; } } } return(result); }
public override AcceptanceReport CanDesignateCell(IntVec3 c) { if (!c.InBounds(base.Map)) { return(false); } if (base.Map.designationManager.DesignationAt(c, this.Designation) != null) { return(AcceptanceReport.WasRejected); } if (c.Fogged(base.Map)) { return(true); } Mineable firstMineable = c.GetFirstMineable(base.Map); if (firstMineable == null) { return("MessageMustDesignateMineable".Translate()); } AcceptanceReport result = this.CanDesignateThing(firstMineable); if (!result.Accepted) { return(result); } return(AcceptanceReport.WasAccepted); }
public override AcceptanceReport CanDesignateCell(IntVec3 c) { if (!GenGrid.InBounds(c, base.Map)) { return(false); } if (base.Map.designationManager.DesignationAt(c, DesignationDefOf.Mine) != null) { return(AcceptanceReport.WasRejected); } if (GridsUtility.Fogged(c, base.Map)) { return(true); } Mineable firstMineable = GridsUtility.GetFirstMineable(c, base.Map); if (firstMineable == null) { return(Translator.Translate("MessageMustDesignateMineable")); } AcceptanceReport result = this.CanDesignateThing(firstMineable); if (result.Accepted) { return(AcceptanceReport.WasAccepted); } return(result); }
/// <summary> /// Copy paste from vanilla /// </summary> protected override AcceptanceReport NameIsValid(string name) { AcceptanceReport result = base.NameIsValid(name); if (!result.Accepted) { return(result); } string str = null; switch (this.type) { case Resources.Type.animal: if (AnimalManager.policies.Any((Policy d) => d.label == name)) { str = "NameIsInUse".Translate(); } break; case Resources.Type.assign: if (AssignManager.policies.Any((Policy d) => d.label == name)) { str = "NameIsInUse".Translate(); } break; } if (!str.NullOrEmpty()) { return(str); } return(true); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { AcceptanceReport result = new AcceptanceReport("Ceiling mounted buildings must be placed under a roof that is unobstructed by a wall."); result = map.roofGrid.Roofed(loc) && !loc.Impassable(map); return(result); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { AcceptanceReport roofedReport = base.AllowsPlacing(checkingDef, loc, rot, map, thingToIgnore); //check if tile is roofed if (!roofedReport.Accepted) { return(roofedReport); } foreach (IntVec3 c in GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size)) // Don't allow placing on big things { if (c.GetEdifice(map) != null) { if (c.GetEdifice(map).def.blockWind == true || c.GetEdifice(map).def.holdsRoof == true) { return(new AcceptanceReport("D9F_Chandelier_TooTall".Translate(c.GetEdifice(map).LabelCap, checkingDef.LabelCap))); } } IEnumerable <Thing> things = c.GetThingList(map); if (things.Where(x => x.def.placeWorkers != null && x.def.placeWorkers.Where(y => y.GetType() == typeof(PlaceWorker_RoofHanger)).Any()).Any()) // don't hang if there's already a chandelier here { return(new AcceptanceReport("IdenticalThingExists".Translate())); } } // Otherwise, accept placing return(true); }
public void DrawTrainingSelector(Rect rect) { var cellCount = _selectedCurrent.Training.Count; float cellWidth = (rect.width - Margin * (cellCount - 1)) / cellCount; List <TrainableDef> keys = _selectedCurrent.Training.Defs; GUI.BeginGroup(rect); for (var i = 0; i < _selectedCurrent.Training.Count; i++) { var cell = new Rect(i * (cellWidth + Margin), 0f, cellWidth, rect.height); bool visible; AcceptanceReport report = _selectedCurrent.CanBeTrained(_selectedCurrent.Trigger.pawnKind, keys[i], out visible); if (visible && report.Accepted) { bool checkOn = _selectedCurrent.Training[keys[i]]; DrawToggle(cell, keys[i].LabelCap, keys[i].description, ref checkOn, size: 16f, font: GameFont.Tiny, wrap: false); _selectedCurrent.Training[keys[i]] = checkOn; } else if (visible) { Label(cell, keys[i].LabelCap, report.Reason, TextAnchor.MiddleCenter, GameFont.Tiny, Color.grey); } } GUI.EndGroup(); }
private AcceptanceReport CanReinstallAllThings(IntVec3 mousePos) { AcceptanceReport result = AcceptanceReport.WasAccepted; GenConstruct_CanPlaceBlueprintAt_Patch.Mode = BlueprintMode.Check; this.TraverseDesignateThings( mousePos , (drawCell, thing) => { AcceptanceReport report = GenConstruct.CanPlaceBlueprintAt( thing.def , drawCell , GetRotation(thing) , thing.MapHeld , false , null , thing); if (!report.Accepted) { result = report; return(true); } return(false); }); return(result); }
private AcceptanceReport CanReinstall(Thing thing, IntVec3 drawCell) { GenConstruct_CanPlaceBlueprintAt_Patch.Mode = BlueprintMode.Check; AcceptanceReport report = GenConstruct.CanPlaceBlueprintAt(thing.def, drawCell, GetRotation(thing), thing.MapHeld, false, null, thing); return(report); }
public override IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn pawn) { if (pawn.Dead || pawn.Drafted) { yield break; } string text = "BeginLinkingRitualFloatMenu".Translate(); AcceptanceReport acceptanceReport = CanPsylink(pawn); if (!acceptanceReport.Accepted && !string.IsNullOrWhiteSpace(acceptanceReport.Reason)) { text = text + ": " + acceptanceReport.Reason; } FloatMenuOption floatMenuOption = new FloatMenuOption(text, delegate { TaggedString psylinkAffectedByTraitsNegativelyWarning = RoyalTitleUtility.GetPsylinkAffectedByTraitsNegativelyWarning(pawn); if ((string)psylinkAffectedByTraitsNegativelyWarning != null) { Find.WindowStack.Add(new Dialog_MessageBox(psylinkAffectedByTraitsNegativelyWarning, "Confirm".Translate(), delegate { BeginLinkingRitual(pawn); }, "GoBack".Translate())); } else { BeginLinkingRitual(pawn); } }); floatMenuOption.Disabled = !acceptanceReport.Accepted; yield return(floatMenuOption); }
public override AcceptanceReport CanDesignateCell(IntVec3 c) { if (!c.InBounds(Map) || c.Fogged(Map)) { return(false); } List <Thing> things = c.GetThingList(Map); if (things.Count < 1) { return(false); } foreach (Thing thing in things) { if (thing.TryGetComp <CompHarvestableReagent>() == null) { return("NoHarvestableReagentPresent".Translate()); } else { AcceptanceReport result = CanDesignateThing(thing); if (!result.Accepted) { return(result); } } } return(true); }
public override AcceptanceReport CanDesignateCell(IntVec3 c) { AcceptanceReport result = base.CanDesignateCell(c); if (!result.Accepted) { return(result); } TerrainDef terrain = c.GetTerrain(Map); if (terrain.passability == Traversability.Impassable) { return(false); } List <Thing> list = Map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { if (!list[i].def.CanOverlapZones) { return(false); } } Zone zone = Map.zoneManager.ZoneAt(c); if (zone != null && zone.GetType() == typeof(Zone_PresetStockpile)) { Zone_PresetStockpile z = zone as Zone_PresetStockpile; if (z.ZoneType != preset) { return(false); } } return(true); }
public static bool AllowAction(EventPack ep) { if (!TutorSystem.TutorialMode) { return(true); } if (DebugViewSettings.logTutor) { Log.Message("AllowAction: " + ep); } if (ep.Cells != null && ep.Cells.Count <IntVec3>() == 1) { return(TutorSystem.AllowAction(new EventPack(ep.Tag, ep.Cells.First <IntVec3>()))); } if (Find.ActiveLesson.Current != null) { AcceptanceReport acceptanceReport = Find.ActiveLesson.Current.AllowAction(ep); if (!acceptanceReport.Accepted) { string text = acceptanceReport.Reason.NullOrEmpty() ? Find.ActiveLesson.Current.DefaultRejectInputMessage : acceptanceReport.Reason; Messages.Message(text, MessageTypeDefOf.RejectInput); return(false); } } return(true); }
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { if (pawn.training == null) { return; } AcceptanceReport canTrain = pawn.training.CanAssignToTrain(def.trainable, out bool visible); if (!visible) { return; } // basic stuff Rect checkboxRect = Utilities.GetCheckboxRect(rect); if (!canTrain.Accepted) { Utilities.DoTrainableTooltip(checkboxRect, pawn, def.trainable, canTrain); return; } GUI.DrawTexture(checkboxRect, Resources.Background_Dark); var steps = Utilities.GetTrainingProgress(pawn, def.trainable); var completed = pawn.training.HasLearned(def.trainable); var wanted = pawn.training.GetWanted(def.trainable); Utilities.DoTrainableTooltip(checkboxRect, pawn, def.trainable, canTrain, wanted, completed, steps); if (wanted) { Utilities.DrawCheckColoured(checkboxRect, completed ? Color.white : Color.green); if (steps.min < steps.max) { Utilities.DrawTrainingProgress(checkboxRect, pawn, def.trainable, completed ? Color.white : Color.green); } } // not wanted anymore if (!wanted) { if (completed) { Utilities.DrawCheckColoured(checkboxRect, Color.grey); } if (steps.min > 0 && steps.min < steps.max) { Utilities.DrawTrainingProgress(checkboxRect, pawn, def.trainable, Color.grey); } } // interaction Widgets.DrawHighlightIfMouseover(checkboxRect); if (Widgets.ButtonInvisible(checkboxRect)) { pawn.training.SetWantedRecursive(def.trainable, !wanted); } }
public static void ToggleAllTraining(TrainableDef td, List <Pawn> pawns) { bool[] visible = new bool[pawns.Count]; AcceptanceReport[] canAssign = new AcceptanceReport[pawns.Count]; bool[] assigned = pawns.Select(p => p.training.GetWanted(td)).ToArray(); bool[] trained = pawns.Select(p => p.training.IsCompleted(td)).ToArray(); bool all = true; for (int i = 0; i < pawns.Count; i++) { canAssign[i] = pawns[i].training.CanAssignToTrain(td, out visible[i]); if (!assigned[i] && !trained[i] && canAssign[i].Accepted) { all = false; } } for (int i = 0; i < pawns.Count; i++) { if (all && assigned[i]) { SetWantedRecursive(td, pawns[i], false); } else if (!assigned[i] && canAssign[i].Accepted && !trained[i]) { SetWantedRecursive(td, pawns[i], true); } } }
public static void DrawTrainingButton(Rect rect, Pawn pawn, TrainableDef td, AcceptanceReport ar) { if (ar.Accepted) { if (pawn.training.IsCompleted(td)) { GUI.DrawTexture(rect, CheckWhite); } else if (pawn.training.GetWanted(td)) { GUI.DrawTexture(rect, Widgets.CheckboxOnTex); // Get method named "GetSteps", which is internal(non-public) and not static(instance) var getSteps = typeof(Pawn_TrainingTracker).GetMethod("GetSteps", BindingFlags.NonPublic | BindingFlags.Instance); if (getSteps == null) { #if DEBUG Log.Error("GetSteps is null!"); #endif return; } // Call "GetSteps" from instance pawn.training, parameter is td. var curSteps = getSteps.Invoke(pawn.training, new object[] { td }); int steps = td.steps; // Return value of Invoke(...) is Object; thus casting into int type. float barHeight = (rect.height / steps) * (int)curSteps; Rect bar = new Rect(rect.xMax - 5f, rect.yMax - barHeight, 3f, barHeight); GUI.DrawTexture(bar, BarBg); } } }
public override AcceptanceReport CanDesignateCell(IntVec3 c) { if (!c.InBounds(map: Find.CurrentMap)) { return(AcceptanceReport.WasRejected); } if (Find.CurrentMap.designationManager.DesignationAt(c: c, def: DesignationDefOf.Plan) == null) { return(AcceptanceReport.WasRejected); } if (c.Fogged(map: Find.CurrentMap)) { return(AcceptanceReport.WasAccepted); } Thing thing = c.GetFirstMineable(map: Find.CurrentMap); if (thing == null) { return("MessageMustDesignateMineable".Translate()); } AcceptanceReport result = this.CanDesignateThing(t: thing); if (!result.Accepted) { return(result); } return(AcceptanceReport.WasAccepted); }
private int GetValueToCompare(Pawn pawn) { if (pawn.training == null) { return(-2147483648); } if (pawn.training.IsCompleted(base.def.trainable)) { return(4); } bool flag = default(bool); AcceptanceReport acceptanceReport = pawn.training.CanAssignToTrain(base.def.trainable, out flag); if (!flag) { return(0); } if (!acceptanceReport.Accepted) { return(1); } if (!pawn.training.GetWanted(base.def.trainable)) { return(2); } return(3); }
public static void DoTrainingRow(Rect rect, Pawn pawn) { List <TrainableDef> trainableDefs = TrainableUtility.TrainableDefsInListOrder; float width = rect.width / trainableDefs.Count; float iconSize = 16f; float widthOffset = (width - iconSize) / 2; float heightOffset = (rect.height - iconSize) / 2; float x = rect.xMin; float y = rect.yMin; for (int i = 0; i < trainableDefs.Count; i++) { Rect bg = new Rect(x, y, width, rect.height); Rect icon = new Rect(x + widthOffset, y + heightOffset, iconSize, iconSize); x += width; bool vis; AcceptanceReport report = pawn.training.CanAssignToTrain(trainableDefs[i], out vis); TooltipHandler.TipRegion(bg, GetTrainingTip(pawn, trainableDefs[i], report)); if (vis) { DrawTrainingButton(icon, pawn, trainableDefs[i], report); if (report.Accepted && !pawn.training.IsCompleted(trainableDefs[i])) { if (Widgets.InvisibleButton(bg)) { ToggleTraining(trainableDefs[i], pawn, report); } if (Mouse.IsOver(icon)) { GUI.DrawTexture(icon, TexUI.HighlightTex); } } } } }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; bool flag = false; if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { flag = true; Event.current.Use(); } string text = Widgets.TextField(new Rect(0f, 15f, inRect.width, 35f), this.inputText); if (text.Length < this.MaxNameLength) { this.inputText = text; } if (Widgets.ButtonText(new Rect(15f, inRect.height - 35f - 15f, inRect.width - 15f - 15f, 35f), "OK", true, false, true) || flag) { AcceptanceReport acceptanceReport = this.NameIsValid(this.inputText); if (acceptanceReport.Accepted) { this.fridge.label = this.inputText; Find.WindowStack.TryRemove(this, true); } } }
public override AcceptanceReport CanDesignateCell(IntVec3 c) { AcceptanceReport result = base.CanDesignateCell(c); if (!result.Accepted) { return(result); } TerrainDef terrain = c.GetTerrain(base.Map); if (terrain.passability == Traversability.Impassable) { return(false); } List <Thing> list = base.Map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { if (!list[i].def.CanOverlapZones) { return(false); } } return(true); }
public override IEnumerable <FloatMenuOption> GetShuttleFloatMenuOptions(IEnumerable <IThingHolder> pods, Action <int, TransportPodsArrivalAction> launchAction) { if (!TransportPodsArrivalAction_LandInSpecificCell.CanLandInSpecificCell(pods, this)) { yield break; } yield return(new FloatMenuOption("LandInExistingMap".Translate(Label), delegate { Map map = Map; Current.Game.CurrentMap = map; CameraJumper.TryHideWorld(); Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x) { launchAction(base.Tile, new TransportPodsArrivalAction_LandInSpecificCell(this, x.Cell, landInShuttle: true)); }, delegate(LocalTargetInfo x) { RoyalTitlePermitWorker_CallShuttle.DrawShuttleGhost(x, Map); }, delegate(LocalTargetInfo x) { AcceptanceReport acceptanceReport = RoyalTitlePermitWorker_CallShuttle.ShuttleCanLandHere(x, Map); if (!acceptanceReport.Accepted) { Messages.Message(acceptanceReport.Reason, new LookTargets(this), MessageTypeDefOf.RejectInput, historical: false); } return acceptanceReport.Accepted; }, null, null, CompLaunchable.TargeterMouseAttachment); })); }
public FloatMenuOption CommFloatMenuOption(Building_CommsConsole console, Pawn negotiator) { string label = "CallOnRadio".Translate(GetCallLabel()); Action action = null; AcceptanceReport canCommunicate = CanCommunicateWith_NewTemp(negotiator); if (!canCommunicate.Accepted) { if (!canCommunicate.Reason.NullOrEmpty()) { action = delegate { Messages.Message(canCommunicate.Reason, console, MessageTypeDefOf.RejectInput, historical: false); }; } } else { action = delegate { if (!Building_OrbitalTradeBeacon.AllPowered(Map).Any()) { Messages.Message("MessageNeedBeaconToTradeWithShip".Translate(), console, MessageTypeDefOf.RejectInput, historical: false); } else { console.GiveUseCommsJob(negotiator, this); } }; } return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, MenuOptionPriority.InitiateSocial), negotiator, console)); }
public override AcceptanceReport CanDesignateThing(Thing t) { AcceptanceReport acceptanceReport = base.CanDesignateThing(t); AcceptanceReport result; if (!acceptanceReport.Accepted) { result = acceptanceReport; } else { Plant plant = (Plant)t; if ((plant.def.plant.harvestTag != "Standard" && plant.def.plant.harvestTag != "Wood") || !plant.Blighted) { result = "Designator_PlantCut_Blighted_rejected".Translate(); } else { result = true; } } return(result); }
protected override AcceptanceReport NameIsValid(string newName) { // always ok if we didn't change anything if (newName == _blueprint.name) { return(true); } // otherwise check for used symbols and uniqueness AcceptanceReport validName = Blueprint.IsValidBlueprintName(newName); if (!validName.Accepted) { return(validName); } // finally, if we're renaming an already exported blueprint, check if the new name doesn't already exist if (_blueprint.exported && !Controller.TryRenameFile(_blueprint, newName)) { return(new AcceptanceReport("Fluffy.Blueprints.ExportedBlueprintWithThatNameAlreadyExists".Translate(newName))); } // if all checks are passed, return true. return(true); }
public static void ToggleAllTraining(TrainableDef td, List<Pawn> pawns) { bool[] visible = new bool[pawns.Count]; AcceptanceReport[] canAssign = new AcceptanceReport[pawns.Count]; bool[] assigned = pawns.Select(p => p.training.GetWanted(td)).ToArray(); bool[] trained = pawns.Select(p => p.training.IsCompleted(td)).ToArray(); bool all = true; for (int i = 0; i < pawns.Count; i++) { canAssign[i] = pawns[i].training.CanAssignToTrain(td, out visible[i]); if (!assigned[i] && !trained[i] && canAssign[i].Accepted) all = false; } for (int i = 0; i < pawns.Count; i++) { if (all && assigned[i]) { SetWantedRecursive(td, pawns[i], false); } else if (!assigned[i] && canAssign[i].Accepted && !trained[i]) { SetWantedRecursive(td, pawns[i], true); } } }
public static void DrawTrainingButton(Rect rect, Pawn pawn, TrainableDef td, AcceptanceReport ar) { if (ar.Accepted) { if (pawn.training.IsCompleted(td)) { GUI.DrawTexture(rect, CheckWhite); } else if (pawn.training.GetWanted(td)) { GUI.DrawTexture(rect, Widgets.CheckboxOnTex); // Get method named "GetSteps", which is internal(non-public) and not static(instance) var getSteps = typeof(Pawn_TrainingTracker).GetMethod( "GetSteps", BindingFlags.NonPublic | BindingFlags.Instance ); if (getSteps == null) { #if DEBUG Log.Error("GetSteps is null!"); #endif return; } // Call "GetSteps" from instance pawn.training, parameter is td. var curSteps = getSteps.Invoke( pawn.training, new object[] {td} ); int steps = td.steps; // Return value of Invoke(...) is Object; thus casting into int type. float barHeight = (rect.height/steps)*(int) curSteps; Rect bar = new Rect( rect.xMax - 5f, rect.yMax - barHeight, 3f, barHeight ); GUI.DrawTexture( bar, BarBg ); } } }
public static string GetTrainingTip(Pawn pawn, TrainableDef td, AcceptanceReport ar) { var label = new StringBuilder(); label.AppendLine(td.LabelCap); if (!ar.Accepted) { label.AppendLine(ar.Reason); } else { if (pawn.training.IsCompleted(td)) { label.Append("Fluffy.TrainingCompleted".Translate()); } else { label.AppendLine(!pawn.training.GetWanted(td) ? "Fluffy.NotTraining".Translate() : "Fluffy.CurrentlyTraining".Translate()); var getSteps = typeof(Pawn_TrainingTracker).GetMethod("GetSteps", BindingFlags.NonPublic | BindingFlags.Instance); if (getSteps == null) { #if DEBUG Log.Error("GetSteps is null!"); #endif return label.ToString(); } var curSteps = getSteps.Invoke(pawn.training, new object[] { td }); int steps = td.steps; label.Append( "Fluffy.StepsCompleted".Translate( curSteps, steps ) ); } } return label.ToString(); }
private AcceptanceReport CanStart() { AcceptanceReport result; foreach (Pawn current in ModdedMapInitParams.colonists) { if (!current.Name.Valid) { result = new AcceptanceReport(Translator.Translate("EveryoneNeedsValidName")); return result; } } result = AcceptanceReport.WasAccepted; return result; }
public static void ToggleTraining(TrainableDef td, Pawn pawn, AcceptanceReport ar) { bool train = !pawn.training.GetWanted(td); if (ar.Accepted) { SetWantedRecursive(td, pawn, train); } }