public static bool Prefix(TransportPodsArrivalAction_LandInSpecificCell __instance, List <ActiveDropPodInfo> pods, int tile, IntVec3 ___cell, MapParent ___mapParent) { // Log.Message(string.Format("pods: {0}", pods.Count)); foreach (ActiveDropPodInfo info in pods) { for (int i = 0; i < info.innerContainer.Count; i++) { Thing dropship = info.innerContainer[i]; CompDropship comp = dropship.TryGetCompFast <CompDropship>(); if (comp != null) { // Log.Message(string.Format("pods: {0}", info.innerContainer.ContentsString)); Thing lookTarget = TransportPodsArrivalActionUtility.GetLookTarget(pods); Traverse tv = Traverse.Create(__instance); IntVec3 c = ___cell; Map map = ___mapParent.Map; TransportPodsArrivalActionUtility.RemovePawnsFromWorldPawns(pods); for (int ii = 0; ii < pods.Count; ii++) { DropPodUtility.MakeDropPodAt(c, map, pods[ii]); } Messages.Message("AvP_USCM_Dropship_MessageArrived".Translate(), lookTarget, MessageTypeDefOf.TaskCompletion, true); return(false); } } } return(true); }
/* * public new ActiveDropPodInfo Contents * { * get * { * return ((ActiveDropPod)this.innerContainer[0]).Contents; * } * set * { * ((ActiveDropPod)this.innerContainer[0]).Contents = value; * } * } */ // Token: 0x0600792A RID: 31018 RVA: 0x00239AC8 File Offset: 0x00237CC8 private void PodOpen() { Map map = base.Map; if (this.contents.despawnPodBeforeSpawningThing) { this.DeSpawn(DestroyMode.Vanish); } if (Dropship != null) { this.contents.innerContainer.Remove(Dropship); } else { return; } GenSpawn.Spawn(Dropship, base.Position, map, this.contents.setRotation.Value, this.contents.spawnWipeMode.Value, false); for (int i = this.contents.innerContainer.Count - 1; i >= 0; i--) { Thing thing = this.contents.innerContainer[i]; if (Dropship.TryGetCompFast <CompTransporter>() != null) { CompDropship transporter = Dropship.TryGetCompFast <CompDropship>(); transporter.Transporter.innerContainer.TryAddOrTransfer(thing); } } this.contents.innerContainer.ClearAndDestroyContents(DestroyMode.Vanish); // SoundDefOf.DropPod_Open.PlayOneShot(new TargetInfo(base.Position, map, false)); this.Destroy(DestroyMode.Vanish); }
public static bool Prefix(IntVec3 c, Map map, ActiveDropPodInfo info) { Thing dropship = null; CompDropship cargo = null; // CompTransporter comp2 = null; for (int index = 0; index < info.innerContainer.Count; index++) { if (info.innerContainer[index].TryGetCompFast <CompDropship>() != null) { dropship = info.innerContainer[index]; string defName = dropship.def.defName; ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDef.Named(defName + "_Active"), null); activeDropPod.Contents = info; EnsureInBounds(ref c, info.innerContainer[index].def, map); info.innerContainer.Remove(dropship); cargo = dropship.TryGetCompFast <CompDropship>(); cargo.Transporter.innerContainer = info.innerContainer; SkyfallerMaker.SpawnSkyfaller(ThingDef.Named(defName + "_Incoming"), dropship, c, map); return(false); } } return(true); }
// Token: 0x060047C7 RID: 18375 RVA: 0x00180F4C File Offset: 0x0017F14C public override void GenerateIntoMap(Map map) { method = PlayerPawnsArriveMethod.DropShip; if (Find.GameInitData == null) { return; } List <List <Thing> > list = new List <List <Thing> >(); foreach (Pawn item in Find.GameInitData.startingAndOptionalPawns) { list.Add(new List <Thing> { item }); } List <Thing> list2 = new List <Thing>(); foreach (ScenPart scenPart in Find.Scenario.AllParts) { list2.AddRange(scenPart.PlayerStartingThings()); } int num = 0; foreach (Thing thing in list2) { if (thing.def.CanHaveFaction) { thing.SetFactionDirect(Faction.OfPlayer); } list[num].Add(thing); num++; if (num >= list.Count) { num = 0; } } if ((int)this.method == (int)PlayerPawnsArriveMethod.DropShip) { Thing thing = ThingMaker.MakeThing(dropshipdef, null); CompDropship dropship = thing.TryGetComp <CompDropship>(); foreach (List <Thing> item in list) { dropship.Transporter.innerContainer.TryAddRangeOrTransfer(item); } dropship.autodustoff = true; if (DropCellFinder.TryFindDropSpotNear(MapGenerator.PlayerStartSpot, map, out IntVec3 spot, false, false, false, dropshipdef.Size)) { GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(dropship.Props.incomming, thing), spot, map, ThingPlaceMode.Near, null, null, default(Rot4)); } else { GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(dropship.Props.incomming, thing), MapGenerator.PlayerStartSpot, map, ThingPlaceMode.Near, null, null, default(Rot4)); } }
public static IEnumerable <FloatMenuOption> GetATKFloatMenuOptions(CompDropship representative, IEnumerable <IThingHolder> pods, Settlement settlement, Caravan car) { foreach (FloatMenuOption f in DropShipArrivalActionUtility.GetFloatMenuOptions <TransportPodsArrivalAction_AttackSettlement>(() => TransportPodsArrivalAction_AttackSettlement.CanAttack(pods, settlement), () => new TransportPodsArrivalAction_AttackSettlement(settlement, PawnsArrivalModeDefOf.EdgeDrop), "AttackAndDropAtEdge".Translate(settlement.Label), representative, settlement.Tile, car)) { yield return(f); } foreach (FloatMenuOption f2 in DropShipArrivalActionUtility.GetFloatMenuOptions <TransportPodsArrivalAction_AttackSettlement>(() => TransportPodsArrivalAction_AttackSettlement.CanAttack(pods, settlement), () => new TransportPodsArrivalAction_AttackSettlement(settlement, PawnsArrivalModeDefOf.CenterDrop), "AttackAndDropInCenter".Translate(settlement.Label), representative, settlement.Tile, car)) { yield return(f2); } yield break; }
public static IEnumerable <FloatMenuOption> GetGIFTFloatMenuOptions(CompDropship representative, IEnumerable <IThingHolder> pods, Settlement settlement, Caravan car) { return(Enumerable.Empty <FloatMenuOption>()); /* * if (settlement.Faction == Faction.OfPlayer) * { * return Enumerable.Empty<FloatMenuOption>(); * } * return DropShipArrivalActionUtility.GetFloatMenuOptions<TransportPodsArrivalAction_GiveGift>(() => TransportPodsArrivalAction_GiveGift.CanGiveGiftTo(pods, settlement), * () => new TransportPodsArrivalAction_GiveGift(settlement), "GiveGiftViaTransportPods".Translate(settlement.Faction.Name, * FactionGiftUtility.GetGoodwillChange(pods, settlement).ToStringWithSign()), representative, settlement.Tile, car); */ }
public static void Postfix(Caravan __instance, ref IEnumerable <Gizmo> __result) { float masss = 0; foreach (Pawn pawn in __instance.pawns.InnerListForReading) { Pawn_InventoryTracker pinv = pawn.inventory; for (int i = 0; i < pinv.innerContainer.Count; i++) { Thing dropship = pawn.inventory.innerContainer[i]; CompDropship comp = dropship.TryGetCompFast <CompDropship>(); if (comp != null) { masss += (pinv.innerContainer[i].def.BaseMass * pinv.innerContainer[i].stackCount); Command_Action launch = new Command_Action(); launch.defaultLabel = "CommandSendShuttle".Translate(); launch.defaultDesc = "CommandSendShuttleDesc".Translate(); launch.icon = ContentFinder <Texture2D> .Get("UI/Commands/LaunchShip", true); launch.alsoClickIfOtherInGroupClicked = false; launch.action = delegate { float maxmass = pinv.innerContainer[i].TryGetCompFast <CompTransporter>().Props.massCapacity; if (masss <= maxmass) { pinv.innerContainer[i].TryGetCompFast <CompDropship>().WorldStartChoosingDestination(__instance); } else { Messages.Message("TooBigTransportersMassUsage".Translate() + "(" + (maxmass - masss) + "KG)", MessageTypeDefOf.RejectInput, false); } }; List <Gizmo> newr = __result.ToList(); newr.Add(launch); Command_Action addFuel = new Command_Action(); addFuel.defaultLabel = "AvP_USCM_Dropship_CommandAddFuel".Translate(); addFuel.defaultDesc = "AvP_USCM_Dropship_CommandAddFuelDesc".Translate(); addFuel.icon = ContentFinder <Texture2D> .Get("Things/Item/Resource/Chemfuel", true); addFuel.alsoClickIfOtherInGroupClicked = false; addFuel.action = delegate { bool hasAddFuel = false; int fcont = 0; CompRefuelable comprf = pinv.innerContainer[i].TryGetCompFast <CompRefuelable>(); List <Thing> list = CaravanInventoryUtility.AllInventoryItems(__instance); //pinv.innerContainer.Count for (int j = 0; j < list.Count; j++) { if (list[j].def == ThingDefOf.Chemfuel) { fcont = list[j].stackCount; Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(__instance, list[j]); float need = comprf.Props.fuelCapacity - comprf.Fuel; if (need < 1f && need > 0) { fcont = 1; } if (fcont * 1f >= need) { fcont = (int)need; } // Log.Warning("f&n is "+fcont+"/"+need); if (list[j].stackCount * 1f <= fcont) { list[j].stackCount -= fcont; Thing thing = list[j]; ownerOf.inventory.innerContainer.Remove(thing); thing.Destroy(DestroyMode.Vanish); } else { if (fcont != 0) { list[j].SplitOff(fcont).Destroy(DestroyMode.Vanish); } } Type crtype = comprf.GetType(); FieldInfo finfo = crtype.GetField("fuel", BindingFlags.NonPublic | BindingFlags.Instance); finfo.SetValue(comprf, comprf.Fuel + fcont); hasAddFuel = true; break; } } if (hasAddFuel) { Messages.Message("AvP_USCM_Dropship_AddFuelDoneMsg".Translate(fcont, comprf.Fuel), MessageTypeDefOf.PositiveEvent, false); } else { Messages.Message("AvP_USCM_Dropship_NoFuelMsg".Translate(), MessageTypeDefOf.RejectInput, false); } }; newr.Add(addFuel); Gizmo_MapRefuelableFuelStatus fuelStat = new Gizmo_MapRefuelableFuelStatus { nowFuel = pinv.innerContainer[i].TryGetCompFast <CompRefuelable>().Fuel, maxFuel = pinv.innerContainer[i].TryGetCompFast <CompRefuelable>().Props.fuelCapacity, compLabel = pinv.innerContainer[i].TryGetCompFast <CompRefuelable>().Props.FuelGizmoLabel }; newr.Add(fuelStat); __result = newr; return; } } } }
public override void GenerateIntoMap(Map map) { if (Find.GameInitData == null) { return; } List <List <Thing> > list = new List <List <Thing> >(); foreach (Pawn item in Find.GameInitData.startingAndOptionalPawns) { list.Add(new List <Thing> { item }); } List <Thing> list2 = new List <Thing>(); foreach (ScenPart scenPart in Find.Scenario.AllParts) { list2.AddRange(scenPart.PlayerStartingThings()); } int num = 0; for (int i = 0; i < list2.Count; i++) { Thing thing = list2[i]; if (thing.def.CanHaveFaction) { thing.SetFactionDirect(Faction.OfPlayer); } list[num].Add(thing); num++; if (num >= list.Count) { num = 0; } } PlayerPawnsArriveMethod method = (PlayerPawnsArriveMethod)AccessTools.Field(typeof(ScenPart_PlayerPawnsArriveMethod), "method").GetValue(this); // Log.Message("method = " + method.ToStringHuman() + " dropship: "+ (DropshipDef != null)); if (DropshipDef != null && method == PlayerPawnsArriveMethod.DropPods) { Thing ship = ThingMaker.MakeThing(this.DropshipDef); CompDropship dropship = ship.TryGetCompFast <CompDropship>(); if (dropship != null) { foreach (List <Thing> item in list) { if (item.Contains(ship)) { item.Remove(ship); } dropship.Transporter.innerContainer.TryAddRangeOrTransfer(item); } dropship.autodustoff = AutoDustoff; if (DropCellFinder.TryFindDropSpotNear(MapGenerator.PlayerStartSpot, map, out IntVec3 spot, false, false, false, ship.def.Size)) { GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(ThingDef.Named(ship.def.defName + "_Incoming"), ship), spot, map, ThingPlaceMode.Near, null, null, default(Rot4)); } else { GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(ThingDef.Named(ship.def.defName + "_Incoming"), ship), MapGenerator.PlayerStartSpot, map, ThingPlaceMode.Near, null, null, default(Rot4)); } return; } }
public static IEnumerable <FloatMenuOption> GetVisitFloatMenuOptions(CompDropship representative, IEnumerable <IThingHolder> pods, Settlement settlement, Caravan car) { return(DropShipArrivalActionUtility.GetFloatMenuOptions <TransportPodsArrivalAction_VisitSettlement>(() => TransportPodsArrivalAction_VisitSettlement.CanVisit(pods, settlement), () => new TransportPodsArrivalAction_VisitSettlement(settlement), "VisitSettlement".Translate(settlement.Label), representative, settlement.Tile, car)); }
public static IEnumerable <FloatMenuOption> GetFloatMenuOptions <T>(Func <FloatMenuAcceptanceReport> acceptanceReportGetter, Func <T> arrivalActionGetter, string label, CompDropship representative, int destinationTile, Caravan car) where T : TransportPodsArrivalAction { FloatMenuAcceptanceReport rep = acceptanceReportGetter(); if (rep.Accepted || !rep.FailReason.NullOrEmpty() || !rep.FailMessage.NullOrEmpty()) { if (!rep.FailReason.NullOrEmpty()) { yield return(new FloatMenuOption(label + " (" + rep.FailReason + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { yield return(new FloatMenuOption(label, delegate { FloatMenuAcceptanceReport floatMenuAcceptanceReport = acceptanceReportGetter(); if (floatMenuAcceptanceReport.Accepted) { representative.TryLaunch(destinationTile, arrivalActionGetter(), car); } else if (!floatMenuAcceptanceReport.FailMessage.NullOrEmpty()) { Messages.Message(floatMenuAcceptanceReport.FailMessage, new GlobalTargetInfo(destinationTile), MessageTypeDefOf.RejectInput, false); } }, MenuOptionPriority.Default, null, null, 0f, null, null)); } } yield break; }
private static void SpawnDropship() { List <DebugMenuOption> list = new List <DebugMenuOption>(); foreach (ThingDef localDef2 in from f in DefDatabase <ThingDef> .AllDefs where f.HasComp(typeof(CompDropship)) orderby f.defName select f) { ThingDef localDef = localDef2; list.Add(new DebugMenuOption(localDef.defName, DebugMenuOptionMode.Tool, delegate() { List <FloatMenuOption> list2 = new List <FloatMenuOption>(); IntVec3 cell = UI.MouseCell(); ThingDef Incomingdef = DefDatabase <ThingDef> .GetNamedSilentFail(localDef.defName + "_Incoming"); if (Incomingdef != null) { list2.Add(new FloatMenuOption("Incoming", delegate() { Thing Dropship = ThingMaker.MakeThing(localDef, null); CompDropship compDropship = Dropship.TryGetCompFast <CompDropship>(); if (compDropship != null) { compDropship.Refuelable.Refuel(compDropship.Refuelable.TargetFuelLevel); } GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(Incomingdef, Dropship), cell, Find.CurrentMap, ThingPlaceMode.Near, null, null, default); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } ThingDef Crasheddef = DefDatabase <ThingDef> .GetNamedSilentFail(localDef.defName + "_Crashed"); if (Crasheddef != null) { ThingDef Crashingdef = DefDatabase <ThingDef> .GetNamedSilentFail(localDef.defName + "_Crashing"); if (Crashingdef != null) { list2.Add(new FloatMenuOption("Crashing", delegate() { Thing Dropship = ThingMaker.MakeThing(Crasheddef, null); CompDropship compDropship = Dropship.TryGetCompFast <CompDropship>(); if (compDropship != null) { compDropship.Refuelable.Refuel(compDropship.Refuelable.TargetFuelLevel); } GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(Crashingdef, Dropship), cell, Find.CurrentMap, ThingPlaceMode.Near, null, null, default(Rot4)); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } } list2.Add(new FloatMenuOption("Stationary", delegate() { Thing Dropship = ThingMaker.MakeThing(localDef, null); CompDropship compDropship = Dropship.TryGetCompFast <CompDropship>(); if (compDropship != null) { compDropship.Refuelable.Refuel(compDropship.Refuelable.TargetFuelLevel); } GenPlace.TryPlaceThing(Dropship, cell, Find.CurrentMap, ThingPlaceMode.Near, null, null, default(Rot4)); }, MenuOptionPriority.Default, null, null, 0f, null, null)); Find.WindowStack.Add(new FloatMenu(list2)); })); } Find.WindowStack.Add(new Dialog_DebugOptionListLister(list)); }