public IEnumerable <Gizmo> GetGizmos() { if (PawnAttackGizmoUtility.CanShowEquipmentGizmos()) { List <ThingWithComps> list = this.AllEquipmentListForReading; for (int i = 0; i < list.Count; i++) { ThingWithComps eq = list[i]; foreach (Command command in eq.GetComp <CompEquippable>().GetVerbsCommands()) { if (i != 0) { if (i != 1) { if (i == 2) { command.hotKey = KeyBindingDefOf.Misc3; } } else { command.hotKey = KeyBindingDefOf.Misc2; } } else { command.hotKey = KeyBindingDefOf.Misc1; } yield return(command); } } } }
public static void SetColor(this Thing t, Color newColor, bool reportFailure = true) { ThingWithComps thingWithComps = t as ThingWithComps; if (thingWithComps == null) { if (reportFailure) { Log.Error("SetColor on non-ThingWithComps " + t); } return; } CompColorable comp = thingWithComps.GetComp <CompColorable>(); if (comp == null) { if (reportFailure) { Log.Error("SetColor on Thing without CompColorable " + t); } } else if (comp.Color != newColor) { comp.Color = newColor; } }
public void Notify_EquipmentAdded(ThingWithComps eq) { foreach (Verb allVerb in eq.GetComp <CompEquippable>().AllVerbs) { allVerb.caster = this.pawn; allVerb.Notify_PickedUp(); } }
public void EquipmentTrackerTick() { List <ThingWithComps> allEquipmentListForReading = this.AllEquipmentListForReading; for (int i = 0; i < allEquipmentListForReading.Count; i++) { ThingWithComps thingWithComps = allEquipmentListForReading[i]; thingWithComps.GetComp <CompEquippable>().verbTracker.VerbsTick(); } }
public static T TryGetComp <T>(this Thing thing) where T : ThingComp { ThingWithComps thingWithComps = thing as ThingWithComps; if (thingWithComps == null) { return((T)((object)null)); } return(thingWithComps.GetComp <T>()); }
public static T TryGetComp <T>(this Thing thing) where T : ThingComp { ThingWithComps thingWithComps = thing as ThingWithComps; T result; if (thingWithComps == null) { result = (T)((object)null); } else { result = thingWithComps.GetComp <T>(); } return(result); }
public void ExposeData() { Scribe_Deep.Look(ref equipment, "equipment", this); if (Scribe.mode == LoadSaveMode.PostLoadInit) { List <ThingWithComps> allEquipmentListForReading = AllEquipmentListForReading; for (int i = 0; i < allEquipmentListForReading.Count; i++) { ThingWithComps thingWithComps = allEquipmentListForReading[i]; foreach (Verb allVerb in thingWithComps.GetComp <CompEquippable>().AllVerbs) { allVerb.caster = pawn; } } } }
public void ExposeData() { Scribe_Deep.Look <ThingOwner <ThingWithComps> >(ref this.equipment, "equipment", new object[] { this }); if (Scribe.mode == LoadSaveMode.PostLoadInit) { List <ThingWithComps> allEquipmentListForReading = this.AllEquipmentListForReading; for (int i = 0; i < allEquipmentListForReading.Count; i++) { ThingWithComps thingWithComps = allEquipmentListForReading[i]; foreach (Verb current in thingWithComps.GetComp <CompEquippable>().AllVerbs) { current.caster = this.pawn; } } } }
public IEnumerable <Gizmo> GetGizmos() { if (PawnAttackGizmoUtility.CanShowEquipmentGizmos()) { List <ThingWithComps> list = this.AllEquipmentListForReading; for (int i = 0; i < list.Count; i++) { ThingWithComps eq = list[i]; using (IEnumerator <Command> enumerator = eq.GetComp <CompEquippable>().GetVerbsCommands().GetEnumerator()) { if (enumerator.MoveNext()) { Command command = enumerator.Current; switch (i) { case 0: command.hotKey = KeyBindingDefOf.Misc1; break; case 1: command.hotKey = KeyBindingDefOf.Misc2; break; case 2: command.hotKey = KeyBindingDefOf.Misc3; break; } yield return((Gizmo)command); /*Error: Unable to find new state assignment for yield return*/; } } } } yield break; IL_0187: /*Error near IL_0188: Unexpected return in MoveNext()*/; }
public void Notify_EquipmentRemoved(ThingWithComps eq) { eq.GetComp <CompEquippable>().Notify_EquipmentLost(); }
private string CurrentDebugString() { StringBuilder stringBuilder = new StringBuilder(); if (DebugViewSettings.writeGame) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine((Current.Game != null) ? Current.Game.DebugString() : "Current.Game = null"); } if (DebugViewSettings.writeMusicManagerPlay) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.MusicManagerPlay.DebugString()); } if (DebugViewSettings.writePlayingSounds) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Sustainers:"); foreach (Sustainer sustainer in Find.SoundRoot.sustainerManager.AllSustainers) { stringBuilder.AppendLine(sustainer.DebugString()); } stringBuilder.AppendLine(); stringBuilder.AppendLine("OneShots:"); foreach (SampleOneShot sampleOneShot in Find.SoundRoot.oneShotManager.PlayingOneShots) { stringBuilder.AppendLine(sampleOneShot.ToString()); } } if (DebugViewSettings.writeSoundEventsRecord) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Recent sound events:\n ..."); stringBuilder.AppendLine(DebugSoundEventsLog.EventsListingDebugString); } if (DebugViewSettings.writeSteamItems) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(WorkshopItems.DebugOutput()); } if (DebugViewSettings.writeConcepts) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(LessonAutoActivator.DebugString()); } if (DebugViewSettings.writeMemoryUsage) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Total allocated: " + Profiler.GetTotalAllocatedMemoryLong().ToStringBytes("F2")); stringBuilder.AppendLine("Total reserved: " + Profiler.GetTotalReservedMemoryLong().ToStringBytes("F2")); stringBuilder.AppendLine("Total reserved unused: " + Profiler.GetTotalUnusedReservedMemoryLong().ToStringBytes("F2")); stringBuilder.AppendLine("Mono heap size: " + Profiler.GetMonoHeapSizeLong().ToStringBytes("F2")); stringBuilder.AppendLine("Mono used size: " + Profiler.GetMonoUsedSizeLong().ToStringBytes("F2")); } if (Current.ProgramState == ProgramState.Playing) { stringBuilder.AppendLine("Tick " + Find.TickManager.TicksGame); if (DebugViewSettings.writeStoryteller) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.Storyteller.DebugString()); } } if (Current.ProgramState == ProgramState.Playing && Find.CurrentMap != null) { if (DebugViewSettings.writeMapGameConditions) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.gameConditionManager.DebugString()); } if (DebugViewSettings.drawPawnDebug) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.reservationManager.DebugString()); } if (DebugViewSettings.writeMoteSaturation) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Mote count: " + Find.CurrentMap.moteCounter.MoteCount); stringBuilder.AppendLine("Mote saturation: " + Find.CurrentMap.moteCounter.Saturation); } if (DebugViewSettings.writeEcosystem) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.wildAnimalSpawner.DebugString()); } if (DebugViewSettings.writeTotalSnowDepth) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Total snow depth: " + Find.CurrentMap.snowGrid.TotalDepth); } if (DebugViewSettings.writeWind) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.windManager.DebugString()); } if (DebugViewSettings.writeRecentStrikes) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.mineStrikeManager.DebugStrikeRecords()); } if (DebugViewSettings.writeListRepairableBldgs) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.listerBuildingsRepairable.DebugString()); } if (DebugViewSettings.writeListFilthInHomeArea) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.listerFilthInHomeArea.DebugString()); } if (DebugViewSettings.writeListHaulables) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.listerHaulables.DebugString()); } if (DebugViewSettings.writeListMergeables) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.listerMergeables.DebugString()); } if (DebugViewSettings.drawLords) { foreach (Lord lord in Find.CurrentMap.lordManager.lords) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(lord.DebugString()); } } IntVec3 intVec = UI.MouseCell(); if (intVec.InBounds(Find.CurrentMap)) { stringBuilder.AppendLine("Inspecting " + intVec.ToString()); if (DebugViewSettings.writeTerrain) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.terrainGrid.DebugStringAt(intVec)); } if (DebugViewSettings.writeAttackTargets) { foreach (Pawn pawn in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()).OfType <Pawn>()) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Potential attack targets for " + pawn.LabelShort + ":"); List <IAttackTarget> potentialTargetsFor = Find.CurrentMap.attackTargetsCache.GetPotentialTargetsFor(pawn); for (int i = 0; i < potentialTargetsFor.Count; i++) { Thing thing = (Thing)potentialTargetsFor[i]; stringBuilder.AppendLine(string.Concat(new object[] { thing.LabelShort, ", ", thing.Faction, (!potentialTargetsFor[i].ThreatDisabled(null)) ? "" : " (threat disabled)" })); } } } if (DebugViewSettings.writeSnowDepth) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Snow depth: " + Find.CurrentMap.snowGrid.GetDepth(intVec)); } if (DebugViewSettings.drawDeepResources) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Deep resource def: " + Find.CurrentMap.deepResourceGrid.ThingDefAt(intVec)); stringBuilder.AppendLine("Deep resource count: " + Find.CurrentMap.deepResourceGrid.CountAt(intVec)); } if (DebugViewSettings.writeCanReachColony) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("CanReachColony: " + Find.CurrentMap.reachability.CanReachColony(UI.MouseCell())); } if (DebugViewSettings.writeMentalStateCalcs) { stringBuilder.AppendLine("---"); foreach (Pawn pawn2 in (from t in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()) where t is Pawn select t).Cast <Pawn>()) { stringBuilder.AppendLine(pawn2.mindState.mentalBreaker.DebugString()); } } if (DebugViewSettings.writeWorkSettings) { foreach (Pawn pawn3 in (from t in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()) where t is Pawn select t).Cast <Pawn>()) { if (pawn3.workSettings != null) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(pawn3.workSettings.DebugString()); } } } if (DebugViewSettings.writeApparelScore) { stringBuilder.AppendLine("---"); if (intVec.InBounds(Find.CurrentMap)) { foreach (Thing thing2 in intVec.GetThingList(Find.CurrentMap)) { Apparel apparel = thing2 as Apparel; if (apparel != null) { stringBuilder.AppendLine(apparel.Label + ": " + JobGiver_OptimizeApparel.ApparelScoreRaw(null, apparel).ToString("F2")); } } } } if (DebugViewSettings.writeCellContents || this.fullMode) { stringBuilder.AppendLine("---"); if (intVec.InBounds(Find.CurrentMap)) { foreach (Designation designation in Find.CurrentMap.designationManager.AllDesignationsAt(intVec)) { stringBuilder.AppendLine(designation.ToString()); } foreach (Thing thing3 in Find.CurrentMap.thingGrid.ThingsAt(intVec)) { if (!this.fullMode) { stringBuilder.AppendLine(thing3.LabelCap + " - " + thing3.ToString()); } else { stringBuilder.AppendLine(Scribe.saver.DebugOutputFor(thing3)); stringBuilder.AppendLine(); } } } } if (DebugViewSettings.debugApparelOptimize) { stringBuilder.AppendLine("---"); foreach (Thing thing4 in Find.CurrentMap.thingGrid.ThingsAt(intVec)) { Apparel apparel2 = thing4 as Apparel; if (apparel2 != null) { stringBuilder.AppendLine(apparel2.LabelCap); stringBuilder.AppendLine(" raw: " + JobGiver_OptimizeApparel.ApparelScoreRaw(null, apparel2).ToString("F2")); Pawn pawn4 = Find.Selector.SingleSelectedThing as Pawn; if (pawn4 != null) { stringBuilder.AppendLine(" Pawn: " + pawn4); stringBuilder.AppendLine(" gain: " + JobGiver_OptimizeApparel.ApparelScoreGain(pawn4, apparel2).ToString("F2")); } } } } if (DebugViewSettings.drawRegions) { stringBuilder.AppendLine("---"); Region regionAt_NoRebuild_InvalidAllowed = Find.CurrentMap.regionGrid.GetRegionAt_NoRebuild_InvalidAllowed(intVec); stringBuilder.AppendLine("Region:\n" + ((regionAt_NoRebuild_InvalidAllowed == null) ? "null" : regionAt_NoRebuild_InvalidAllowed.DebugString)); } if (DebugViewSettings.drawRooms) { stringBuilder.AppendLine("---"); Room room = intVec.GetRoom(Find.CurrentMap, RegionType.Set_All); if (room != null) { stringBuilder.AppendLine(room.DebugString()); } else { stringBuilder.AppendLine("(no room)"); } } if (DebugViewSettings.drawRoomGroups) { stringBuilder.AppendLine("---"); RoomGroup roomGroup = intVec.GetRoomGroup(Find.CurrentMap); if (roomGroup != null) { stringBuilder.AppendLine(roomGroup.DebugString()); } else { stringBuilder.AppendLine("(no room group)"); } } if (DebugViewSettings.drawGlow) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Game glow: " + Find.CurrentMap.glowGrid.GameGlowAt(intVec, false)); stringBuilder.AppendLine("Psych glow: " + Find.CurrentMap.glowGrid.PsychGlowAt(intVec)); stringBuilder.AppendLine("Visual Glow: " + Find.CurrentMap.glowGrid.VisualGlowAt(intVec)); stringBuilder.AppendLine("GlowReport:\n" + ((SectionLayer_LightingOverlay)Find.CurrentMap.mapDrawer.SectionAt(intVec).GetLayer(typeof(SectionLayer_LightingOverlay))).GlowReportAt(intVec)); stringBuilder.AppendLine("SkyManager.CurSkyGlow: " + Find.CurrentMap.skyManager.CurSkyGlow); } if (DebugViewSettings.writePathCosts) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("Perceived path cost: " + Find.CurrentMap.pathGrid.PerceivedPathCostAt(intVec)); stringBuilder.AppendLine("Real path cost: " + Find.CurrentMap.pathGrid.CalculatedCostAt(intVec, false, IntVec3.Invalid)); } if (DebugViewSettings.writeFertility) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("\nFertility: " + Find.CurrentMap.fertilityGrid.FertilityAt(intVec).ToString("##0.00")); } if (DebugViewSettings.writeLinkFlags) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine("\nLinkFlags: "); IEnumerator enumerator11 = Enum.GetValues(typeof(LinkFlags)).GetEnumerator(); try { while (enumerator11.MoveNext()) { object obj = enumerator11.Current; if ((Find.CurrentMap.linkGrid.LinkFlagsAt(intVec) & (LinkFlags)obj) != LinkFlags.None) { stringBuilder.Append(" " + obj); } } } finally { IDisposable disposable; if ((disposable = (enumerator11 as IDisposable)) != null) { disposable.Dispose(); } } } if (DebugViewSettings.writeSkyManager) { stringBuilder.AppendLine("---"); stringBuilder.AppendLine(Find.CurrentMap.skyManager.DebugString()); } if (DebugViewSettings.writeCover) { stringBuilder.AppendLine("---"); stringBuilder.Append("Cover: "); Thing thing5 = Find.CurrentMap.coverGrid[intVec]; if (thing5 == null) { stringBuilder.AppendLine("null"); } else { stringBuilder.AppendLine(thing5.ToString()); } } if (DebugViewSettings.drawPower) { stringBuilder.AppendLine("---"); foreach (Thing thing6 in Find.CurrentMap.thingGrid.ThingsAt(intVec)) { ThingWithComps thingWithComps = thing6 as ThingWithComps; if (thingWithComps != null && thingWithComps.GetComp <CompPowerTrader>() != null) { stringBuilder.AppendLine(" " + thingWithComps.GetComp <CompPowerTrader>().DebugString); } } PowerNet powerNet = Find.CurrentMap.powerNetGrid.TransmittedPowerNetAt(intVec); if (powerNet != null) { stringBuilder.AppendLine("" + powerNet.DebugString()); } else { stringBuilder.AppendLine("(no PowerNet here)"); } } if (DebugViewSettings.drawPreyInfo) { Pawn pawn5 = Find.Selector.SingleSelectedThing as Pawn; if (pawn5 != null) { List <Thing> thingList = intVec.GetThingList(Find.CurrentMap); for (int j = 0; j < thingList.Count; j++) { Pawn pawn6 = thingList[j] as Pawn; if (pawn6 != null) { stringBuilder.AppendLine("---"); if (FoodUtility.IsAcceptablePreyFor(pawn5, pawn6)) { stringBuilder.AppendLine("Prey score: " + FoodUtility.GetPreyScoreFor(pawn5, pawn6)); } else { stringBuilder.AppendLine("Prey score: None"); } break; } } } } } } return(stringBuilder.ToString()); }