示例#1
0
        // called when designator successfuly selects at least one thing
        protected override void FinalizeDesignationSucceeded()
        {
            // plays corresponding sound
            base.FinalizeDesignationSucceeded();

            Job job = new Job(HaulJobDefOf.PutInBackpackSlot)
            {
                targetQueueA   = new List <TargetInfo>(),
                numToBringList = new List <int>(),
                targetB        = SlotsBackpackComp.parent
            };

            foreach (Thing thing in SlotsBackpackComp.designatedThings)
            {
                if (thing.IsForbidden(SlotsBackpackComp.owner))
                {
                    thing.SetForbidden(false);
                }

                job.targetQueueA.Add(thing);
                job.numToBringList.Add(thing.def.stackLimit);
                SlotsBackpackComp.owner.Reserve(thing);
            }
            SlotsBackpackComp.designatedThings.Clear();

            if (!job.targetQueueA.NullOrEmpty())
            {
                SlotsBackpackComp.owner.drafter.TakeOrderedJob(job);
            }

            // remove active selection after click
            DesignatorManager.Deselect();
        }
示例#2
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            Job jobNew = new Job(HaulJobDefOf.StandBy, c, 4800);

            driver.jobs.StartJob(jobNew, JobCondition.Incompletable);

            DesignatorManager.Deselect();
        }
示例#3
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            Job jobNew = new Job(DefDatabase <JobDef> .GetNamed("Standby"), c, 4800);

            driver.jobs.StartJob(jobNew, JobCondition.Incompletable);

            DesignatorManager.Deselect();
        }
示例#4
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            List <Thing> thingList = c.GetThingList();

            foreach (Thing thing in thingList)
            {
                Pawn pawn = thing as Pawn;

                bool alreadyMounted = false;
                foreach (Vehicle_Cart cart in ToolsForHaulUtility.Cart)
                {
                    if (cart.mountableComp.Driver == pawn)
                    {
                        alreadyMounted = true;
                    }
                }
                foreach (Vehicle_Turret cart in ToolsForHaulUtility.CartTurret)
                {
                    if (cart.mountableComp.Driver == pawn)
                    {
                        alreadyMounted = true;
                    }
                }
                if (pawn != null && pawn.Faction == Faction.OfPlayer && (pawn.RaceProps.IsMechanoid || pawn.RaceProps.Humanlike) && !alreadyMounted)
                {
                    Job jobNew = new Job(HaulJobDefOf.Mount);
                    Find.Reservations.ReleaseAllForTarget(vehicle);
                    jobNew.targetA = vehicle;
                    pawn.jobs.StartJob(jobNew, JobCondition.InterruptForced);
                    break;
                }
                if (pawn != null && (pawn.Faction == Faction.OfPlayer && pawn.RaceProps.Animal) && pawn.training.IsCompleted(TrainableDefOf.Obedience) && pawn.RaceProps.baseBodySize >= 1.0 && !alreadyMounted)
                {
                    Pawn worker = null;
                    Job  jobNew = new Job(HaulJobDefOf.MakeMount);
                    Find.Reservations.ReleaseAllForTarget(vehicle);
                    jobNew.maxNumToCarry = 1;
                    jobNew.targetA       = vehicle;
                    jobNew.targetB       = pawn;
                    foreach (Pawn colonyPawn in Find.MapPawns.FreeColonistsSpawned)
                    {
                        if (colonyPawn.CurJob.def != jobNew.def && (worker == null || (worker.Position - pawn.Position).LengthHorizontal > (colonyPawn.Position - pawn.Position).LengthHorizontal))
                        {
                            worker = colonyPawn;
                        }
                    }
                    if (worker == null)
                    {
                        Messages.Message("NoWorkForMakeMount".Translate(), MessageSound.RejectInput);
                        break;
                    }
                    worker.jobs.StartJob(jobNew, JobCondition.InterruptForced);
                    break;
                }
            }
            DesignatorManager.Deselect();
        }
        public static void Prefix(DesignatorManager __instance)
        {
            if (!DesignatorShapes.Settings.EnableKeyboardInput)
            {
                return;
            }

            if (Event.current.type == EventType.KeyDown && Event.current.alt && DesignatorShapes.Settings.RestoreAltToggle)
            {
                DesignatorShapes.ShowControls = !DesignatorShapes.ShowControls;
            }

            if (!DesignatorShapes.ShowControls)
            {
                return;
            }
            if (__instance.SelectedDesignator == null)
            {
                return;
            }
            if (!__instance.SelectedDesignator.CanRemainSelected())
            {
                __instance.Deselect();
                return;
            }

            if (__instance.SelectedDesignator.DraggableDimensions == 0)
            {
                return;
            }
            if (Event.current.type == EventType.KeyDown)
            {
                var key = Event.current.keyCode;

                if (key == DesignatorShapes.Settings.Keys[DesignatorSettings.RotateLeftKeyIndex])
                {
                    RotateShape(Event.current, 1);
                }
                else if (key == DesignatorShapes.Settings.Keys[DesignatorSettings.RotateRightKeyIndex])
                {
                    RotateShape(Event.current, -1);
                }
                else if (key == DesignatorShapes.Settings.Keys[DesignatorSettings.FillCornersToggleKeyIndex])
                {
                    DesignatorShapes.FillCorners = !DesignatorShapes.FillCorners;
                }
                else if (key == DesignatorShapes.Settings.Keys[DesignatorSettings.IncreaseThicknessKeyIndex])
                {
                    DesignatorShapes.IncreaseThickness();
                }
                else if (key == DesignatorShapes.Settings.Keys[DesignatorSettings.DecreaseThicknessKeyIndex])
                {
                    DesignatorShapes.DecreaseThickness();
                }
            }
        }
示例#6
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            List <Thing> thingList = c.GetThingList();

            foreach (var thing in thingList)
            {
                Pawn pawn = thing as Pawn;
                if (pawn != null && (pawn.Faction == Faction.OfColony && (pawn.RaceProps.mechanoid || pawn.RaceProps.Humanlike)))
                {
                    Pawn crew   = pawn;
                    Job  jobNew = new Job(DefDatabase <JobDef> .GetNamed("Board"));
                    Find.Reservations.ReleaseAllForTarget(vehicle);
                    jobNew.targetA = vehicle;
                    crew.drafter.TakeOrderedJob(jobNew);
                    break;
                }
            }
            DesignatorManager.Deselect();
        }
        public override void DesignateSingleCell(IntVec3 c)
        {
            List <Thing> thingList = c.GetThingList();

            foreach (Thing thing in thingList)
            {
                Pawn pawn = thing as Pawn;
                if (pawn != null && pawn.Faction == Faction.OfPlayer && (pawn.RaceProps.IsMechanoid || pawn.RaceProps.Humanlike))
                {
                    Pawn crew   = pawn;
                    Job  jobNew = new Job(HaulJobDefOf.Board);
                    Find.Reservations.ReleaseAllForTarget(vehicle);
                    jobNew.targetA = vehicle;
                    crew.drafter.TakeOrderedJob(jobNew);
                    break;
                }
            }
            DesignatorManager.Deselect();
        }
示例#8
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            List <Thing> thingList = c.GetThingList();

            foreach (var thing in thingList)
            {
                Pawn pawn = thing as Pawn;
                if (pawn != null && pawn.health.ShouldBeTendedNow)
                {
                    Job jobNew = new Job(DefDatabase <JobDef> .GetNamed("ApplyMedicine"));
                    jobNew.targetA       = pawn;
                    jobNew.targetB       = medicine;
                    jobNew.maxNumToCarry = Medicine.GetMedicineCountToFullyHeal(jobNew.targetA.Thing as Pawn);
                    doctor.drafter.TakeOrderedJob(jobNew);
                    break;
                }
            }
            DesignatorManager.Deselect();
        }
        public override void DesignateSingleCell(IntVec3 c)
        {
            List <Thing> thingList = c.GetThingList();

            foreach (Thing thing in thingList)
            {
                Pawn pawn = thing as Pawn;
                if (pawn != null && (pawn.Faction == Faction.OfPlayer || (pawn.RaceProps.Animal && pawn.drafter != null)))
                {
                    Pawn driver = pawn;
                    Job  job    = new Job(DefDatabase <JobDef> .GetNamed("Board"));
                    Find.Reservations.ReleaseAllForTarget(vehicle);
                    job.targetA = vehicle;
                    job.targetB = mountPos;
                    driver.jobs.StartJob(job, JobCondition.InterruptForced);
                    break;
                }
            }
            DesignatorManager.Deselect();
        }
示例#10
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            List <Thing> thingList = c.GetThingList();

            foreach (var thing in thingList)
            {
                Pawn pawn = thing as Pawn;
                if (pawn != null && (pawn.Faction == Faction.OfColony && (pawn.RaceProps.mechanoid || pawn.RaceProps.Humanlike)))
                {
                    Job jobNew = new Job(DefDatabase <JobDef> .GetNamed("Mount"));
                    Find.Reservations.ReleaseAllForTarget(vehicle);
                    jobNew.targetA = vehicle;
                    pawn.jobs.StartJob(jobNew, JobCondition.InterruptForced);
                    break;
                }
                else if (pawn != null && (pawn.Faction == Faction.OfColony && pawn.RaceProps.Animal && pawn.training.IsCompleted(TrainableDefOf.Obedience) && pawn.RaceProps.baseBodySize >= 1.0))
                {
                    Pawn worker = null;
                    Job  jobNew = new Job(DefDatabase <JobDef> .GetNamed("MakeMount"));
                    Find.Reservations.ReleaseAllForTarget(vehicle);
                    jobNew.maxNumToCarry = 1;
                    jobNew.targetA       = vehicle;
                    jobNew.targetB       = pawn;
                    foreach (Pawn colonyPawn in Find.ListerPawns.FreeColonistsSpawned)
                    {
                        if (colonyPawn.CurJob.def != jobNew.def && (worker == null || (worker.Position - pawn.Position).LengthHorizontal > (colonyPawn.Position - pawn.Position).LengthHorizontal))
                        {
                            worker = colonyPawn;
                        }
                    }
                    if (worker == null)
                    {
                        Messages.Message("NoWorkForMakeMount".Translate(), MessageSound.RejectInput);
                        break;
                    }
                    worker.jobs.StartJob(jobNew, JobCondition.InterruptForced);
                    break;
                }
            }
            DesignatorManager.Deselect();
        }
示例#11
0
        protected override void FinalizeDesignationSucceeded()
        {
            Job jobNew = new Job(DefDatabase <JobDef> .GetNamed("PutInInventory"));

            jobNew.maxNumToCarry = 1;
            jobNew.targetB       = backpack;
            jobNew.targetQueueA  = new List <LocalTargetInfo>();

            while (!designations.NullOrEmpty())
            {
                jobNew.targetQueueA.Add(designations.First().target.Thing);
                designations.RemoveAt(0);
            }
            if (!jobNew.targetQueueA.NullOrEmpty())
            {
                //if (backpack.wearer.drafter.CanTakePlayerJob())
                backpack.wearer.drafter.TakeOrderedJob(jobNew);
            }
            //else
            //    backpack.wearer.drafter.QueueJob(jobNew);
            DesignatorManager.Deselect();
        }
        public void Notify_SwitchedMap()
        {
            designatorManager.Deselect();
            reverseDesignatorDatabase.Reinit();
            selector.ClearSelection();
            selector.dragBox.active = false;
            targeter.StopTargeting();
            MainButtonDef        openTab = Find.MainTabsRoot.OpenTab;
            List <MainButtonDef> allDefsListForReading = DefDatabase <MainButtonDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                allDefsListForReading[i].Notify_SwitchedMap();
            }
            if (openTab != null && openTab != MainButtonDefOf.Inspect)
            {
                Find.MainTabsRoot.SetCurrentTab(openTab, playSound: false);
            }
            if (Find.CurrentMap != null)
            {
                RememberedCameraPos rememberedCameraPos = Find.CurrentMap.rememberedCameraPos;
                Find.CameraDriver.SetRootPosAndSize(rememberedCameraPos.rootPos, rememberedCameraPos.rootSize);
            }
        }
        public override void DesignateSingleCell(IntVec3 c)
        {
            List <Thing> thingList = c.GetThingList();

            foreach (Thing thing in thingList)
            {
                Pawn pawn = thing as Pawn;
                if (pawn != null && pawn.health.ShouldBeTendedNow)
                {
                    Job jobNew = new Job(HaulJobDefOf.ApplyMedicine);
                    jobNew.targetA = pawn;

                    Thing dummy;
                    SlotsBackpackComp.slots.TryDrop(medicine, doctor.Position, ThingPlaceMode.Direct, Medicine.GetMedicineCountToFullyHeal(jobNew.targetA.Thing as Pawn), out dummy);

                    jobNew.targetB = dummy;

                    jobNew.maxNumToCarry = Medicine.GetMedicineCountToFullyHeal(jobNew.targetA.Thing as Pawn);
                    doctor.drafter.TakeOrderedJob(jobNew);
                    break;
                }
            }
            DesignatorManager.Deselect();
        }
 public void PanelClosing()
 {
     DesignatorManager.Deselect();
 }