public static DismountInBase ( Pawn pawn, |
||
pawn | Pawn | |
cart | ||
return | Job |
private static Job GetVehicle(Pawn pawn, Job job, WorkTypeDef worktag) { if (!ToolsForHaulUtility.IsDriver(pawn)) { if (ToolsForHaulUtility.Cart.Count > 0 || ToolsForHaulUtility.CartTurret.Count > 0) { Thing vehicle = RightTools.GetRightVehicle(pawn, worktag); if (vehicle != null) { job = new Job(HaulJobDefOf.Mount) { targetA = vehicle, }; } } } else { if (!ToolsForHaulUtility.IsDriverOfThisVehicle(pawn, RightTools.GetRightVehicle(pawn, worktag))) { job = ToolsForHaulUtility.DismountInBase(pawn, MapComponent_ToolsForHaul.currentVehicle[pawn]); } } return(job); }
public override ThinkResult TryIssueJobPackage(Pawn pawn) { Job job = TryGiveTerminalJob(pawn); bool jobNull = job == null; ThinkResult result; if (pawn.mindState.IsIdle) { //if (previousPawnWeapons.ContainsKey(pawn)) //{ // Apparel_Toolbelt toolbelt = ToolsForHaulUtility.TryGetToolbelt(pawn); // Pawn wearer = toolbelt.wearer; // if (wearer.equipment.Primary != null) // toolbelt.slotsComp.SwapEquipment(previousPawnWeapons[pawn]); // else // { // wearer.equipment.AddEquipment(previousPawnWeapons[pawn]); // toolbelt.slotsComp.slots.Remove(previousPawnWeapons[pawn]); // } // previousPawnWeapons.Remove(pawn); //} if (ToolsForHaulUtility.IsDriver(pawn)) { job = ToolsForHaulUtility.DismountInBase(pawn, MapComponent_ToolsForHaul.currentVehicle[pawn]); } } if (jobNull) { result = ThinkResult.NoJob; } else { if (pawn.Faction == Faction.OfPlayer) { if (job.def == JobDefOf.DoBill) { RightTools.EquipRigthTool(pawn, job.RecipeDef.workSpeedStat); } if (job.def == JobDefOf.Hunt) { RightTools.EquipRigthTool(pawn, StatDefOf.AccuracyLong); job = GetVehicle(pawn, job, WorkTypeDefOf.Hunting); } if (job.def == JobDefOf.FinishFrame || job.def == JobDefOf.Deconstruct || job.def == JobDefOf.Repair || job.def == JobDefOf.BuildRoof || job.def == JobDefOf.RemoveRoof || job.def == JobDefOf.RemoveFloor) { RightTools.EquipRigthTool(pawn, StatDefOf.ConstructionSpeed); if (ToolsForHaulUtility.Cart.Count > 0 || ToolsForHaulUtility.CartTurret.Count > 0) { Thing vehicle = RightTools.GetRightVehicle(pawn, WorkTypeDefOf.Construction); if (vehicle != null && pawn.Position.DistanceToSquared(vehicle.Position) < pawn.Position.DistanceToSquared(job.targetA.Cell)) { job = GetVehicle(pawn, job, WorkTypeDefOf.Construction); } } } if (job.def == JobDefOf.CutPlant || job.def == JobDefOf.Harvest) { RightTools.EquipRigthTool(pawn, StatDefOf.PlantWorkSpeed); } if (job.def == JobDefOf.Mine) { RightTools.EquipRigthTool(pawn, StatDefOf.MiningSpeed); } if (job.def == JobDefOf.TendPatient) { RightTools.EquipRigthTool(pawn, StatDefOf.BaseHealingQuality); } } result = new ThinkResult(job, this); } return(result); }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { Action action_Dismount; Action action_Mount; Action action_DismountInBase; Action action_MakeMount; Action action_Deconstruct; // do nothing if not of colony if (Faction != Faction.OfPlayer) { yield break; } foreach (FloatMenuOption fmo in base.GetFloatMenuOptions(myPawn)) { yield return(fmo); } action_Mount = () => { Job jobNew = new Job(HaulJobDefOf.Mount); Find.Reservations.ReleaseAllForTarget(this); jobNew.targetA = this; myPawn.jobs.StartJob(jobNew, JobCondition.InterruptForced); }; action_DismountInBase = () => { Job jobNew = ToolsForHaulUtility.DismountInBase(mountableComp.Driver, MapComponent_ToolsForHaul.currentVehicle[mountableComp.Driver]); myPawn.jobs.StartJob(jobNew, JobCondition.InterruptForced); }; action_Dismount = () => { if (!myPawn.Position.InBounds()) { mountableComp.DismountAt(myPawn.Position); return; } mountableComp.DismountAt(myPawn.Position - def.interactionCellOffset.RotatedBy(myPawn.Rotation)); myPawn.Position = myPawn.Position.RandomAdjacentCell8Way(); // mountableComp.DismountAt(myPawn.Position - VehicleDef.interactionCellOffset.RotatedBy(myPawn.Rotation)); }; action_MakeMount = () => { Pawn worker = null; Job jobNew = new Job(HaulJobDefOf.MakeMount); Find.Reservations.ReleaseAllForTarget(this); jobNew.maxNumToCarry = 1; jobNew.targetA = this; jobNew.targetB = myPawn; foreach (Pawn colonyPawn in Find.MapPawns.FreeColonistsSpawned) { if (colonyPawn.CurJob.def != jobNew.def && (worker == null || (worker.Position - myPawn.Position).LengthHorizontal > (colonyPawn.Position - myPawn.Position).LengthHorizontal)) { worker = colonyPawn; } } if (worker == null) { Messages.Message("NoWorkForMakeMount".Translate(), MessageSound.RejectInput); } else { worker.jobs.StartJob(jobNew, JobCondition.InterruptForced); } }; action_Deconstruct = () => { Find.Reservations.ReleaseAllForTarget(this); Find.Reservations.Reserve(myPawn, this); Find.DesignationManager.AddDesignation(new Designation(this, DesignationDefOf.Deconstruct)); Job job = new Job(JobDefOf.Deconstruct, this); myPawn.jobs.StartJob(job, JobCondition.InterruptForced); }; bool alreadyMounted = false; if (!mountableComp.IsMounted) { foreach (Vehicle_Turret cart in ToolsForHaulUtility.CartTurret) { if (cart.mountableComp.Driver == myPawn) { alreadyMounted = true; } } if (myPawn.Faction == Faction.OfPlayer && (myPawn.RaceProps.IsMechanoid || myPawn.RaceProps.Humanlike) && !alreadyMounted && !this.IsForbidden(myPawn.Faction)) { yield return(new FloatMenuOption("Mount".Translate(LabelShort), action_Mount)); } yield return(new FloatMenuOption("Deconstruct".Translate(LabelShort), action_Deconstruct)); } else if (myPawn == mountableComp.Driver) { yield return(new FloatMenuOption("Dismount".Translate(LabelShort), action_Dismount)); } yield return(new FloatMenuOption("DismountInBase".Translate(LabelShort), action_DismountInBase)); }