public static void Postfix(Vector3 clickPos, Pawn pawn, ref List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); foreach (Pair <OgsOld_CompTurret, Thing> pair in OgsOld_CompTurretReloadableUtility.FindPotentiallyReloadableGear(pawn, c.GetThingList(pawn.Map))) { OgsOld_CompTurretGun comp = pair.First as OgsOld_CompTurretGun; Thing second = pair.Second; string text4 = "Reload".Translate(comp.parent.Named("GEAR"), comp.AmmoDef.Named("AMMO")) + " (" + comp.LabelRemaining + ")"; List <Thing> chosenAmmo; if (!pawn.CanReach(second, PathEndMode.ClosestTouch, Danger.Deadly, false, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption(text4 + ": " + "NoPath".Translate().CapitalizeFirst(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!comp.NeedsReload(true)) { opts.Add(new FloatMenuOption(text4 + ": " + "ReloadFull".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if ((chosenAmmo = OgsOld_CompTurretReloadableUtility.FindEnoughAmmo(pawn, second.Position, comp, true)) == null) { opts.Add(new FloatMenuOption(text4 + ": " + "ReloadNotEnough".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Action action4 = delegate() { pawn.jobs.TryTakeOrderedJob(JobGiver_ReloadOgsOld_CompTurret.MakeReloadJob(comp, chosenAmmo), JobTag.Misc); }; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text4, action4, MenuOptionPriority.Default, null, null, 0f, null, null), pawn, second, "ReservedBy")); } } }
public static void AddHumanlikeOrders_PostFix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { var c = IntVec3.FromVector3(clickPos); var slotLoadable = pawn.equipment.AllEquipmentListForReading.FirstOrDefault(x => x.TryGetComp <AdeptusMechanicus.CompSlotLoadable>() != null); if (slotLoadable != null) { var compSlotLoadable = slotLoadable.GetComp <AdeptusMechanicus.CompSlotLoadable>(); if (compSlotLoadable != null) { var thingList = c.GetThingList(pawn.Map); foreach (var slot in compSlotLoadable.Slots) { var loadableThing = thingList.FirstOrDefault(y => slot.CanLoad(y.def)); if (loadableThing != null) { FloatMenuOption itemSlotLoadable; var labelShort = loadableThing.Label; if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { itemSlotLoadable = new FloatMenuOption( "CannotEquip".Translate(labelShort) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(loadableThing, PathEndMode.ClosestTouch, Danger.Deadly)) { itemSlotLoadable = new FloatMenuOption( "CannotEquip".Translate(labelShort) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReserve(loadableThing, 1)) { itemSlotLoadable = new FloatMenuOption( "CannotEquip".Translate(labelShort) + " (" + "ReservedBy".Translate(pawn.Map.physicalInteractionReservationManager .FirstReserverOf(loadableThing).LabelShort) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { var text2 = "Equip".Translate(labelShort); itemSlotLoadable = new FloatMenuOption(text2, delegate { loadableThing.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job(DefDatabase <JobDef> .GetNamed("GatherSlotItem"), loadableThing)); MoteMaker.MakeStaticMote(loadableThing.DrawPos, loadableThing.Map, ThingDefOf.Mote_FeedbackEquip, 1f); //PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.High, null, null, 0f, null, null); } opts.Add(itemSlotLoadable); } } } } }
protected override void ScatterAt(IntVec3 c, Map map, int stackCount = 1) { int randomInRange = GenStep_EscapeShip.EscapeShipSizeWidth.RandomInRange; int randomInRange2 = GenStep_EscapeShip.EscapeShipSizeHeight.RandomInRange; CellRect rect = new CellRect(c.x - randomInRange / 2, c.z - randomInRange2 / 2, randomInRange, randomInRange2); rect.ClipInsideMap(map); foreach (IntVec3 item in rect) { if (!map.terrainGrid.TerrainAt(item).affordances.Contains(TerrainAffordance.Heavy)) { CompTerrainPumpDry.AffectCell(map, item); for (int i = 0; i < 8; i++) { Vector2 vector = Random.insideUnitCircle * 3f; IntVec3 c2 = IntVec3.FromVector3(item.ToVector3Shifted() + new Vector3(vector.x, 0f, vector.y)); if (c2.InBounds(map)) { CompTerrainPumpDry.AffectCell(map, c2); } } } } ResolveParams resolveParams = default(ResolveParams); resolveParams.rect = rect; RimWorld.BaseGen.BaseGen.globalSettings.map = map; RimWorld.BaseGen.BaseGen.symbolStack.Push("ship_core", resolveParams); RimWorld.BaseGen.BaseGen.Generate(); }
public override void Generate(Map map, GenStepParams parms) { base.Generate(map, parms); int randomInRange = GenStep_AmbrosiaAnimalsGenLGE.AmbrosiaSproutSizeWidth.RandomInRange; int randomInRange2 = GenStep_AmbrosiaAnimalsGenLGE.AmbrosiaSproutSizeHeight.RandomInRange; CellRect rect = new CellRect(Rand.RangeInclusive(this.adventureRegion.minX + 10, this.adventureRegion.maxX - AmbrosiaSproutSizeWidth.max - 10), Rand.RangeInclusive(this.adventureRegion.minZ + 10, this.adventureRegion.maxZ - AmbrosiaSproutSizeHeight.max - 10), randomInRange, randomInRange2); rect.ClipInsideMap(map); foreach (IntVec3 c2 in rect) { CompTerrainPumpDry.AffectCell(map, c2); for (int i = 0; i < 8; i++) { Vector3 b = Rand.InsideUnitCircleVec3 * 3f; IntVec3 c3 = IntVec3.FromVector3(c2.ToVector3Shifted() + b); if (c3.InBounds(map)) { CompTerrainPumpDry.AffectCell(map, c3); } } } ResolveParams baseResolveParams = default(ResolveParams); baseResolveParams.rect = rect; BaseGen.globalSettings.map = map; BaseGen.symbolStack.Push("ambrosiaAreaPrepareLGE", baseResolveParams); BaseGen.Generate(); }
public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { Pawn pawn2 = GridsUtility.GetThingList(IntVec3.FromVector3(clickPos), pawn.Map) .FirstOrDefault((Thing x) => x is Pawn) as Pawn; var mapComp = pawn.Map.GetComponent <MapComponentZLevel>(); var ZTracker = ZUtils.ZTracker; if (pawn2 != null && ZTracker.ZLevelsTracker[pawn.Map.Tile].ZLevels.Count > 1) { TaggedString toCheck = "Rescue".Translate(pawn2.LabelCap, pawn2); FloatMenuOption floatMenuOption = opts.FirstOrDefault((FloatMenuOption x) => x.Label.Contains (toCheck)); if (floatMenuOption != null) { opts.Remove(floatMenuOption); opts.Add(AddHumanlikeOrders_Patch.AddRescueOption(pawn, pawn2)); } TaggedString toCheck2 = "Capture".Translate(pawn2.LabelCap, pawn2); FloatMenuOption floatMenuOption2 = opts.FirstOrDefault((FloatMenuOption x) => x.Label.Contains (toCheck2)); if (floatMenuOption2 != null) { opts.Remove(floatMenuOption2); opts.Add(AddHumanlikeOrders_Patch.AddCaptureOption(pawn, pawn2)); } } }
static void Postfix(Vector3 clickPos, Pawn pawn, ref List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); foreach (LocalTargetInfo current in GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true)) { if (pawn.equipment.TryGetOffHandEquipment(out ThingWithComps eq)) { FloatMenuOption unequipOffHandOption = new FloatMenuOption("DW_DropOffHand".Translate(eq.LabelShort), new Action(delegate { pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, eq)); })); //TODO translation opts.Add(unequipOffHandOption); } } if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[i]; FloatMenuOption equipOffHandOption = GetEquipOffHandOption(pawn, equipment); opts.Add(equipOffHandOption); } } } } }
public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { if (pawn.RaceProps.Humanlike && pawn.TryGetComp <CompKnowledge>() != null) { IntVec3 c = IntVec3.FromVector3(clickPos); ThingWithComps equipment = null; List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[i]; break; } } if (equipment != null && equipment.def.IsWeapon && !HarmonyPatches.CheckKnownWeapons(pawn, equipment)) { string labelShort = equipment.LabelShort; int Index = opts.FindIndex(x => x.Label.Contains(labelShort)); if (Index != -1) { string flavoredExplanation = ModBaseHumanResources.unlocked.weapons.Contains(equipment.def) ? "UnknownWeapon".Translate(pawn) : "EvilWeapon".Translate(pawn); FloatMenuOption item = new FloatMenuOption("CannotEquip".Translate(labelShort) + " (" + flavoredExplanation + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); opts.RemoveAt(Index); opts.Add(item); } } } }
/// <summary> /// Adds the "Find Treasure" option to the right click menu. /// </summary> private static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { var c = IntVec3.FromVector3(clickPos); if (!(c is IntVec3 vec) || !vec.IsValid || !(vec.GetTerrain(pawn.MapHeld) is TerrainDef def) || (def != TerrainDefOf.WaterDeep && def != TerrainDefOf.WaterMovingDeep && def != TerrainDefOf.WaterOceanDeep )) { return; } FloatMenuOption item5; var BOX = "Find Treasure"; if (!pawn.CanReach(c, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { item5 = new FloatMenuOption(" (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { var priority = MenuOptionPriority.Low; item5 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(BOX, delegate { var job = new Job(DefDatabase <JobDef> .GetNamed("LZG_FindTreasure"), c); job.count = 1; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, priority, null, null, 0f, null, null), pawn, c, "ReservedBy"); } opts.Add(item5); }
public override void Tick() { if (def == null || (ticks++ > projDef.lifetime && (effecter == null || this.effecter.ticksLeft <= 0))) { if (effecter != null) { effecter.Cleanup(); } Destroy(DestroyMode.Vanish); } if (effecter != null) { if (this.effecter.ticksLeft > 0) { var targetInfo = hitThing ?? new TargetInfo(IntVec3.FromVector3(b), launcher.Map, false); effecter.EffectTick(targetInfo, targetInfo); effecter.ticksLeft--; } else { this.effecter.Cleanup(); } } if (this.ticksToDetonation > 0) { this.ticksToDetonation--; if (this.ticksToDetonation <= 0) { this.Explode(); } } }
public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { return; } IntVec3 position = IntVec3.FromVector3(clickPos); var tools = position.GetThingList(pawn.Map).OfType <ThingWithComps>().Where(t => t.IsTool(true)).ToList(); foreach (var tool in tools) { if (!pawn.CanReach(tool, PathEndMode.ClosestTouch, Danger.Deadly)) { return; } if (!MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, tool, 1)) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUp".Translate(tool.Label, tool) + "AsTool".Translate() + " (" + "ApparelForcedLower".Translate() + ")", delegate { tool.SetForbidden(value: false, warnOnFail: false); var job = pawn.TakeTool(tool); pawn.jobs.TryTakeOrderedJob(job); }, MenuOptionPriority.High), pawn, tool)); } } }
public static bool TryFindDirectFleeDestination(IntVec3 root, float dist, Pawn pawn, out IntVec3 result) { for (int i = 0; i < 30; i++) { result = root + IntVec3.FromVector3(Vector3Utility.HorizontalVectorFromAngle((float)Rand.RangeSeeded(0, 360, Find.TickManager.TicksAbs + pawn.thingIDNumber)) * dist); if (result.Walkable(pawn.Map) && result.DistanceToSquared(pawn.Position) < result.DistanceToSquared(root) && GenSight.LineOfSight(root, result, pawn.Map, true, null, 0, 0)) { return(true); } } Region region = pawn.GetRegion(RegionType.Set_Passable); for (int j = 0; j < 30; j++) { Region region2 = CellFinder.RandomRegionNear(region, 15, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), null, null, RegionType.Set_Passable); IntVec3 randomCell = region2.RandomCell; if (randomCell.Walkable(pawn.Map) && (float)(root - randomCell).LengthHorizontalSquared > dist * dist) { using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, randomCell, pawn, PathEndMode.OnCell)) { if (PawnPathUtility.TryFindCellAtIndex(pawnPath, (int)dist + 3, out result)) { return(true); } } } } result = pawn.Position; return(false); }
public override void Generate(Map map, GenStepParams parms) { base.Generate(map, parms); int prisonCampWidth = GenStep_PrisonCampLGE.PrisonCampSizeWidth.RandomInRange; int prisonCampHeight = GenStep_PrisonCampLGE.PrisonCampSizeHeight.RandomInRange; CellRect rect = new CellRect(this.adventureRegion.minX + (this.adventureRegion.Width / 2) - (prisonCampWidth / 2), this.adventureRegion.minZ + (this.adventureRegion.Height / 2) - (prisonCampHeight / 2), prisonCampWidth, prisonCampHeight); rect.ClipInsideMap(map); foreach (IntVec3 c2 in rect) { CompTerrainPumpDry.AffectCell(map, c2); for (int i = 0; i < 8; i++) { Vector3 b = Rand.InsideUnitCircleVec3 * 3f; IntVec3 c3 = IntVec3.FromVector3(c2.ToVector3Shifted() + b); if (c3.InBounds(map)) { CompTerrainPumpDry.AffectCell(map, c3); } } } ResolveParams baseResolveParams = default(ResolveParams); baseResolveParams.rect = rect; BaseGen.globalSettings.map = map; BaseGen.symbolStack.Push("prisonCampLGE", baseResolveParams); BaseGen.Generate(); }
private void HarmPlant() { if (this.PlantHarmRange < 0.0001f) { return; } float angle = Rand.Range(0f, 360f); float num = Rand.Range(0f, this.PlantHarmRange); num = Mathf.Sqrt(num / this.PlantHarmRange) * this.PlantHarmRange; Quaternion rotation = Quaternion.AngleAxis(angle, Vector3.up); Vector3 point = Vector3.forward * num; Vector3 v = rotation * point; IntVec3 b = IntVec3.FromVector3(v); IntVec3 c = base.Position + b; if (c.InBounds(base.Map)) { Plant plant = c.GetPlant(base.Map); if (plant != null) { if (Rand.Value < 0.2f) { plant.Destroy(DestroyMode.Kill); } else { plant.MakeLeafless(); } } } this.ticksToPlantHarm = this.PlantHarmInterval; }
public static bool TryFindDirectFleeDestination(IntVec3 root, float dist, Pawn pawn, out IntVec3 result) { for (int i = 0; i < 30; i++) { result = root + IntVec3.FromVector3(Vector3Utility.HorizontalVectorFromAngle(Rand.Range(0, 360)) * dist); if (result.Walkable(pawn.Map) && result.DistanceToSquared(pawn.Position) < result.DistanceToSquared(root) && GenSight.LineOfSight(root, result, pawn.Map, skipFirstCell: true)) { return(true); } } Region region = pawn.GetRegion(); for (int j = 0; j < 30; j++) { IntVec3 randomCell = CellFinder.RandomRegionNear(region, 15, TraverseParms.For(pawn)).RandomCell; if (randomCell.Walkable(pawn.Map) && (float)(root - randomCell).LengthHorizontalSquared > dist * dist) { using (PawnPath path = pawn.Map.pathFinder.FindPath(pawn.Position, randomCell, pawn)) { if (PawnPathUtility.TryFindCellAtIndex(path, (int)dist + 3, out result)) { return(true); } } } } result = pawn.Position; return(false); }
public static void Postfix(Vector3 clickPos, Pawn pawn, ref List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); if (pawn.equipment != null) { List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { var options = thingList[i].def.GetModExtension <HeavyWeapon>(); if (options != null && options.isHeavy) { var equipment = (ThingWithComps)thingList[i]; TaggedString toCheck = "Equip".Translate(equipment.LabelShort); FloatMenuOption floatMenuOption = opts.FirstOrDefault((FloatMenuOption x) => x.Label.Contains(toCheck)); if (floatMenuOption != null && !CanEquip(pawn, options)) { opts.Remove(floatMenuOption); opts.Add(new FloatMenuOption("CannotEquip".Translate(equipment.LabelShort) + " (" + "VWE.CannotEquipHeavy".Translate(pawn.LabelShort) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } break; } } } }
static void Postfix(ref List <FloatMenuOption> __result, UnityEngine.Vector3 clickPos, Pawn pawn) { IntVec3 intVec = IntVec3.FromVector3(clickPos); var op = EquipFood.EquipFoodOption(intVec, pawn); if (op != null) { __result.Add(op); } }
static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { foreach (Thing t in IntVec3.FromVector3(clickPos).GetThingList(pawn.Map)) { if (t is Building_CommsConsole) { addOptions(pawn.Map, opts); } } }
public static bool Create(Vector3 clickPosition, Pawn pawn) { var c = IntVec3.FromVector3(clickPosition); if (!pawn.IsColonistPlayerControlled) { return(false); } if (pawn.Downed) { Messages.Message("IsIncapped".Translate((NamedArgument)pawn.LabelCap, (NamedArgument)pawn), pawn, MessageTypeDefOf.RejectInput, false); } else { if (pawn.Map != Find.CurrentMap) { return(false); } } var buildingList = StaticHelper.GetBuildings(c, pawn.Map); if (buildingList.NullOrEmpty()) { return(true); } ThingComp target = null; foreach (var building in buildingList) { target = building.AllComps.Find(x => x is IHoldMultipleThings.IHoldMultipleThings); } if (target == null) { return(true); } var thingList = new List <Thing>(c.GetThingList(pawn.Map)); if (thingList.NullOrEmpty()) { var cells = target.parent.GetSlotGroup().CellsList; foreach (var cell in cells) { thingList.AddRange(cell.GetThingList(pawn.Map)); } } Find.WindowStack.Add(new DSGUI_ListModal(pawn, thingList, clickPosition)); return(false); }
public static void OrderForSilverTreatment(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); foreach (Thing current in c.GetThingList(pawn.Map)) { if (current is ThingWithComps target && pawn != null && pawn != target) { if ((target?.def?.IsWeapon ?? false)) { if (pawn?.Map?.listerBuildings?.AllBuildingsColonistOfDef(DefDatabase <ThingDef> .GetNamed("TableMachining"))?.FirstOrDefault(x => x is Building_WorkTable) is Building_WorkTable machiningTable) { if (target.IsSilverTreated()) { //Do nothing } else if (!pawn.CanReach(target, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("ROM_CannotApplySilverTreatment".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReserve(target, 1)) { opts.Add(new FloatMenuOption("ROM_CannotApplySilverTreatment".Translate() + ": " + "Reserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReach(machiningTable, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("ROM_CannotApplySilverTreatment".Translate() + " (" + "ROM_NoPathToMachiningTable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (!pawn.CanReserve(machiningTable, 1)) { opts.Add(new FloatMenuOption("ROM_CannotApplySilverTreatment".Translate() + ": " + "ROM_MachiningTableReserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (pawn.Map.resourceCounter.Silver < SilverTreatedUtility.AmountRequired(target)) { opts.Add(new FloatMenuOption("ROM_CannotApplySilverTreatment".Translate() + ": " + "ROM_NeedsSilver".Translate(SilverTreatedUtility.AmountRequired(target)), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Action action = delegate { Job job = new Job(WWDefOf.ROM_ApplySilverTreatment, target, SilverTreatedUtility.FindSilver(pawn), machiningTable); job.count = SilverTreatedUtility.AmountRequired(target); pawn.jobs.TryTakeOrderedJob(job); }; opts.Add(new FloatMenuOption("ROM_ApplySilverTreatment".Translate(new object[] { target.LabelCap, SilverTreatedUtility.AmountRequired(target) }), action, MenuOptionPriority.High, null, target, 0f, null, null)); } } } } } }
private static void DoPickupOrder(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { if (!HugsLibUtility.ShiftIsHeld) { return; } IntVec3 c = IntVec3.FromVector3(clickPos); Thing item = c.GetFirstItem(pawn.Map); if (item != null && item.def.EverHaulable) { if (!pawn.CanReach(item, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(new object[] { item.Label }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (MassUtility.WillBeOverEncumberedAfterPickingUp(pawn, item, 1)) { opts.Add(new FloatMenuOption("CannotPickUp".Translate(new object[] { item.Label }) + " (" + "TooHeavy".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else if (item.stackCount == 1) { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUp".Translate(new object[] { item.Label }), delegate { item.SetForbidden(false, false); Job job = new Job(NewOrderJobDefOf.QOL_PickupObject, item); job.count = 1; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy")); } else { opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpAll".Translate(new object[] { item.Label }), delegate { item.SetForbidden(false, false); Job job = new Job(NewOrderJobDefOf.QOL_PickupObject, item); job.count = item.stackCount; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy")); } } }
public static List <FloatMenuOption> ChoicesAtFor(Vector3 clickPos, Pawn pawn) { IntVec3 intVec = IntVec3.FromVector3(clickPos); List <FloatMenuOption> list = new List <FloatMenuOption>(); if (intVec.InBounds(pawn.Map) && FloatMenuMakerMap.CanTakeOrder(pawn)) { if (pawn.Map != Find.VisibleMap) { return(list); } FloatMenuMakerMap.makingFor = pawn; try { if (intVec.Fogged(pawn.Map)) { FloatMenuOption floatMenuOption = FloatMenuMakerMap.GotoLocationOption(intVec, pawn); if (floatMenuOption != null) { if (!floatMenuOption.Disabled) { list.Add(floatMenuOption); return(list); } return(list); } return(list); } if (pawn.Drafted) { FloatMenuMakerMap.AddDraftedOrders(clickPos, pawn, list); } if (pawn.RaceProps.Humanlike) { FloatMenuMakerMap.AddHumanlikeOrders(clickPos, pawn, list); } if (!pawn.Drafted) { FloatMenuMakerMap.AddUndraftedOrders(clickPos, pawn, list); } foreach (FloatMenuOption item in pawn.GetExtraFloatMenuOptionsFor(intVec)) { list.Add(item); } return(list); } finally { FloatMenuMakerMap.makingFor = null; } } return(list); }
public static bool Create(Vector3 clickPosition, Pawn pawn) { var c = IntVec3.FromVector3(clickPosition); if (!pawn.IsColonistPlayerControlled || pawn.Downed || pawn.Map != Find.CurrentMap) { Log.Message("[DSGUI] Pawn is not player controlled, downed, or on the current map."); return(true); } var buildingList = StaticHelper.GetBuildings(c, pawn.Map).ToList(); // var building = c.GetFirstBuilding(pawn.Map); if (buildingList.EnumerableNullOrEmpty()) { Log.Message("[DSGUI] Building List is empty."); return(true); } var storageUnit = buildingList.Find(building => building.AllComps.Find(x => x is IHoldMultipleThings.IHoldMultipleThings) != null); if (storageUnit == null || storageUnit.DestroyedOrNull()) { Log.Message("[DSGUI] Found no valid target."); return(true); } // var thingList = new List<Thing>(c.GetThingList(pawn.Map)); List <Thing> thingList; if (DSGUIMain.modSimplyLoaded && storageUnit.def.modContentPack.PackageId == "jangodsoul.simplestorage") { var storageComp = (CompDeepStorage)storageUnit.AllComps.Find(x => x is CompDeepStorage); thingList = new List <Thing>(storageComp.getContentsHeader(out _, out _)); } else { thingList = new List <Thing>(c.GetThingList(pawn.Map)); } thingList.RemoveAll(t => t.def.category != ThingCategory.Item || t is Mote); if (thingList.EnumerableNullOrEmpty()) { Log.Message("[DSGUI] Thing List is empty."); return(true); } Find.WindowStack.Add(new DSGUI_ListModal(pawn, thingList, clickPosition)); return(false); }
void TriggerEffect(EffecterDef effect, Vector3 position) { if (effect == null) { return; } var targetInfo = new TargetInfo(IntVec3.FromVector3(position), Map, false); Effecter effecter = effect.Spawn(); effecter.offset = position - targetInfo.CenterVector3; effecter.Trigger(targetInfo, targetInfo); effecter.Cleanup(); }
public void TriggerEffect(EffecterDef effect, Vector3 position, Thing hitThing = null) { if (effect == null) { return; } var targetInfo = hitThing ?? new TargetInfo(IntVec3.FromVector3(position), launcher.Map, false); effecter = effect.Spawn(); effecter.offset = (position - targetInfo.CenterVector3); effecter.ticksLeft = this.projDef.effecterLifetime; effecter.Trigger(targetInfo, null); // effecter.Cleanup(); }
public static void AddArrestOrder(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { //TODO this is some copy-pasted example, refactor it so it should add arrest option IntVec3 c = IntVec3.FromVector3(clickPos); if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { foreach (LocalTargetInfo current in GenUI.TargetsAt(clickPos, ForArrest(pawn), true)) { LocalTargetInfo dest = current; bool flag = dest.HasThing && dest.Thing is Pawn && ((Pawn)dest.Thing).IsWildMan(); if (!pawn.Drafted || flag) { if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn)) { opts.Add(new FloatMenuOption("CannotArrest".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { Pawn pTarg = (Pawn)dest.Thing; Action action = delegate { Building_Bed building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, false); if (building_Bed == null) { building_Bed = RestUtility.FindBedFor(pTarg, pawn, true, false, true); } if (building_Bed == null) { Messages.Message("CannotArrest".Translate() + ": " + "NoPrisonerBed".Translate(), pTarg, MessageTypeDefOf.RejectInput, false); return; } Job job = new Job(JobDefOf.Arrest, pTarg, building_Bed); job.count = 1; pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); if (pTarg.Faction != null && pTarg.Faction != Faction.OfPlayer && !pTarg.Faction.def.hidden) { TutorUtility.DoModalDialogIfNotKnown(ConceptDefOf.ArrestingCreatesEnemies); } }; string label = "TryToArrest".Translate(dest.Thing.LabelCap, dest.Thing); Action action2 = action; MenuOptionPriority priority = MenuOptionPriority.High; Thing thing = dest.Thing; opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action2, priority, null, thing, 0f, null, null), pawn, pTarg, "ReservedBy")); } } } } }
static Exception Finalizer(Exception __exception, Vector3 clickPos, Pawn pawn) { // Time to clean up our mess if (pawn != null) { CompMeeseeksMemory compMeeseeksMemory = pawn.GetComp <CompMeeseeksMemory>(); if (compMeeseeksMemory != null) { IntVec3 cell = IntVec3.FromVector3(clickPos); DesignatorUtility.RestoreDesignationsOnCell(cell, pawn.MapHeld); } } return(__exception); }
//private static void CanTakeOrder_PostFix(Pawn pawn, ref bool __result) //{ // if (__result) // { // floatMenuID = Rand.Range(1000, 9999); // DebugMessage("FMOL :: ID Set to " + floatMenuID); // } //} // RimWorld.FloatMenuMakerMap public static void AddHumanlikeOrders_PostFix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { var c = IntVec3.FromVector3(clickPos); optsID = ""; optsID += pawn.ThingID; optsID += c.ToString(); for (var i = 0; i < (opts?.Count() ?? 0); i++) { optsID += opts[i].Label; } if (optsID == lastOptsID) { opts.AddRange(savedList); return; } DebugMessage("FMOL :: New list constructed"); DebugMessage(optsID); lastOptsID = optsID; savedList.Clear(); if (c.GetThingList(pawn.Map) is List <Thing> things && !things.NullOrEmpty()) { foreach (var pair in FloatMenuOptionList) { if (!pair.Value.NullOrEmpty()) { var passers = things.FindAll(x => pair.Key.Passes(x)); if (passers.NullOrEmpty()) { continue; } foreach (var passer in passers) { foreach (var func in pair.Value) { if (func.Invoke(clickPos, pawn, passer) is List <FloatMenuOption> newOpts && !newOpts.NullOrEmpty()) { opts?.AddRange(newOpts); savedList.AddRange(newOpts); } } } } } } }
// ReSharper disable once ParameterTypeCanBeEnumerable.Global public static void Postfix(List <FloatMenuOption> opts, Vector3 clickPos, Pawn pawn) { if (pawn?.apparel == null) { return; } var apparel = pawn.Map.thingGrid.ThingAt <Apparel>(IntVec3.FromVector3(clickPos)); if (apparel == null) { return; } var str = "ForceWear"; if (apparel.def.apparel.LastLayer.IsUtilityLayer) { str = "ForceEquipApparel"; } var comp = apparel.TryGetComp <Comp_VerbGiver>(); if (comp == null) { return; } if (!comp.VerbTracker.AllVerbs.Any(verb => !verb.IsMeleeAttack)) { return; } var traits = pawn.story?.traits; if (traits == null) { return; } if (!traits.HasTrait(TraitDefOf.Brawler)) { return; } foreach (var opt in opts) { if (opt.Label.Contains(str.Translate((NamedArgument)apparel.LabelShort, (NamedArgument)apparel))) { opt.Label += " " + "EquipWarningBrawler".Translate(); } } }
/// <summary> /// Add pickup option to context menu when right-click on items on map. /// </summary> /// <param name="clickPos"> Position of the mouse when right-click. </param> /// <param name="pawn"> Currently focused pawn. </param> /// <param name="opts"> Options displayed in context menu. </param> public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { ValidateArg.NotNull(pawn, nameof(pawn)); ValidateArg.NotNull(opts, nameof(opts)); if (pawn.IsQuestLodger()) { return; } IntVec3 position = IntVec3.FromVector3(clickPos); List <Thing> items = position.GetThingList(pawn.Map); if (!PickUpAndHaulUtility.IsActive) { foreach (Thing item in items) { if (item.def.category == ThingCategory.Item) { int count = MassUtility.CountToPickUpUntilOverEncumbered(pawn, item); if (count == 0) { continue; } count = Math.Min(count, item.stackCount); string displayText = UIText.Pickup.Translate(item.LabelNoCount + " x" + count); var option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( displayText , () => { Job job = JobMaker.MakeJob(JobDefOf.TakeInventory, item); job.count = count; job.checkEncumbrance = true; pawn.jobs.TryTakeOrderedJob(job); }) , pawn , item); opts.Add(option); } } } }
private static void DoMoveOrder(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { if (!HugsLibUtility.ShiftIsHeld) { return; } FloatMenuOption item; IntVec3 c = IntVec3.FromVector3(clickPos); string text = "MoveToOrder".Translate(); item = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text, delegate { pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Goto, c), JobTag.Misc); MoteMaker.MakeStaticMote(c, pawn.Map, ThingDefOf.Mote_FeedbackGoto, 1f); }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, c, "ReservedBy"); opts.Add(item); }