// Token: 0x06002764 RID: 10084 RVA: 0x0012C518 File Offset: 0x0012A918 public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true, DeepStrikeType strikeType = DeepStrikeType.Drop) { foreach (List <Thing> list in thingsGroups) { List <Thing> list2 = list.Where(x => x.def.thingClass == typeof(Pawn) && (x.Faction != null && x.Faction.def.HasModExtension <FactionDefExtension>())).ToList(); FactionDefExtension extension = list2.RandomElement().Faction.def.GetModExtension <FactionDefExtension>(); IntVec3 intVec; if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec, true, canRoofPunch)) { Log.Warning(string.Concat(new object[] { "DropThingsNear failed to find a place to drop ", list.FirstOrDefault <Thing>(), " near ", dropCenter, ". Dropping on random square instead." }), false); intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map) && (c.Roofed(map) && c.GetRoof(map) != RoofDefOf.RoofRockThick), map, 1000); } for (int i = 0; i < list.Count; i++) { list[i].SetForbidden(true, false); } if (instaDrop) { foreach (Thing thing in list) { GenPlace.TryPlaceThing(thing, intVec, map, ThingPlaceMode.Near, null, null); } } else { ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); foreach (Thing item in list) { activeDropPodInfo.innerContainer.TryAddOrTransfer(item, true); } activeDropPodInfo.openDelay = openDelay; activeDropPodInfo.leaveSlag = leaveSlag; if (strikeType == DeepStrikeType.Fly) { DeepStrikeUtility.MakeFlyerLandAt(intVec, map, activeDropPodInfo, extension); } else if (strikeType == DeepStrikeType.Tunnel) { DeepStrikeUtility.MakeTunnelAt(intVec, map, activeDropPodInfo, extension); } else if (strikeType == DeepStrikeType.Teleport) { DeepStrikeUtility.MakeTeleportAt(intVec, map, activeDropPodInfo, extension); } else { DeepStrikeUtility.MakeDropPodAt(intVec, map, activeDropPodInfo, extension); } } } }
public static void MakeTunnelAt(IntVec3 c, Map map, ActiveDropPodInfo info, FactionDefExtension extension = null) { ThingDef TunnelDef = DefDatabase <ThingDef> .GetNamed("OG_AMA_Tunneler"); TunnelSpawner tunnelSpawner = (TunnelSpawner)ThingMaker.MakeThing(TunnelDef, null); foreach (Thing item in info.innerContainer) { tunnelSpawner.GetDirectlyHeldThings().TryAddOrTransfer(item, false); } GenSpawn.Spawn(tunnelSpawner, c, map); }
// Token: 0x06002762 RID: 10082 RVA: 0x0012C458 File Offset: 0x0012A858 public static void MakeTunnelAt(IntVec3 c, Map map, ActiveDropPodInfo info, FactionDefExtension extension) { ThingDef TunnelDef = DefDatabase <ThingDef> .GetNamed("OG_AMA_Tunneler"); // Log.Message(string.Format("making tunnelSpawner: {0}, @: {1}, {2}, {3}", TunnelDef, c, map, info.innerContainer.ContentsString)); TunnelSpawner tunnelSpawner = (TunnelSpawner)ThingMaker.MakeThing(TunnelDef, null); foreach (Thing item in info.innerContainer) { tunnelSpawner.GetDirectlyHeldThings().TryAddOrTransfer(item, false); } GenSpawn.Spawn(tunnelSpawner, c, map); //-- SkyfallerMaker.SpawnSkyfaller(ThingDefOf.DropPodIncoming, tunnelSpawner, c, map); }
// Token: 0x06002762 RID: 10082 RVA: 0x0012C458 File Offset: 0x0012A858 public static void MakeDropPodAt(IntVec3 c, Map map, ActiveDropPodInfo info, FactionDefExtension extension) { ThingDef ActiveDropPod = ThingDefOf.ActiveDropPod; ThingDef DropPodIncoming = ThingDefOf.DropPodIncoming; if (extension != null) { ActiveDropPod = extension.ActiveDropPod; DropPodIncoming = extension.DropPodIncoming; } ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ActiveDropPod, null); activeDropPod.Contents = info; SkyfallerMaker.SpawnSkyfaller(DropPodIncoming, activeDropPod, c, map); }
// RimWorld.CharacterCardUtility public void DrawCard(Rect rect, ThingWithComps selectedThing, CompColorableTwoFaction Colorable) { GUI.BeginGroup(rect); if (Colorable != null && Colorable.Props != null) { var ts = Text.CalcSize(selectedThing.def.LabelCap).x; var y = rect.y; var rect2 = new Rect(rect.width / 2 - ts + SpacingOffset, y, rect.width, HeaderSize); // y += rect2.height; Text.Font = GameFont.Small; Widgets.ListSeparator(ref y, rect2.width, "Colours: "); if (!Colorable.Props.Key.NullOrEmpty()) { List <FactionDef> factions = new List <FactionDef>(); for (int i = 0; i < DefDatabase <FactionDef> .AllDefsListForReading.Count; i++) { FactionDef f = DefDatabase <FactionDef> .AllDefsListForReading[i]; FactionDefExtension extension = f.GetModExtensionFast <FactionDefExtension>(); if (f.defName.Contains(Colorable.Props.Key) && extension != null) { if (extension.factionColor.HasValue) { factions.Add(f); } } } if (!factions.NullOrEmpty()) { var rect3 = new Rect(0f, y, rect.width, 20f); DrawFactionColorsButton(rect3, Colorable, false); y += rect2.height; } if (!factions.NullOrEmpty()) { var rect3 = new Rect(0f, y, rect.width, 20f); var rect3R = rect3.RightHalf(); var rect3L = rect3.LeftHalf(); y += rect2.height; } } } GUI.EndGroup(); }
public void UpdateGraphic() { if (Drawer?.pawn == null) { Graphic = null; return; } if (apparel.Wearer == null) { if (Drawer != null) { Drawer.pawn = null; } Graphic = null; return; } if (Drawer.pawn != apparel.Wearer) { // Log.Message("Old Wearer: "+ Drawer.pawn + "new Wearer: "+ apparel.Wearer); Drawer.pawn = apparel.Wearer; } Pawn pawn = Drawer.pawn; Shader shader = this.Shader; string path = padTexPath; if (UseFactionTextures || UseVariableTextures) { bool notPlayer = pawn.Faction != null && (pawn.Faction != Faction.OfPlayer); if (notPlayer) { FactionDefExtension ext = pawn.Faction.def.HasModExtension <FactionDefExtension>() ? pawn.Faction.def.GetModExtensionFast <FactionDefExtension>() : null; bool factionTextures = UseFactionTextures && ext?.factionTextureTag != null; if (factionTextures) { // Log.Message("using factionTextureTag " + ext.factionTextureTag); for (int i = 0; i < Options.Count; i++) { if (Options[i].TexPath == ext.factionTextureTag) { Used = Options[i]; // Log.Message("Found faction VariantTexture " + VariantTextures.Options[i].texPath); break; } } } else { bool foundVar = false; if (!Options.NullOrEmpty()) { for (int i = 0; i < Options.Count; i++) { if (pawn.kindDef.apparelTags.Contains(Options[i].TexPath)) { Used = Options[i]; foundVar = true; // Log.Message("Found KindDef VariantTexture " + VariantTextures.Options[i].texPath); break; } } if (!foundVar) { Used = Options.RandomElement(); } } } } else { if (UseFactionTextures) { // Log.Message("UseFactionTextures"); // CompColorableTwoFaction FC = Drawer.Colours as CompColorableTwoFaction; if (Drawer.Colours is CompColorableTwoFaction FC) { // Log.Message("FC != null"); if (FC.FactionDef != null) { // Log.Message("FactionDef = " + FC.FactionDef.LabelCap); FactionDefExtension e = FC.Extension; if (e != null) { // Log.Message("FactionDefExtension != null"); if (!Options.NullOrEmpty()) { // Log.Message("Options: " + Options.Count); for (int i = 0; i < Options.Count; i++) { // Log.Message("checking " + e.factionTextureTag + " Vs " + Options[i].TexPath + " = " + (Options[i].TexPath == e.factionTextureTag)); if (Options[i].TexPath == e.factionTextureTag) { Used = Options[i]; // Log.Message("Found faction VariantTexture " + Options[i].TexPath); break; } } } } } } else { // Log.Message("FC == null"); List <FactionDef> factions = DefDatabase <FactionDef> .AllDefsListForReading; // Log.Message("UpdateGraphic() 4 1 B 1 1 B 2 factions: "+ factions.Count); for (int i = 0; i < factions.Count; i++) { // Log.Message("UpdateGraphic() 4 1 B 1 1 B 2 faction: " + i); FactionDef f = factions[i]; // Log.Message("UpdateGraphic() 4 1 B 1 1 B 2 faction: " + f); FactionDefExtension e = f.HasModExtension <FactionDefExtension>() ? f.GetModExtensionFast <FactionDefExtension>() : null; // Log.Message("UpdateGraphic() 4 1 B 1 1 B 2 faction: " + (e == null)); if (e == null) { // Log.Message("e == null"); continue; } if (e.factionTextureTag.NullOrEmpty()) { // Log.Message("factionTextureTag == null"); continue; } if (!Options.NullOrEmpty()) { // Log.Message("UpdateGraphic() 4 1 B 1 1 A 1 1 1"); // Log.Message("Options: " + Options.Count); for (int ii = 0; ii < Options.Count; ii++) { // Log.Message("checking " + e.factionTextureTag + " Vs " + Options[i].TexPath + " = " + (Options[i].TexPath == e.factionTextureTag)); if (Options[ii].TexPath == e.factionTextureTag) { faction = f; // Log.Message("Found faction VariantTexture " + Options[i].TexPath); break; } } } } } } } path = padTexPath + "/" + Used.TexPath; } string body = bodyTypeString(pawn.story.bodyType); string testRot = "_"; if (CheckPauldronRotation(Rot4.South)) { testRot += "south"; } else if (CheckPauldronRotation(Rot4.North)) { testRot += "north"; } else if (CheckPauldronRotation(Rot4.East)) { testRot += "east"; } else if (CheckPauldronRotation(Rot4.West)) { testRot += "west"; } else { testRot = ""; } string testpath = path + body + testRot; Texture2D tex = ContentFinder <Texture2D> .Get(testpath, false); Graphic graphic; if (tex == null) { this.UpdateProps(); path = padTexPath; if (UseFactionTextures || UseVariableTextures) { path = padTexPath + "/" + this.DefaultOption.TexPath; } } path += body; Color color = Drawer.mainColorFor(this); Color colorTwo = Drawer.secondaryColorFor(this); graphic = GraphicDatabase.Get <Graphic_Multi>(path, shader, size, color, colorTwo); if (Drawer.Colours is CompColorableTwoFaction factionColors) { Texture texture; if (factionColors.ActiveFaction) { if (!factionColors.Extension.factionMaskTag.NullOrEmpty()) { string msk = "m_" + factionColors.Extension.factionMaskTag; texture = ContentFinder <Texture2D> .Get(graphic.path + "_east" + msk, false); if (texture != null) { graphic.MatEast.SetTexture(ShaderPropertyIDs.MaskTex, texture); } graphic.MatEast.SetColor(ShaderPropertyIDs.ColorTwo, colorTwo); texture = ContentFinder <Texture2D> .Get(graphic.path + "_west" + msk, false); if (texture != null) { graphic.MatWest.SetTexture(ShaderPropertyIDs.MaskTex, texture); } graphic.MatWest.SetColor(ShaderPropertyIDs.ColorTwo, colorTwo); texture = ContentFinder <Texture2D> .Get(graphic.path + "_south" + msk, false); if (texture != null) { graphic.MatSouth.SetTexture(ShaderPropertyIDs.MaskTex, texture); } graphic.MatSouth.SetColor(ShaderPropertyIDs.ColorTwo, colorTwo); texture = ContentFinder <Texture2D> .Get(graphic.path + "_north" + msk, false); if (texture != null) { graphic.MatNorth.SetTexture(ShaderPropertyIDs.MaskTex, texture); } graphic.MatNorth.SetColor(ShaderPropertyIDs.ColorTwo, colorTwo); } } } // Log.Message(this.Label + " " + graphic.path + " Shader: " + graphic.Shader.name + "Colour: " + graphic.Color + " Colour: " + graphic.ColorTwo); /* * if (!this.Drawer.apparel.def.apparel.wornGraphicPath.NullOrEmpty()) * { * SetApparelColours(); * } */ Graphic = graphic; }
// Token: 0x060046EB RID: 18155 RVA: 0x0017FE99 File Offset: 0x0017E099 private static IEnumerable <Widgets.DropdownMenuElement <FactionDef> > DrawFactionColorsButton_GenerateMenu(CompColorableTwoFaction e) { if (e.FactionDef != null) { yield return(new Widgets.DropdownMenuElement <FactionDef> { option = new FloatMenuOption("None", delegate() { /* * Graphic graphic = e.parent.DefaultGraphic; * Color color = graphic.Color; * Color colorTwo = graphic.ColorTwo; * * graphic = graphic.GetColoredVersion(graphic.Shader, color, colorTwo); * e.parent.SetColors(color, colorTwo, true, null, graphic); */ /* * e.drawer.apparel.SetColorOne(color); * e.drawer.apparel.SetColorTwo(colorTwo); * FieldInfo subgraphic = typeof(Thing).GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField); * Traverse traverse = Traverse.Create(e.drawer.apparel); * subgraphic.SetValue(e.drawer.apparel, graphic); */ e.FactionDef = null; Graphic graphic = e.parent.DefaultGraphic; Color color = e.Color; Color colorTwo = e.ColorTwo; graphic = graphic.GetColoredVersion(graphic.Shader, color, colorTwo); e.parent.SetColors(color, colorTwo, true, e.FactionDef, graphic); }, MenuOptionPriority.Default, null, null, 0f, null, null), payload = null }); } string key = e.Props.Key; using (List <FactionDef> .Enumerator enumerator = e.ColouredDefs.OrderBy(x => x.label).ToList().GetEnumerator()) { while (enumerator.MoveNext()) { FactionDef variant = enumerator.Current; FactionDefExtension ext = enumerator.Current.GetModExtensionFast <FactionDefExtension>(); if (e.FactionDef != variant && variant.defName.Contains(key)) { if (ext == null) { continue; } if (ext.factionColor == null && ext.factionColorTwo == null && ext.factionMaskTag.NullOrEmpty() && ext.factionTextureTag.NullOrEmpty()) { continue; } yield return(new Widgets.DropdownMenuElement <FactionDef> { option = new FloatMenuOption((string)variant.LabelCap ?? variant.fixedName, delegate() { /* * Graphic graphic = e.parent.Graphic; * // graphic.path += "_" + variant.TexPath; * Color color = graphic.Color; * Color colorTwo = graphic.ColorTwo; * if (ext.factionColor != null) * { * color = ext.factionColor.Value; * } * if (ext.factionColorTwo != null) * { * colorTwo = ext.factionColorTwo.Value; * } * graphic = graphic.GetColoredVersion(graphic.Shader, color, colorTwo); * * e.parent.SetColors(color, colorTwo, true, variant, graphic); * Texture texture; * if (!ext.factionMaskTag.NullOrEmpty()) * { * string msk = "m_" + ext.factionMaskTag; * texture = ContentFinder<Texture2D>.Get(graphic.path + msk, false); * if (texture != null) * { * graphic.MatEast.SetTexture(ShaderPropertyIDs.MaskTex, texture); * } * graphic.MatEast.SetColor(ShaderPropertyIDs.ColorTwo, colorTwo); * } */ /* * e.drawer.apparel.SetColorOne(color); * e.drawer.apparel.SetColorTwo(colorTwo); * * FieldInfo subgraphic = typeof(Thing).GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField); * Traverse traverse = Traverse.Create(e.drawer.apparel); * subgraphic.SetValue(e.drawer.apparel, graphic); */ // Log.Message("set active"); e.FactionDef = variant; Graphic graphic = e.parent.DefaultGraphic; Color color = e.Color; Color colorTwo = e.ColorTwo; graphic = graphic.GetColoredVersion(graphic.Shader, color, colorTwo); e.parent.SetColors(color, colorTwo, true, e.FactionDef, graphic); }, MenuOptionPriority.Default, null, null, 0f, null, null), payload = variant }); } } } yield break; }
private static IEnumerable <Widgets.DropdownMenuElement <PauldronTextureOption> > DrawFactionButton_GenerateMenu(ShoulderPadEntry e) { if (e.Used != e.DefaultOption) { yield return(new Widgets.DropdownMenuElement <PauldronTextureOption> { option = new FloatMenuOption(e.DefaultOption.TexPath, delegate() { Graphic graphic = e.Drawer.apparel.DefaultGraphic; Color color = graphic.Color; Color colorTwo = graphic.ColorTwo; graphic = graphic.GetColoredVersion(graphic.Shader, color, colorTwo); /* * e.Drawer.apparel.SetColors(color, colorTwo, true, null, graphic); * e.drawer.apparel.SetColorOne(color); * e.drawer.apparel.SetColorTwo(colorTwo); * FieldInfo subgraphic = typeof(Thing).GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField); * Traverse traverse = Traverse.Create(e.drawer.apparel); * subgraphic.SetValue(e.drawer.apparel, graphic); */ e.Used = e.DefaultOption; e.faction = e.DefaultOption.factionDef; e.UpdateGraphic(); }, MenuOptionPriority.Default, null, null, 0f, null, null), payload = e.DefaultOption }); } using (List <PauldronTextureOption> .Enumerator enumerator = e.Options.OrderBy(x => x.Label).ToList().GetEnumerator()) { while (enumerator.MoveNext()) { PauldronTextureOption variant = enumerator.Current; if (e.Used != variant) { yield return(new Widgets.DropdownMenuElement <PauldronTextureOption> { option = new FloatMenuOption(variant.Label.CapitalizeFirst() ?? variant.TexPath, delegate() { Graphic graphic = e.Drawer.apparel.Graphic; graphic.path += "_" + variant.TexPath; Color color = graphic.Color; Color colorTwo = graphic.ColorTwo; if (variant.factionDef != null) { // e.faction = variant.factionDef; if (variant.factionDef.HasModExtension <FactionDefExtension>()) { FactionDefExtension extension = variant.factionDef.GetModExtensionFast <FactionDefExtension>(); if (extension.factionColor != null) { color = extension.factionColor.Value; } if (extension.factionColorTwo != null) { colorTwo = extension.factionColorTwo.Value; } } } else { if (e.UseFactionColors) { if (variant.Color.HasValue) { color = variant.Color.Value; } if (variant.ColorTwo.HasValue) { colorTwo = variant.ColorTwo.Value; } } } graphic = graphic.GetColoredVersion(graphic.Shader, color, colorTwo); /* * e.Drawer.apparel.SetColors(color, colorTwo, true, variant.factionDef, graphic); * e.drawer.apparel.SetColorOne(color); * e.drawer.apparel.SetColorTwo(colorTwo); * * FieldInfo subgraphic = typeof(Thing).GetField("graphicInt", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField); * Traverse traverse = Traverse.Create(e.drawer.apparel); * subgraphic.SetValue(e.drawer.apparel, graphic); */ // Log.Message("set active"); e.faction = variant.factionDef; e.Used = variant; // Log.Message("Update PadGraphic"); e.UpdateGraphic(); }, MenuOptionPriority.Default, null, null, 0f, null, null), payload = variant }); } } } yield break; }
public static void MakeTeleportAt(IntVec3 c, Map map, ActiveDropPodInfo info, FactionDefExtension extension = null) { /* * WeatherEvent @event = new WeatherEvent_DeepStrike_Teleport(map, c, boltstring: (extension !=null ? extension.TeleportBoltTexPath : "")); * map.weatherManager.eventHandler.AddEvent(@event); */ ThingDef TunnelDef = DefDatabase <ThingDef> .GetNamed("OG_AMA_Teleporter"); TeleportSpawner teleportSpawner = (TeleportSpawner)ThingMaker.MakeThing(TunnelDef, null); foreach (Thing item in info.innerContainer) { teleportSpawner.GetDirectlyHeldThings().TryAddOrTransfer(item, false); } teleportSpawner.extFaction = extension; GenSpawn.Spawn(teleportSpawner, c, map); }
public static void MakeFlyerLandAt(IntVec3 c, Map map, ActiveDropPodInfo info, FactionDefExtension extension = null) { ThingDef ActiveDropPod = DefDatabase <ThingDef> .GetNamed("OG_Active_DeepStrike_Flyer"); ThingDef DropPodIncoming = DefDatabase <ThingDef> .GetNamed("OG_DeepStrike_Flyer_Incoming"); ActiveFlyer activeDropPod = (ActiveFlyer)ThingMaker.MakeThing(ActiveDropPod, null); activeDropPod.Contents = info; activeDropPod.Contents.leaveSlag = false; SkyfallerMaker.SpawnSkyfaller(DropPodIncoming, activeDropPod, c, map); }
// Token: 0x06002762 RID: 10082 RVA: 0x0012C458 File Offset: 0x0012A858 public static void MakeTeleportAt(IntVec3 c, Map map, ActiveDropPodInfo info, FactionDefExtension extension) { WeatherEvent @event = new WeatherEvent_DeepStrike_Teleport(map, c, boltstring: (extension != null ? extension.TeleportBoltTexPath : "")); map.weatherManager.eventHandler.AddEvent(@event); ThingDef TunnelDef = DefDatabase <ThingDef> .GetNamed("OG_AMA_Teleporter"); // Log.Message(string.Format("making teleportSpawner: {0}, @: {1}, {2}, {3}", TunnelDef, c, map, info.innerContainer.ContentsString)); TeleportSpawner teleportSpawner = (TeleportSpawner)ThingMaker.MakeThing(TunnelDef, null); foreach (Thing item in info.innerContainer) { teleportSpawner.GetDirectlyHeldThings().TryAddOrTransfer(item, false); } GenSpawn.Spawn(teleportSpawner, c, map); //-- SkyfallerMaker.SpawnSkyfaller(ThingDefOf.DropPodIncoming, tunnelSpawner, c, map); }