public static void Postfix(IntVec3 c, DesignationDef def, ref Designation __result) { if (__result == null && DesignatorUtility.getFudgedForToilCheck) { __result = new Designation(c, def); } }
public static T FailOnThingMissingDesignation <T>(this T f, TargetIndex ind, DesignationDef desDef) where T : IJobEndable { f.AddEndCondition(delegate { Pawn actor = f.GetActor(); Job curJob = actor.jobs.curJob; JobCondition result; if (curJob.ignoreDesignations) { result = JobCondition.Ongoing; } else { Thing thing = curJob.GetTarget(ind).Thing; if (thing == null || actor.Map.designationManager.DesignationOn(thing, desDef) == null) { result = JobCondition.Incompletable; } else { result = JobCondition.Ongoing; } } return(result); }); return(f); }
// Expands cell designations iteratively to adjacent cells that are deemed valid by the expansionFilter. // Returns the number of additional cells designated. private int FloodExpandDesignationType(DesignationDef designationDef, Map map, ValidationPredicate initialFilter, ValidationPredicate expansionFilter) { var designatedCells = map.designationManager.SpawnedDesignationsOfDef(designationDef).Where(d => !d.target.HasThing).Select(d => d.target.Cell).ToList(); var markedCells = new HashSet <IntVec3>(designatedCells); var cellsToProcess = new Queue <IntVec3>(designatedCells.Where(c => initialFilter(c, map))); var adjacent = GenAdj.AdjacentCellsAround; var cyclesLimit = 1000000; var hitCount = 0; while (cellsToProcess.Count > 0 && cyclesLimit > 0) { cyclesLimit--; var baseCell = cellsToProcess.Dequeue(); for (int i = 0; i < adjacent.Length; i++) { var cell = baseCell + adjacent[i]; if (!markedCells.Contains(cell) && expansionFilter(cell, map)) { map.designationManager.AddDesignation(new Designation(cell, designationDef)); markedCells.Add(cell); hitCount++; cellsToProcess.Enqueue(cell); } } } if (cyclesLimit == 0) { AllowToolController.Instance.Logger.Error("Ran out of cycles while expanding designations: " + Environment.StackTrace); } return(hitCount); }
static void UnmarkDesignation(Pawn_JobTracker __instance, JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft, bool canReturnToPool) { if (__instance?.curJob?.bill == null || __instance.curJob.bill.billStack != null || condition != JobCondition.Succeeded) { return; } if (__instance.curJob.targetB != null && __instance.curJob.targetB.HasThing && !__instance.curJob.targetB.ThingDestroyed) { RecipeDef rec = __instance.curJob.bill.recipe; Thing thing = __instance.curJob.targetB.Thing; DesignationDef dDef = DefDatabase <DesignationDef> .AllDefsListForReading.FirstOrDefault(x => x.defName == rec.defName + "Designation"); if (dDef == null) { return; } Designation d = thing.Map.designationManager.DesignationOn(__instance.curJob.targetB.Thing, dDef); if (d == null) { return; } thing.Map.designationManager.RemoveDesignation(d); } }
//no longer shall haul designation be removed when a pawn puts an item down static bool Prefix(DesignationDef def) { if (def != DesignationDefOf.Haul) { return(true); } return(MiscUtil.StackFrameWithMethod("PlaceHauledThingInCell") == null); }
public void AddDesignation(Pawn p, DesignationDef def) { // create and add designation to the game and our managed list. var des = new Designation(p, def); _designations.Add(des); manager.map.designationManager.AddDesignation(des); }
public static void RemoveDesignationDefOfOn( DesignationDef of, Thing on ) { Designation designation = Find.DesignationManager.DesignationOn( on, of ); if( designation != null ) { Find.DesignationManager.RemoveDesignation( designation ); } }
public static void RemoveDesignationDefOfAt( DesignationDef of, IntVec3 at ) { Designation designation = Find.DesignationManager.DesignationAt( at, of ); if( designation != null ) { Find.DesignationManager.RemoveDesignation( designation ); } }
public List <Designation> DesignationsOfOn(DesignationDef def, AgeAndSex ageSex) { return(_designations.Where(des => des.def == def && des.target.HasThing && des.target.Thing is Pawn && ((Pawn)des.target.Thing).PawnIsOfAgeSex(ageSex)) .ToList()); }
/// <summary> /// Checks if a Thing has a designation of a given def. /// </summary> /// <param name="thing"></param> /// <param name="def">The designation def to check for</param> public static bool HasDesignation(this Thing thing, DesignationDef def) { if (thing.Map == null || thing.Map.designationManager == null) { return(false); } return(thing.Map.designationManager.DesignationOn(thing, def) != null); }
private void AddDesignation(Plant p, DesignationDef def = null) { // create designation var des = new Designation(p, def); // pass to adder AddDesignation(des); }
public object SetObjectData(object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector) { DesignationDef def = (DesignationDef)info.GetValue("def", typeof(DesignationDef)); return(new Designation((LocalTargetInfo)info.GetValue("target", typeof(LocalTargetInfo)), def) { designationManager = Find.CurrentMap.designationManager }); }
public static void RemoveDesignationDefOfAt(DesignationDef of, IntVec3 at) { Designation designation = Find.DesignationManager.DesignationAt(at, of); if (designation != null) { Find.DesignationManager.RemoveDesignation(designation); } }
public Designator_Plan(DesignateMode mode) { this.mode = mode; base.soundDragSustain = SoundDefOf.DesignateDragStandard; base.soundDragChanged = SoundDefOf.DesignateDragStandardChanged; base.useMouseIcon = true; base.hotKey = KeyBindingDefOf.Misc9; this.desDef = DesignationDefOf.Plan; }
public static void RemoveDesignationDefOfOn(DesignationDef of, Thing on) { Designation designation = Find.DesignationManager.DesignationOn(on, of); if (designation != null) { Find.DesignationManager.RemoveDesignation(designation); } }
public static Toil RemoveDesignationDefOfOn(DesignationDef of, Thing on) { return(new Toil { initAction = delegate { Common.RemoveDesignationDefOfOn(of, on); } }); }
public static Toil RemoveDesignationDefOfOn( DesignationDef of, Thing on ) { return new Toil { initAction = delegate { Common.RemoveDesignationDefOfOn( of, on ); } }; }
public static Toil RemoveDesignationDefOfAt( DesignationDef of, IntVec3 at ) { return new Toil { initAction = delegate { Common.RemoveDesignationDefOfAt( of, at ); } }; }
public static Toil RemoveDesignationsOnThing(TargetIndex ind, DesignationDef def) { Toil toil = new Toil(); toil.initAction = delegate { toil.actor.Map.designationManager.RemoveAllDesignationsOn(toil.actor.jobs.curJob.GetTarget(ind).Thing, false); }; return(toil); }
public static Toil RemoveDesignationDefOfAt(DesignationDef of, IntVec3 at) { return(new Toil { initAction = delegate { Common.RemoveDesignationDefOfAt(of, at); } }); }
/// <summary> /// Checks if a cell has a designation of a given def /// </summary> /// <param name="pos">The map position to check</param> /// <param name="def">The DesignationDef to detect</param> /// <param name="map">The map to look on. When null, defaults to VisibleMap.</param> public static bool HasDesignation(this IntVec3 pos, DesignationDef def, Map map = null) { if (map == null) { map = Find.CurrentMap; } if (map == null || map.designationManager == null) { return(false); } return(map.designationManager.DesignationAt(pos, def) != null); }
public override void DesignateThing(Thing t) { DesignationDef designation_def = comfort_prisoners.designation_def_no_sticky; if (xxx.config.rape_me_sticky_enabled) { designation_def = comfort_prisoners.designation_def; //comfort_prisoners.designation_def = comfort_prisoners.designation_def_no_sticky; } base.Map.designationManager.AddDesignation(new Designation(t, designation_def)); }
public Designator_PlantsHarvestSecondary() { defaultLabel = "ZEN_DesignatorHarvestSecondary".Translate(); defaultDesc = "ZEN_DesignatorHarvestSecondaryDesc".Translate(); icon = ContentFinder <Texture2D> .Get("Cupro/UI/Designations/HarvestSecondary"); soundDragSustain = SoundDefOf.DesignateDragStandard; soundDragChanged = SoundDefOf.DesignateDragStandardChanged; useMouseIcon = true; soundSucceeded = SoundDefOf.DesignateHarvest; designationDef = DefDatabase <DesignationDef> .GetNamed("ZEN_Designator_PlantsHarvestSecondary"); }
public static Toil RemoveDesignationAtPosition(IntVec3 pos,DesignationDef dDef) { Toil toil = new Toil(); toil.initAction= delegate{ Designation des = Find.DesignationManager.DesignationAt(pos, dDef); if(des!=null) { Find.DesignationManager.RemoveDesignation(des); } }; return toil; }
public RoofSupportToolDesignatorAdd() { this.soundDragSustain = SoundDefOf.DesignateDragStandard; this.soundDragChanged = SoundDefOf.DesignateDragStandardChanged; this.useMouseIcon = true; this.desDef = DesignationDefOf.Plan; this.defaultLabel = "Roof Support Tool"; this.defaultDesc = "Displays roof support range and can place plan to show radius."; this.icon = ContentFinder <Texture2D> .Get("RoofSupportTool"); this.soundSucceeded = SoundDefOf.DesignatePlanAdd; }
public Designator_HarvestReagent() { defaultLabel = "DesignatorHarvestReagent".Translate(); defaultDesc = "DesignatorHarvestReagentDesc".Translate(); icon = ContentFinder <Texture2D> .Get("UI/Designators/Harvest", true); soundDragSustain = SoundDefOf.DesignateDragStandard; soundDragChanged = SoundDefOf.DesignateDragStandardChanged; useMouseIcon = true; soundSucceeded = SoundDefOf.DesignateHarvest; hotKey = KeyBindingDefOf.Misc2; designationDef = DefDatabase <DesignationDef> .GetNamed("HarvestReagents"); }
static QBTypes() { try { compQBType = AccessTools.TypeByName("CompQualityBuilder"); compPropQBType = AccessTools.TypeByName("CompProperties_QualityBuilderr"); qbDesDef = DefDatabase <DesignationDef> .GetNamed("SkilledBuilder", false); } catch (System.Reflection.ReflectionTypeLoadException) //Aeh, this happens to people, should not happen, meh. { Verse.Log.Warning("Replace Stuff failed to check for Quality Builder"); } }
private void AddDesignation(Thing target, DesignationDef designationDef) { if (designationDef == DesignationDefOf.Deconstruct) { var building = target as Building; if (building?.ClaimableBy(Faction.OfPlayer) ?? false) { building.SetFaction(Faction.OfPlayer); } } AddDesignation(new Designation(target, designationDef)); }
public static Toil RemoveDesignationAtPosition(IntVec3 pos, DesignationDef dDef) { Toil toil = new Toil(); toil.initAction = delegate { Designation des = Find.DesignationManager.DesignationAt(pos, dDef); if (des != null) { Find.DesignationManager.RemoveDesignation(des); } }; return(toil); }
//pick up stuff until you can't anymore, //while you're up and about, pick up something and haul it //before you go out, empty your pockets public override Job JobOnThing(Pawn pawn, Thing thing, bool forced = false) { //bulky gear (power armor + minigun) so don't bother. if (MassUtility.GearMass(pawn) / MassUtility.Capacity(pawn) >= 0.8f) { return(null); } DesignationDef haulUrgentlyDesignation = DefDatabase <DesignationDef> .GetNamed("HaulUrgentlyDesignation", false); // Misc. Robots compatibility // See https://github.com/catgirlfighter/RimWorld_CommonSense/blob/master/Source/CommonSense11/CommonSense/OpportunisticTasks.cs#L129-L140 if (pawn.TryGetComp <CompHauledToInventory>() == null) { return(null); } //This WorkGiver gets hijacked by AllowTool and expects us to urgently haul corpses. if (ModCompatibilityCheck.AllowToolIsActive && thing is Corpse && pawn.Map.designationManager.DesignationOn(thing)?.def == haulUrgentlyDesignation && HaulAIUtility.PawnCanAutomaticallyHaulFast(pawn, thing, forced)) { return(HaulAIUtility.HaulToStorageJob(pawn, thing)); } if (!GoodThingToHaul(thing, pawn) || !HaulAIUtility.PawnCanAutomaticallyHaulFast(pawn, thing, forced)) { return(null); } StoragePriority currentPriority = StoreUtility.CurrentStoragePriorityOf(thing); if (StoreUtility.TryFindBestBetterStoreCellFor(thing, pawn, pawn.Map, currentPriority, pawn.Faction, out IntVec3 storeCell, true)) { //since we've gone through all the effort of getting the loc, might as well use it. //Don't multi-haul food to hoppers. if (thing.def.IsNutritionGivingIngestible) { if (thing.def.ingestible.preferability == FoodPreferability.RawBad || thing.def.ingestible.preferability == FoodPreferability.RawTasty) { List <Thing> thingList = storeCell.GetThingList(thing.Map); foreach (Thing t in thingList) { if (t.def == ThingDefOf.Hopper) { return(HaulAIUtility.HaulToStorageJob(pawn, thing)); } } } } }
public static T FailOnCellMissingDesignation <T>(this T f, TargetIndex ind, DesignationDef desDef) where T : IJobEndable { f.AddEndCondition(delegate { Pawn actor = f.GetActor(); Job curJob = actor.jobs.curJob; if (curJob.ignoreDesignations) { return(JobCondition.Ongoing); } return((actor.Map.designationManager.DesignationAt(curJob.GetTarget(ind).Cell, desDef) != null) ? JobCondition.Ongoing : JobCondition.Incompletable); }); return(f); }
static void UnmarkDesignation(Pawn_JobTracker __instance, JobCondition condition, bool releaseReservations, bool cancelBusyStancesSoft, bool canReturnToPool) { if (__instance?.curJob?.bill == null || __instance.curJob.bill.billStack != null /*|| condition != JobCondition.Succeeded*/) { return; } if (__instance.curJob.targetB != null && __instance.curJob.targetB.HasThing && !__instance.curJob.targetB.ThingDestroyed) { RecipeDef rec = __instance.curJob.bill.recipe; ThingWithComps thing = __instance.curJob.targetB.Thing as ThingWithComps; if (thing == null) { return; } // DesignationDef dDef = DefDatabase <DesignationDef> .AllDefsListForReading.FirstOrDefault(x => x.defName == rec.defName + "Designation"); if (dDef == null) { return; } Designation d = thing.Map.designationManager.DesignationOn(__instance.curJob.targetB.Thing, dDef); if (d == null) { return; } thing.Map.designationManager.RemoveDesignation(d); if (condition != JobCondition.Succeeded) { Settings.ResetSelectTick(); var comp = thing.AllComps?.FirstOrDefault(x => x is ApplicableDesignationThingComp && (x as ApplicableDesignationThingComp).Props.designationDef == dDef) as ApplicableDesignationThingComp; if (comp != null) { comp.Allowed = null; } var ds = Find.ReverseDesignatorDatabase.AllDesignators.FirstOrDefault(x => (x as Designator_MicroRecipe) != null && (x as Designator_MicroRecipe).designationDef == dDef); if (ds == null || !ds.CanDesignateThing(thing)) { return; } // thing.Map.designationManager.AddDesignation(new Designation(thing, dDef)); } } }
public static IEnumerable <Designation> SpawnedDesignationsOfDefEnumerable(DesignationManager __instance, DesignationDef def) { List <Designation> allDesignationsSnapshot = __instance.allDesignations; int count = allDesignationsSnapshot.Count; for (int i = 0; i < count; ++i) { Designation allDesignation = allDesignationsSnapshot[i]; if (allDesignation.def == def && (!allDesignation.target.HasThing || allDesignation.target.Thing.Map == __instance.map)) { yield return(allDesignation); } } }
private bool TryRemoveDesignation(Utilities_Livestock.AgeAndSex ageSex, DesignationDef def) { // get current designations List <Designation> currentDesignations = DesignationsOfOn(def, ageSex); // if none, return false if (currentDesignations.Count == 0) { return(false); } // else, remove one from the game as well as our managed list. (delete last - this should be the youngest/oldest). Designations.Remove(currentDesignations.Last()); currentDesignations.Last().Delete(); return(true); }
public bool IsValidDesignation(DesignationDef dummyDef) { if (dummyDef == CombatTrainingDefOf.TrainCombatDesignationMeleeOnly) { return(true); } if (dummyDef == CombatTrainingDefOf.TrainCombatDesignationRangedOnly) { return(true); } if (dummyDef == CombatTrainingDefOf.TrainCombatDesignation) { return(true); } return(false); }
public void AddDesignation( Pawn p, DesignationDef def ) { // create and add designation to the game and our managed list. Designation des = new Designation( p, def ); Designations.Add( des ); Find.DesignationManager.AddDesignation( des ); }
public List<Designation> DesignationsOfOn( DesignationDef def, Utilities_Livestock.AgeAndSex ageSex ) { return Designations.Where( des => des.def == def && des.target.HasThing && des.target.Thing is Pawn && ( (Pawn)des.target.Thing ).PawnIsOfAgeSex( ageSex ) ) .ToList(); }
private bool TryRemoveDesignation( Utilities_Livestock.AgeAndSex ageSex, DesignationDef def ) { // get current designations List<Designation> currentDesignations = DesignationsOfOn( def, ageSex ); // if none, return false if ( currentDesignations.Count == 0 ) { return false; } // else, remove one from the game as well as our managed list. (delete last - this should be the youngest/oldest). Designations.Remove( currentDesignations.Last() ); currentDesignations.Last().Delete(); return true; }
private void AddDesignation( Plant p, DesignationDef def = null ) { // create designation Designation des = new Designation( p, def ); // pass to adder AddDesignation( des ); }