Exemple #1
0
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            HaulExplicitlyPosting posting = HaulExplicitly.GetManager(Find.CurrentMap).PostingWithItem(thing);

            if (posting != null)
            {
                posting.TryRemoveItem(thing, true);
                foreach (Pawn p in Find.CurrentMap.mapPawns.PawnsInFaction(Faction.OfPlayer))
                {
                    var jobs = new List <Job>(p.jobs.jobQueue.AsEnumerable().Select(j => j.job));
                    if (p.CurJob != null)
                    {
                        jobs.Add(p.CurJob);
                    }
                    foreach (var job in jobs)
                    {
                        if (job.def.driverClass == typeof(JobDriver_HaulExplicitly) &&
                            job.targetA.Thing == thing)
                        {
                            p.jobs.EndCurrentOrQueuedJob(job, JobCondition.Incompletable);
                        }
                    }
                }
            }
        }
Exemple #2
0
        public void init()
        {
            Thing targetItem = job.targetA.Thing;

            _posting = HaulExplicitly.GetManager(targetItem.MapHeld).postings[posting_id];
            _record  = _posting.RecordWithItem(targetItem);
        }
Exemple #3
0
        public static void DrawForItem(Thing item)
        {
            var mgr = HaulExplicitly.GetManager(item.Map);
            HaulExplicitlyPosting posting = mgr.PostingWithItem(item);

            if (posting == null)
            {
                return;
            }
            //draw line
            Vector3 start         = item.Position.ToVector3ShiftedWithAltitude(alt);
            Vector3 circle_center = posting.center;

            circle_center.y = alt;
            Vector3 line_vector = circle_center - start;

            if (line_vector.magnitude > posting.visualization_radius)
            {
                line_vector = line_vector.normalized * (line_vector.magnitude - posting.visualization_radius);
                GenDraw.DrawLineBetween(start, start + line_vector);
            }

            if (postings_drawn_this_frame.Contains(posting.id))
            {
                return;
            }
            postings_drawn_this_frame.Add(posting.id);
            //draw circle
            GenDraw.DrawCircleOutline(circle_center, posting.visualization_radius);
        }
Exemple #4
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            HaulExplicitlyPosting posting = Designator_HaulExplicitly.prospective_job;

            posting.TryMakeDestinations(UI.MouseMapPosition(), false);
            HaulExplicitly.RegisterPosting(posting);
            ResetJob();
        }
Exemple #5
0
 public static DeliverableDestinations For(
     Thing item, Pawn carrier, HaulExplicitlyPosting posting = null, Func <IntVec3, float> grader = null)
 {
     if (posting == null) //do the handholdy version of this function
     {
         posting = HaulExplicitly.GetManager(item.Map).PostingWithItem(item);
         if (posting == null)
         {
             throw new ArgumentException();
         }
     }
     return(new DeliverableDestinations(item, carrier, posting, (grader != null) ? grader : DefaultGrader));
 }
        public static void SetRetaining(this Zone_Stockpile z, bool value)
        {
            var hs = HaulExplicitly.GetRetainingZones();

            if (value)
            {
                hs.Add(z);
            }
            else
            {
                hs.Remove(z);
            }
        }
Exemple #7
0
        static void Postfix(CompressibilityDecider __instance)
        {
            HashSet <Thing> referencedThings =
                (HashSet <Thing>) typeof(CompressibilityDecider).InvokeMember("referencedThings",
                                                                              BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic,
                                                                              null, __instance, null);
            Map map = (Map)typeof(CompressibilityDecider).InvokeMember("map",
                                                                       BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic,
                                                                       null, __instance, null);

            foreach (Thing t in HaulExplicitly.GetManager(map).haulables)
            {
                referencedThings.Add(t);
            }
        }
Exemple #8
0
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            Selector              selector  = Find.Selector;
            List <object>         selection = selector.SelectedObjects;
            Thing                 example   = (Thing)selection.First();
            HaulExplicitlyPosting posting   = HaulExplicitly.GetManager(example.Map).PostingWithItem(example);

            foreach (object o in posting.items)
            {
                Thing t = o as Thing;
                if (!selection.Contains(o) && t != null && t.Spawned)
                {
                    selector.Select(o);
                }
            }
        }
Exemple #9
0
        public static bool RelevantToThing(Thing t)
        {
            var mgr = HaulExplicitly.GetManager(t.Map);
            HaulExplicitlyPosting posting = mgr.PostingWithItem(t);

            if (posting == null)
            {
                return(false);
            }
            foreach (object o in Find.Selector.SelectedObjects)
            {
                Thing other = o as Thing;
                if (other == null || !posting.items.Contains(other))
                {
                    return(false);
                }
            }
            return(Find.Selector.SelectedObjects.Count < posting.items.Count(i => i.Spawned));
        }
Exemple #10
0
        public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            if (!CanGetThing(pawn, t, forced))
            {
                return(null);
            }

            //plan count and dests
            HaulExplicitlyPosting posting = HaulExplicitly.GetManager(t.Map).PostingWithItem(t);

            if (posting == null)
            {
                return(null);
            }
            int            space_request        = AmountPawnWantsToPickUp(pawn, t, posting);
            var            destInfo             = DeliverableDestinations.For(t, pawn, posting);
            List <IntVec3> dests                = destInfo.RequestSpaceForItemAmount(space_request);
            int            dest_space_available = destInfo.FreeSpaceInCells(dests);
            var            count                = Math.Min(space_request, dest_space_available);

            if (count < 1)
            {
                return(null);
            }

            //make job
            JobDef JobDefOfHaulExplicitly =
                (JobDef)(GenDefDatabase.GetDef(typeof(JobDef), "HaulExplicitlyHaul"));
            Job job = new Job(JobDefOfHaulExplicitly, t, dests.First());

            //((JobDriver_HaulExplicitly)job.GetCachedDriver(pawn)).init();
            job.count        = count;
            job.targetQueueA = new List <LocalTargetInfo>(
                new LocalTargetInfo[] { new IntVec3(posting.id, dest_space_available, 0) });
            job.targetQueueB = new List <LocalTargetInfo>(dests.Skip(1).Take(dests.Count - 1)
                                                          .Select(c => new LocalTargetInfo(c)));
            job.haulOpportunisticDuplicates = true;
            return(job);
        }
Exemple #11
0
        public HaulExplicitlyPosting(IEnumerable <object> objects)
        {
            id  = HaulExplicitly.GetNewPostingID();
            map = Find.CurrentMap;
            foreach (object o in objects)
            {
                Thing t = o as Thing;
                if (t == null || !t.def.EverHaulable)
                {
                    continue;
                }

                items.Add(t);
                foreach (HaulExplicitlyInventoryRecord record in inventory)
                {
                    if (record.TryAddItem(t))
                    {
                        goto match;
                    }
                }
                inventory.Add(new HaulExplicitlyInventoryRecord(t, this));
                match : { }
            }
        }
Exemple #12
0
        public static bool RelevantToThing(Thing t)
        {
            var mgr = HaulExplicitly.GetManager(t.Map);

            return(mgr.PostingWithItem(t) != null);
        }
Exemple #13
0
 public override IEnumerable <Thing> PotentialWorkThingsGlobal(Pawn pawn)
 {
     return(HaulExplicitly.GetManager(pawn.Map).haulables);
 }
Exemple #14
0
 public HaulExplicitly()
 {
     _instance = this;
 }
        public static bool IsRetaining(this Zone_Stockpile z)
        {
            var hs = HaulExplicitly.GetRetainingZones();

            return(hs.Contains(z));
        }