protected override IEnumerable <Toil> MakeNewToils() { yield return(Toils_Reserve.Reserve(TargetIndex.A, 1)); yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.InteractionCell).FailOn(delegate(Toil to) { Building_MechanicusMedTable building_CommsConsole = (Building_MechanicusMedTable)to.actor.jobs.curJob.GetTarget(TargetIndex.A).Thing; CompPowerTrader power = building_CommsConsole.GetComp <CompPowerTrader>(); return !power.PowerOn; })); yield return(new Toil { initAction = delegate { Pawn actor = this.GetActor(); Building_CommsConsole building_CommsConsole = (Building_CommsConsole)actor.jobs.curJob.GetTarget(TargetIndex.A).Thing; if (building_CommsConsole.CanUseCommsNow) { actor.jobs.curJob.commTarget.TryOpenComms(actor); } } }); yield break; }
public static void TenantInvite(Building_CommsConsole comms, Pawn pawn) { Messages.Message("InviteTenantMessage".Translate(), MessageTypeDefOf.NeutralEvent); MapComponent_Tenants.GetComponent(pawn.Map).Broadcast = true; if (Rand.Value < 0.20f) { var parms = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, pawn.Map); parms.raidStrategy = RaidStrategyDefOf.Retribution; parms.forced = true; Find.Storyteller.incidentQueue.Add(IncidentDefOf.Opportunists, Find.TickManager.TicksGame + Rand.Range(25000, 150000), parms, 240000); } else { var parms = new IncidentParms { target = pawn.Map, forced = true }; Find.Storyteller.incidentQueue.Add(IncidentDefOf.RequestForTenancy, Find.TickManager.TicksGame + Rand.Range(15000, 120000), parms, 240000); while (Rand.Value < 0.10) { Find.Storyteller.incidentQueue.Add(IncidentDefOf.RequestForTenancy, Find.TickManager.TicksGame + Rand.Range(15000, 120000), parms, 240000); } } }
public static void GetFloatMenuOptions_PostFix(Building_CommsConsole __instance, ref IEnumerable <FloatMenuOption> __result, Pawn myPawn) { List <FloatMenuOption> list = __result.ToList(); if (!MapComponent_Tenants.GetComponent(myPawn.Map).Broadcast) { void inviteTenant() { Job job = new Job(JobDefOf.JobUseCommsConsoleTenants, __instance); myPawn.jobs.TryTakeOrderedJob(job); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.OpeningComms, KnowledgeAmount.Total); } FloatMenuOption inviteTenants = new FloatMenuOption("InviteTenant".Translate(), inviteTenant, MenuOptionPriority.InitiateSocial); list.Add(inviteTenants); } if (!MapComponent_Tenants.GetComponent(myPawn.Map).BroadcastCourier) { void inviteCourier() { Job job = new Job(JobDefOf.JobUseCommsConsoleInviteCourier, __instance); myPawn.jobs.TryTakeOrderedJob(job); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.OpeningComms, KnowledgeAmount.Total); } FloatMenuOption inviteCouriers = new FloatMenuOption("CourierInvite".Translate(SettingsHelper.LatestVersion.CourierCost), inviteCourier, MenuOptionPriority.InitiateSocial); list.Add(inviteCouriers); } __result = list.AsEnumerable(); }
public FloatMenuOption CommFloatMenuOption(Building_CommsConsole console, Pawn negotiator) { StringBuilder sb = new StringBuilder(""); if (CommunicationEstablished) { sb.Append("CallOnRadio".Translate(this.GetCallLabel())); } else { sb.Append("PES_TryToCallOnRadio".Translate(GetCallLabel())); } return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(sb.ToString(), delegate() { console.GiveUseCommsJob(negotiator, this); }, MenuOptionPriority.InitiateSocial), negotiator, console)); }
private void SolarFlareShieldTick(int tickAmount) { if ((Find.TickManager.TicksGame) % tickAmount == 0) { if (compPowerTrader == null || compPowerTrader.PowerOn) { coordinator.hasActiveShield = true; GameCondition gameCondition = Find.World.GameConditionManager.GetActiveCondition(GameConditionDefOf.SolarFlare); if (gameCondition != null) { compPowerTrader.PowerOutput = -properties.shieldingPowerDrain; rotatorAngle += properties.rotatorSpeedActive * tickAmount; RoomGroup roomGroup = parent.GetRoomGroup(); if (roomGroup != null && !roomGroup.UsesOutdoorTemperature) { roomGroup.Temperature += properties.heatingPerTick * tickAmount; } if ((Find.TickManager.TicksGame) % (5 * tickAmount) == 0) { foreach (Building building in parent.Map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial)) { Building_CommsConsole console = building as Building_CommsConsole; if (console != null) { CompPowerTrader consoleCompPowerTrader = console.TryGetComp <CompPowerTrader>(); if (consoleCompPowerTrader != null) { consoleCompPowerTrader.PowerOn = false; } } } } } else { compPowerTrader.PowerOutput = -compPowerTrader.Props.basePowerConsumption; rotatorAngle += properties.rotatorSpeedIdle * tickAmount; } } else { coordinator.hasActiveShield = false; } } }
static bool Prefix(PassingShip __instance, Building_CommsConsole console, Pawn negotiator, ref FloatMenuOption __result) { string label = "CallOnRadio".Translate(__instance.GetCallLabel()); if (!__instance.Map.listerBuildings.allBuildingsColonist.Any(b => b.def.HasComp(typeof(Comp_EnhancedBeacon)) && b.TryGetComp <CompPowerTrader>().PowerOn)) { return(true); } else { Action action = delegate() { console.GiveUseCommsJob(negotiator, __instance); }; __result = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, MenuOptionPriority.InitiateSocial, null, null, 0f, null, null), negotiator, console, "ReservedBy"); return(false); } }
public static bool CommFloatMenuOptionPrefix(Building_CommsConsole console, Pawn negotiator, PassingShip __instance, ref FloatMenuOption __result) { string label = "CallOnRadio".Translate(__instance.GetCallLabel()); Action action = delegate { if (!AllPowered(__instance.Map).Any()) { Messages.Message("MessageNeedBeaconToTradeWithShip".Translate(), console, MessageTypeDefOf.RejectInput, false); } else { //Log.Message("Trying to use console with PassingShip " + __instance); console.GiveUseCommsJob(negotiator, __instance); } }; __result = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, MenuOptionPriority.InitiateSocial, null, null, 0f, null, null), negotiator, console, "ReservedBy"); return(false); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedOrNull(TargetIndex.A); yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.InteractionCell).FailOn(delegate(Toil to) { Building_CommsConsole building_CommsConsole = (Building_CommsConsole)to.actor.jobs.curJob.GetTarget(TargetIndex.A).Thing; return !building_CommsConsole.CanUseCommsNow; })); Toil invite = new Toil(); invite.initAction = delegate { Pawn actor = invite.actor; Building_CommsConsole building_CommsConsole = (Building_CommsConsole)actor.jobs.curJob.GetTarget(TargetIndex.A).Thing; if (building_CommsConsole.CanUseCommsNow) { Events.CourierInvite(building_CommsConsole, actor); } }; yield return(invite); }
public static void CourierInvite(Building_CommsConsole comms, Pawn pawn) { if (MapComponent_Tenants.GetComponent(pawn.Map).KilledCourier > 0) { string courierDeniedLabel = "CourierDeniedTitle".Translate(pawn.Map.Parent.Label); string courierDeniedText = "CourierDeniedRadioMessage".Translate(); Find.LetterStack.ReceiveLetter(courierDeniedLabel, courierDeniedText, LetterDefOf.NegativeEvent); } else { Messages.Message("CourierInvited".Translate(SettingsHelper.LatestVersion.CourierCost), MessageTypeDefOf.NeutralEvent); MapComponent_Tenants.GetComponent(pawn.Map).BroadcastCourier = true; IncidentParms parms = new IncidentParms() { target = pawn.Map, forced = true }; Find.Storyteller.incidentQueue.Add(IncidentDefOf.TenantCourier, Find.TickManager.TicksGame + Rand.Range(15000, 90000), parms, 240000); Thing silver = ThingMaker.MakeThing(RimWorld.ThingDefOf.Silver); silver.stackCount = (int)SettingsHelper.LatestVersion.CourierCost; MapComponent_Tenants.GetComponent(pawn.Map).CourierCost.Add(silver); } }
public FloatMenuOption CommFloatMenuOption(Building_CommsConsole console, Pawn negotiator) => FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption(GetCallLabel(), () => console.GiveUseCommsJob(negotiator, this), MenuOptionPriority.InitiateSocial), negotiator, console);
public FloatMenuOption CommFloatMenuOption(Building_CommsConsole console, Pawn negotiator) { return(new FloatMenuOption(Label, () => console.GiveUseCommsJob(negotiator, this))); }
public override void DoWindowContents(Rect inRect) { Rect baseRect = inRect; Rect leftRect = new Rect(0f, 15f, 120f, baseRect.height - 25f); Rect centerRect = new Rect(baseRect.width / 2f - 220f, 120f, 440f, baseRect.height - 120f); Rect rightRect = new Rect(baseRect.width - 120f, 15f, 120f, baseRect.height - 25f); GUI.BeginGroup(inRect); Rect titleRect = new Rect(baseRect.x, baseRect.y, baseRect.width, 30f); // GUI.BeginGroup(titleRect); Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Medium; string title = "Subsector " + storyTracker.SubsectorName; Widgets.Label(titleRect, title); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; // GUI.EndGroup(); GUI.BeginGroup(leftRect); float num = leftRect.y; CorruptionStoryTrackerUtilities.ListSeparatorBig(ref num, leftRect.width, "ImperialFrequencies".Translate()); num += 50f; for (int i = 0; i < storyTracker.ImperialFactions.Count; i++) { num += DrawFactionRowCommsIoM(storyTracker.ImperialFactions[i], num, leftRect, negotiator); } // Widgets.DrawRectFast(leftRect, Color.white); GUI.EndGroup(); this.DrawStarGrid(centerRect); // GUI.BeginGroup(centerRect); Rect worldRect = new Rect((centerRect.x + centerRect.width / 2f) - 30f, (centerRect.y + centerRect.height / 2f) - 30f, 60f, 60f); if (Widgets.ButtonImage(worldRect, CorruptionStoryTrackerUtilities.PlanetMedium)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); IEnumerable <ICommunicable> enumerable = negotiator.Map.passingShipManager.passingShips.Cast <ICommunicable>().Concat(Find.FactionManager.AllFactionsInViewOrder.Cast <ICommunicable>()); foreach (ICommunicable commTarget in enumerable) { ICommunicable localCommTarget = commTarget; string text = "CallOnRadio".Translate(new object[] { localCommTarget.GetCallLabel() }); Faction faction = localCommTarget as Faction; if (faction != null) { if (faction.IsPlayer) { continue; } if (!Building_CommsConsole.LeaderIsAvailableToTalk(faction)) { list.Add(new FloatMenuOption(text + " (" + "LeaderUnavailable".Translate(new object[] { faction.leader.LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); continue; } } Action action = delegate { localCommTarget.TryOpenComms(negotiator); }; list.Add(new FloatMenuOption(text, action, MenuOptionPriority.InitiateSocial, null, null, 0f, null, null)); } Find.WindowStack.Add(new FloatMenu(list, null, false)); } TooltipHandler.TipRegion(worldRect, "CurrentWorldInfoRect".Translate(new object[] { Find.World.info.name })); Rect worldLabelrect = worldRect; worldLabelrect.y += 65f; worldLabelrect.width = 80f; GUI.color = Color.red; Widgets.Label(worldLabelrect, Find.World.info.name); GUI.color = Color.white; foreach (StarMapObject current in storyTracker.SubSectorObjects) { // Log.Message(current.objectName + current.objectRect.ToString()); // Widgets.DrawRectFast(current.objectRect, Color.red); if (Widgets.ButtonImage(current.objectRect, current.objectTex)) { } TooltipHandler.TipRegion(current.objectRect, "StarmapObjectInfo".Translate(new object[] { current.objectName, current.diameter, "Unknown" })); } // GUI.EndGroup(); GUI.BeginGroup(rightRect); // Widgets.DrawRectFast(rightRect, Color.red); float num2 = rightRect.y; CorruptionStoryTrackerUtilities.ListSeparatorBig(ref num2, rightRect.width, "UnknownFrequencies".Translate()); num2 += 50f; for (int i = 0; i < storyTracker.XenoFactions.Count; i++) { num2 += DrawFactionRowCommsXeno(storyTracker.XenoFactions[i], num2, rightRect, negotiator); } GUI.EndGroup(); GUI.EndGroup(); if (Widgets.CloseButtonFor(inRect.AtZero())) { this.Close(); } }
public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(this Building_CommsConsole building, Pawn myPawn) { /*if (!myPawn.CanReserve(building, 1)) * { * FloatMenuOption item = new FloatMenuOption("CannotUseReserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null); * return new List<FloatMenuOption> * { * item * }; * }*/ if (!myPawn.CanReach(building, PathEndMode.InteractionCell, Danger.Some, false, TraverseMode.ByPawn)) { FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null); return(new List <FloatMenuOption> { item2 }); } if (building.Map.mapConditionManager.ConditionIsActive(MapConditionDefOf.SolarFlare)) { FloatMenuOption item3 = new FloatMenuOption("CannotUseSolarFlare".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null); return(new List <FloatMenuOption> { item3 }); } if (!building.GetFieldViaReflection <CompPowerTrader>("powerComp").PowerOn) { FloatMenuOption item4 = new FloatMenuOption("CannotUseNoPower".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null); return(new List <FloatMenuOption> { item4 }); } if (!myPawn.health.capacities.CapableOf(PawnCapacityDefOf.Talking)) { FloatMenuOption item5 = new FloatMenuOption("CannotUseReason".Translate(new object[] { "IncapableOfCapacity".Translate(new object[] { PawnCapacityDefOf.Talking.label }) }), null, MenuOptionPriority.Default, null, null, 0f, null); return(new List <FloatMenuOption> { item5 }); } if (!building.CanUseCommsNow) { Log.Error(myPawn + " could not use comm console for unknown reason."); FloatMenuOption item6 = new FloatMenuOption("Cannot use now", null, MenuOptionPriority.Default, null, null, 0f, null); return(new List <FloatMenuOption> { item6 }); } IEnumerable <ICommunicable> enumerable = myPawn.Map.passingShipManager.passingShips.Cast <ICommunicable>().Concat(Find.FactionManager.AllFactionsInViewOrder.Cast <ICommunicable>()); List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (ICommunicable commTarget in enumerable) { ICommunicable localCommTarget = commTarget; string text = "CallOnRadio".Translate(new object[] { localCommTarget.GetCallLabel() }); Faction faction = localCommTarget as Faction; if (faction != null) { if (faction.IsPlayer) { continue; } if (!Building_CommsConsole.LeaderIsAvailableToTalk(faction)) { list.Add(new FloatMenuOption(text + " (" + "LeaderUnavailable".Translate(new object[] { faction.leader.LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); continue; } } Action action = delegate { if (commTarget is TradeShip && !Building_OrbitalTradeBeacon.AllPowered(building.Map).Any <Building_OrbitalTradeBeacon>()) { Messages.Message("MessageNeedBeaconToTradeWithShip".Translate(), building, MessageSound.RejectInput); return; } Job job = new Job(JobDefOf.UseCommsConsole, building); job.commTarget = localCommTarget; myPawn.jobs.TryTakeOrderedJob(job); PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.OpeningComms, KnowledgeAmount.Total); }; ITWN.PostMenuOption(list, myPawn, building, text, action, priority: MenuOptionPriority.InitiateSocial); } return(list); }
public static void Postfix(Building_CommsConsole __instance, ref IEnumerable <FloatMenuOption> __result, Pawn myPawn) { foreach (var r in __result) { if (r.action == null) { return; } } var res = new List <FloatMenuOption>(__result); HashSet <Pawn> toCheck = new HashSet <Pawn>(); toCheck.AddRange(myPawn.relations.FamilyByBlood); foreach (var rel in myPawn.relations.DirectRelations) { toCheck.Add(rel.otherPawn); } foreach (var otherPawn in toCheck) { var rel = myPawn.GetMostImportantRelation(otherPawn); if ( otherPawn.IsColonistPlayerControlled || otherPawn.Faction == myPawn.Faction || otherPawn.Map == myPawn.Map || otherPawn.Dead || otherPawn.IsPrisoner || !Utils.IsInvitableRelationship(rel) ) { continue; } res.Add(new FloatMenuOption( "LongDistance.Invite".Translate( otherPawn.Named("PAWN"), rel.GetGenderSpecificLabel(otherPawn).CapitalizeFirst().Named("REL"), otherPawn.Faction.Named("FACTION") ), () => myPawn.jobs.TryTakeOrderedJob(new Job(LongDistanceMod.InviteJob, otherPawn, __instance)), otherPawn.Faction.def.FactionIcon, otherPawn.Faction.Color )); if (Utils.IsBreakableRelationship(rel)) { res.Add(new FloatMenuOption( "LongDistance.Breakup".Translate( otherPawn.Named("PAWN"), rel.GetGenderSpecificLabel(otherPawn).CapitalizeFirst().Named("REL"), otherPawn.Faction.Named("FACTION") ), () => myPawn.jobs.TryTakeOrderedJob(new Job(LongDistanceMod.BreakupJob, otherPawn, __instance)), otherPawn.Faction.def.FactionIcon, otherPawn.Faction.Color )); } } __result = res; }
private static FloatMenuOption MakeOpt(string key, Pawn pawn, PawnRelationDef rel, Building_CommsConsole console, Action action) { return(new FloatMenuOption( key.Translate( pawn.Named("PAWN"), rel.GetGenderSpecificLabel(pawn).CapitalizeFirst().Named("REL"), pawn.Faction == null ? "LongDistance.Neutral".Translate().Named("FACTION") : pawn.Faction.Name.Named("FACTION") ), action, pawn.Faction?.def.FactionIcon, pawn.Faction == null ? Color.white : pawn.Faction.Color )); }
public static void Postfix(Building_CommsConsole __instance, ref IEnumerable <FloatMenuOption> __result, Pawn myPawn) { if (mGetFailureReason == null) { mGetFailureReason = typeof(Building_CommsConsole).GetMethod("GetFailureReason", BindingFlags.NonPublic | BindingFlags.Instance); Log.Message("Grabbed GetFailureReason: " + mGetFailureReason.ToString()); } if (mGetFailureReason.Invoke(__instance, new object[] { myPawn }) != null) { return; } var res = new List <FloatMenuOption>(__result); HashSet <Pawn> toCheck = new HashSet <Pawn>(); toCheck.AddRange(myPawn.relations.FamilyByBlood); foreach (var rel in myPawn.relations.DirectRelations) { toCheck.Add(rel.otherPawn); } foreach (var otherPawn in toCheck) { if (otherPawn == null || otherPawn.relations == null) { continue; } var rel = myPawn.GetMostImportantRelation(otherPawn); if (rel == null) { continue; } if ( otherPawn.IsColonistPlayerControlled || otherPawn.Faction == myPawn.Faction || otherPawn.Map == myPawn.Map || otherPawn.Dead || otherPawn.IsPrisoner || !Utils.IsInvitableRelationship(rel) ) { continue; } res.Add(MakeOpt("LongDistance.Invite", otherPawn, rel, __instance, () => myPawn.jobs.TryTakeOrderedJob(new Job(LongDistanceMod.InviteJob, otherPawn, __instance)) )); if (Utils.IsBreakableRelationship(rel)) { res.Add(MakeOpt("LongDistance.Breakup", otherPawn, rel, __instance, () => myPawn.jobs.TryTakeOrderedJob(new Job(LongDistanceMod.BreakupJob, otherPawn, __instance)) )); } } __result = res; }
static void PostFix(Building_CommsConsole __instance, ref IEnumerable <ICommunicable> __result) { __result = __result.Concat(IncidentCaravanUtility.GetAllCommunicableCaravan()); }