public static void IsColonistPlayerControlled_PostFix(Pawn __instance, ref bool __result) { CompVehicle vehicle = __instance.GetComp <CompVehicle>(); if (vehicle != null) { if (__instance.Faction == Faction.OfPlayer) { __result = true; } } }
// Verse.Pawn public static void CurrentlyUsable_PostFix(Pawn __instance, ref bool __result) { CompVehicle vehicle = __instance.GetComp <CompVehicle>(); if (vehicle != null) { if (!__instance.pather.MovingNow) { __result = true; } } }
private static void DoRow(ref float curY, Rect viewRect, Rect scrollOutRect, Vector2 scrollPosition, Thing thing, CompVehicle vehicle, ref Pawn specificNeedsTabForPawn, bool doNeeds) { var num = !(thing is Pawn) ? 30f : 50f; var num2 = scrollPosition.y - num; var num3 = scrollPosition.y + scrollOutRect.height; if (curY > num2 && curY < num3) { DoRow(new Rect(0f, curY, viewRect.width, num), thing, vehicle, ref specificNeedsTabForPawn, doNeeds); } curY += num; }
// RimWorld.HealthCardUtility public static bool DrawOverviewTab_PreFix(ref float __result, Rect leftRect, Pawn pawn, float curY) { if (pawn != null) { CompVehicle compPilotable = pawn.GetComp <CompVehicle>(); if (compPilotable != null) { curY += 4f; Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.UpperLeft; GUI.color = new Color(0.9f, 0.9f, 0.9f); string text = StringOf.Movement; if (compPilotable.movingStatus == MovingState.able) { text = text + ": " + StringOf.On; } else { text = text + ": " + StringOf.Off; } Rect rect = new Rect(0f, curY, leftRect.width, 34f); Widgets.Label(rect, text.CapitalizeFirst()); //TooltipHandler.TipRegion(rect, () => pawn.ageTracker.AgeTooltipString, 73412); //if (Mouse.IsOver(rect)) //{ // Widgets.DrawHighlight(rect); //} curY += 34f; Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.UpperLeft; GUI.color = new Color(0.9f, 0.9f, 0.9f); string text2 = StringOf.Weapons; if (compPilotable.weaponStatus == WeaponState.able) { text2 = text2 + ": " + StringOf.On; } else { text2 = text2 + ": " + StringOf.Off; } Rect rect2 = new Rect(0f, curY, leftRect.width, 34f); Widgets.Label(rect2, text2.CapitalizeFirst()); curY += 34f; __result = curY; return(false); } } return(true); }
// Verse.AI.Pawn_PathFollower public static bool StartPath_PreFix(Pawn_PathFollower __instance, LocalTargetInfo dest, PathEndMode peMode) { Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_PathFollower), "pawn").GetValue(__instance); if (pawn != null) { CompVehicle compPilotable = pawn.GetComp <CompVehicle>(); if (compPilotable != null) { if (compPilotable.movingStatus == MovingState.frozen) { return(false); } } } return(true); }
// Verse.PawnDownedWiggler public static bool WigglerTick_PreFix(PawnDownedWiggler __instance) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (pawn != null) { CompVehicle compPilotable = pawn.GetComp <CompVehicle>(); if (compPilotable != null) { if (!compPilotable.Props.canWiggleWhenDowned) { return(false); } } } return(true); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(this.TransporterInd); //this.FailOn(() => !this.<> f__this.Transporter.LoadingInProgressOrReadyToLaunch); yield return(Toils_Reserve.Reserve(this.TransporterInd, 1, -1, null)); yield return(Toils_Goto.GotoThing(this.TransporterInd, PathEndMode.Touch)); yield return(new Toil { initAction = delegate { CompVehicle vehicle = this.Vehicle; vehicle.Notify_Loaded(this.pawn); } }); }
// Verse.Verb_Shoot public static bool TryCastShot_PreFix(Verb_Shoot __instance, ref bool __result) { Pawn pawn = __instance.CasterPawn; if (pawn != null) { CompVehicle compPilotable = pawn.GetComp <CompVehicle>(); if (compPilotable != null) { if (compPilotable.weaponStatus == WeaponState.frozen) { __result = false; return(false); } } } return(true); }
// Verse.Pawn_HealthTracker public static bool ShouldBeDowned_PreFix(Pawn_HealthTracker __instance, ref bool __result) { Pawn pawn = (Pawn)AccessTools.Field(typeof(Pawn_HealthTracker), "pawn").GetValue(__instance); if (pawn != null) { CompVehicle compPilotable = pawn.GetComp <CompVehicle>(); if (compPilotable != null) { if (!compPilotable.Props.canBeDowned) { __result = false; return(false); } } } return(true); }
// Verse.HealthUtility public static bool GetGeneralConditionLabel_PreFix(ref string __result, Pawn pawn, bool shortVersion = false) { if (pawn != null) { CompVehicle compPilotable = pawn.GetComp <CompVehicle>(); if (compPilotable != null) { if (pawn.Downed || !pawn.health.capacities.CanBeAwake) { __result = compPilotable.Props.labelInoperable; return(false); } if (pawn.Dead) { __result = compPilotable.Props.labelBroken; return(false); } __result = compPilotable.Props.labelUndamaged; return(false); } } return(true); }
// Verse.DamageWorker_AddInjury public static void FinalizeAndAddInjury_PostFix(DamageWorker_AddInjury __instance, Pawn pawn, Hediff_Injury injury, DamageInfo dinfo) { CompVehicle compPilotable = pawn.GetComp <CompVehicle>(); if (compPilotable != null) { List <Pawn> affectedPawns = new List <Pawn>(); if (compPilotable.handlers != null && compPilotable.handlers.Count > 0) { foreach (VehicleHandlerGroup group in compPilotable.handlers) { if (group.OccupiedParts != null && (group.handlers != null && group.handlers.Count > 0)) { if (group.OccupiedParts.Contains(injury.Part)) { affectedPawns.AddRange(group.handlers); } } } } //Attack the seatholder if (affectedPawns != null && affectedPawns.Count > 0) { DamageInfo newDamageInfo = new DamageInfo(dinfo); float criticalBonus = 0f; if (Rand.Value < compPilotable.Props.seatHitCriticalHitChance) { criticalBonus = dinfo.Amount * 2; } float newDamFloat = (dinfo.Amount * compPilotable.Props.seatHitDamageFactor) + criticalBonus; newDamageInfo.SetAmount((int)newDamFloat); affectedPawns.RandomElement <Pawn>().TakeDamage(newDamageInfo); } } }
private static void DoRow(Rect rect, Thing thing, CompVehicle vehicle, ref Pawn specificNeedsTabForPawn, bool doNeeds) { GUI.BeginGroup(rect); Rect rect2 = rect.AtZero(); Pawn pawn = thing as Pawn; //if (listingUsesAbandonSpecificCountButtons) //{ // if (thing.stackCount != 1) // { // CaravanPeopleAndItemsTabUtility.DoAbandonSpecificCountButton(rect2, thing, caravan); // } // rect2.width -= 24f; //} //CaravanPeopleAndItemsTabUtility.DoAbandonButton(rect2, thing, caravan); rect2.width -= 24f; Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, thing); rect2.width -= 24f; if (pawn != null && !pawn.Dead) { CaravanPeopleAndItemsTabUtility.DoOpenSpecificTabButton(rect2, pawn, ref specificNeedsTabForPawn); rect2.width -= 24f; } if (pawn == null) { Rect rect3 = rect2; rect3.xMin = rect3.xMax - 60f; CaravanPeopleAndItemsTabUtility.TryDrawMass(thing, rect3); rect2.width -= 60f; } if (Mouse.IsOver(rect2)) { Widgets.DrawHighlight(rect2); } Rect rect4 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f); Widgets.ThingIcon(rect4, thing, 1f); if (pawn != null) { Rect bgRect = new Rect(rect4.xMax + 4f, 16f, 100f, 18f); GenMapUI.DrawPawnLabel(pawn, bgRect, 1f, 100f, null, GameFont.Small, false, false); if (doNeeds) { GetNeedsToDisplay(pawn, tmpNeeds); float xMax = bgRect.xMax; for (int i = 0; i < tmpNeeds.Count; i++) { Need need = tmpNeeds[i]; int maxThresholdMarkers = 0; bool doTooltip = true; Rect rect5 = new Rect(xMax, 0f, 100f, 50f); #pragma warning disable IDE0019 // Use pattern matching Need_Mood mood = need as Need_Mood; #pragma warning restore IDE0019 // Use pattern matching if (mood != null) { maxThresholdMarkers = 1; doTooltip = false; //TooltipHandler.TipRegion(rect5, new TipSignal(() => CaravanPeopleAndItemsTabUtility.CustomMoodNeedTooltip(mood), rect5.GetHashCode())); } need.DrawOnGUI(rect5, maxThresholdMarkers, 10f, false, doTooltip); xMax = rect5.xMax; } } if (pawn.Downed) { GUI.color = new Color(1f, 0f, 0f, 0.5f); Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width); GUI.color = Color.white; } } else { Rect rect6 = new Rect(rect4.xMax + 4f, 0f, 300f, 30f); Text.Anchor = TextAnchor.MiddleLeft; Text.WordWrap = false; Widgets.Label(rect6, thing.LabelCap); Text.Anchor = TextAnchor.UpperLeft; Text.WordWrap = true; } GUI.EndGroup(); }
public static void DoRows(Vector2 size, CompVehicle vehicle, ref Vector2 scrollPosition, ref float scrollViewHeight, bool alwaysShowItemsSection, ref Pawn specificNeedsTabForPawn, bool doNeeds = true) { //if (specificNeedsTabForPawn != null && (!thing.Contains(specificNeedsTabForPawn) || specificNeedsTabForPawn.Dead)) //{ // specificNeedsTabForPawn = null; //} Text.Font = GameFont.Small; Rect rect = new Rect(0f, 0f, size.x, size.y).ContractedBy(10f); Rect viewRect = new Rect(0f, 0f, rect.width - 16f, scrollViewHeight); //bool listingUsesAbandonSpecificCountButtons = AnyItemOrEmpty(things); Widgets.BeginScrollView(rect, ref scrollPosition, viewRect, true); float num = 0f; if (!vehicle.handlers.NullOrEmpty()) { foreach (VehicleHandlerGroup group in vehicle.handlers) { if ((group?.handlers?.Count ?? 0) > 0) { var flag = false; for (int i = 0; i < group.handlers.Count; i++) { Pawn pawn = group.handlers[i] as Pawn; if (!flag) { Widgets.ListSeparator(ref num, viewRect.width, group.role.label.CapitalizeFirst()); flag = true; } DoRow(ref num, viewRect, rect, scrollPosition, pawn, vehicle, ref specificNeedsTabForPawn, doNeeds); } } } } //bool flag2 = false; //for (int j = 0; j < things.Count; j++) //{ // Pawn pawn2 = things[j] as Pawn; // if (pawn2 != null && !pawn2.IsColonist) // { // if (!flag2) // { // Widgets.ListSeparator(ref num, viewRect.width, "CaravanPrisonersAndAnimals".Translate()); // flag2 = true; // } // DoRow(ref num, viewRect, rect, scrollPosition, pawn2, vehicle, ref specificNeedsTabForPawn, doNeeds, listingUsesAbandonSpecificCountButtons); // } //} //bool flag3 = false; if (alwaysShowItemsSection) { Widgets.ListSeparator(ref num, viewRect.width, "CaravanItems".Translate()); } //for (int k = 0; k < vehicle.Pawn.inventory.innerContainer.Count; k++) //{ // if (!(things[k] is Pawn)) // { // if (!flag3) // { // if (!alwaysShowItemsSection) // { // Widgets.ListSeparator(ref num, viewRect.width, "CaravanItems".Translate()); // } // flag3 = true; // } // DoRow(ref num, viewRect, rect, scrollPosition, things[k], vehicle, ref specificNeedsTabForPawn, doNeeds, listingUsesAbandonSpecificCountButtons); // } //} //if (alwaysShowItemsSection && !flag3) //{ // GUI.color = Color.gray; // Text.Anchor = TextAnchor.UpperCenter; // Widgets.Label(new Rect(0f, num, viewRect.width, 25f), "NoneBrackets".Translate()); // Text.Anchor = TextAnchor.UpperLeft; // num += 25f; // GUI.color = Color.white; //} if (Event.current.type == EventType.Layout) { scrollViewHeight = num + 30f; } Widgets.EndScrollView(); }